Script autostart

I’ve no sd card.
I want the script to start when board powered.
In the IDE i’ve done “Save open script to OPENMV Cam” but no autostart …

I’m missing something ?

Hi, after saving the script to the OpenMV Cam please click the reset OpenMV Cam button right under the save script button. The script should be flushed to the camera then and it should auto-start.

Issue was solved updating the IDE and updating the firmware of the cam.

Hello! I connected OpenMV M7 to my Raspberry Pi… I want to open OpenMV IDE using python scripts, CONNECT to the camera, and START running the script… Does anyone know how to do it? Thanks

Hi, are you talking about scripting up OpenMV IDE? Um, so, if you launch OpenMV IDE via the command line. You can pass it a file path as it’s first argument and it will open that file. Then, if you can emulate pressing ctrl+e and then ctrl+r it will run the script.

Alternatively, you can save a script on the camera permanently and then launch the IDE using command line options which will allow you to create terminal windows to show the debug output for demo purposes. I built this feature into the IDE for folks. Does this sound like what you want? The script needs to be on the camera before hand… but, otherwise, you can launch the IDE and have it display debug output (without the text editor appearing and other buttons) via the command line.

Thank you for the prompt reply sir kwagyeman!

Well what I want to happen is to automatically run the python script for the camera, not necessarily open the OPENMV IDE… Thanks!

  1. Open the script in the IDE.
  2. Go to Tools → Save Script to OpenMV Cam
  3. Go to Tools → Reset OpenMV Cam

The script will now start when the camera starts.

Thank you again for the prompt reply… That information is very useful sir, however my code is still a work in progress… If “Save Open Script to OpenMV Cam” now and do it again with newly updated code, which code will it run when I boot it up?

Will it follow the most recent one? Thanks!

Yes. All this does is create/update a file called main.py on the OpenMV Cam. All micropython boards run a main.py script on startup.

Hello! Last questions… I tried it out and it did run the autostart… However:

  1. Is there a way that I may be able to see the images it sees?

  2. I cant seem to stop the autostarted script since it boots up. How do I stop it without turning it off?

Thanks

Yes,

Go to Tools:

Open Terminal → New Terminal → Serial Port → Select the right comm port → Any baud rate (default is fine).

This pops open a terminal which will show you the

print()

output from the camera. If you want to also see what the camera sees in this view you need to add

print(img.compressed_for_ide(quality=50), end='')

to your script near the end of your while loop to tell the camera to send serial data over the USB port.

If you connect to the OpenMV Cam using the normal connect button the auto started script stops. If you’d like to permanently stop the auto start behavior delete the main.py file on your OpenMV Cam.

Ok! Thank you sir!

Hello! I’m sorry for the additional questions… I’m currently attaching my OPENMV cam to my laptop and I’m running a GUI on python as can be seen on the attached image.

In the attached image, you can see the GUI. When the users clicks “enable camera”, I would like the openmv to start its facial recognition script without having to open the OPENMV IDE and connecting to it.

Is there a way to run the scripts of the code by triggering it in a python script (GUI)? Thanks
attach.png

Yes, use this script: openmv/pyopenmv.py at master · openmv/openmv · GitHub

Hello! Sorry I’m kinda having a hard time trying to understand that code… Do you mind helping me out a bit on how to set it up?

Let’s say I connected my cam to my linux laptop in this port: “ttyACM0”

and have to run the script in this script: “home/pythonfiles/GUI/GUI_tester.py”

any help would be appreciated. Thanks!

Ah, so, the script uses the /dev/openmvcam port which is created only if you install the openmv udev rules. In the top level of the OpenMV repo you need to install the udev rules. Once you do that then on Linux the camera will appear as a /dev/openmvcam device.

Please let me know if this works for you. Then, you can just run that script I linked to and provide it with a path to the script you want the camera to run.

How do I do that exactly? I’m sorry I’m still new at this… I cloned the openmv repository… but I don’t know how to install udev.

http://docs.openmv.io/openmvcam/tutorial/software_setup.html#linux-desktop

It actually comes with openmv ide.

Yes I did that and donwloaded it for RPi however I only have these files in the openmv/openmvide directory (see image attached)… there’s no udev folder…

Go to share/qtcreaotr/pydfu.

However, if you just run the ./setup.sh script it takes care of the install for you.