# Script autostart

**URL:** <https://forums.openmv.io/t/script-autostart/633>\
**Category:** OpenMV Boards\
**Created:** [March 25, 2018, 10:41am UTC](https://forums.openmv.io/t/script-autostart/633 "2018-03-25T10:41:43Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![DCON81](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@DCON81](https://forums.openmv.io/u/DCON81)\
**Post date:** [March 25, 2018, 10:41am UTC](https://forums.openmv.io/t/script-autostart/633/1 "2018-03-25T10:41:43Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [March 25, 2018, 5:54pm UTC](https://forums.openmv.io/t/script-autostart/633/2 "2018-03-25T17:54:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![DCON81](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@DCON81](https://forums.openmv.io/u/DCON81)\
**Post date:** [March 28, 2018, 2:56pm UTC](https://forums.openmv.io/t/script-autostart/633/3 "2018-03-28T14:56:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![levinpqr](https://avatars.discourse-cdn.com/v4/letter/l/9de0a6/32.png) [@levinpqr](https://forums.openmv.io/u/levinpqr)\
**Post date:** [June 28, 2018, 9:15am UTC](https://forums.openmv.io/t/script-autostart/633/4 "2018-06-28T09:15:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [June 28, 2018, 4:00pm UTC](https://forums.openmv.io/t/script-autostart/633/5 "2018-06-28T16:00:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![levinpqr](https://avatars.discourse-cdn.com/v4/letter/l/9de0a6/32.png) [@levinpqr](https://forums.openmv.io/u/levinpqr)\
**Post date:** [June 29, 2018, 5:36am UTC](https://forums.openmv.io/t/script-autostart/633/6 "2018-06-29T05:36:28Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [June 29, 2018, 5:55am UTC](https://forums.openmv.io/t/script-autostart/633/7 "2018-06-29T05:55:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![levinpqr](https://avatars.discourse-cdn.com/v4/letter/l/9de0a6/32.png) [@levinpqr](https://forums.openmv.io/u/levinpqr)\
**Post date:** [June 29, 2018, 6:32am UTC](https://forums.openmv.io/t/script-autostart/633/8 "2018-06-29T06:32:15Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [June 29, 2018, 6:36am UTC](https://forums.openmv.io/t/script-autostart/633/9 "2018-06-29T06:36:54Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![levinpqr](https://avatars.discourse-cdn.com/v4/letter/l/9de0a6/32.png) [@levinpqr](https://forums.openmv.io/u/levinpqr)\
**Post date:** [June 29, 2018, 6:43am UTC](https://forums.openmv.io/t/script-autostart/633/10 "2018-06-29T06:43:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [June 29, 2018, 6:47am UTC](https://forums.openmv.io/t/script-autostart/633/11 "2018-06-29T06:47:59Z")

</div>

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

```python
print()

```

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

```python
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.

---

<div class="post-metadata">

**Author:** ![levinpqr](https://avatars.discourse-cdn.com/v4/letter/l/9de0a6/32.png) [@levinpqr](https://forums.openmv.io/u/levinpqr)\
**Post date:** [June 29, 2018, 7:01am UTC](https://forums.openmv.io/t/script-autostart/633/12 "2018-06-29T07:01:59Z")

</div>

Ok! Thank you sir!

---

<div class="post-metadata">

**Author:** ![levinpqr](https://avatars.discourse-cdn.com/v4/letter/l/9de0a6/32.png) [@levinpqr](https://forums.openmv.io/u/levinpqr)\
**Post date:** [July 6, 2018, 7:55am UTC](https://forums.openmv.io/t/script-autostart/633/13 "2018-07-06T07:55:34Z")

</div>

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](https://canada1.discourse-cdn.com/flex029/uploads/openmv1/original/1X/05cbf43b27aaeb0529f3368d58cfc839f9c73d8a.png)

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [July 6, 2018, 5:12pm UTC](https://forums.openmv.io/t/script-autostart/633/14 "2018-07-06T17:12:07Z")

</div>

Yes, use this script: [openmv/pyopenmv.py at master · openmv/openmv · GitHub](https://github.com/openmv/openmv/blob/master/tools/pyopenmv.py)

---

<div class="post-metadata">

**Author:** ![levinpqr](https://avatars.discourse-cdn.com/v4/letter/l/9de0a6/32.png) [@levinpqr](https://forums.openmv.io/u/levinpqr)\
**Post date:** [July 9, 2018, 6:35am UTC](https://forums.openmv.io/t/script-autostart/633/15 "2018-07-09T06:35:10Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [July 9, 2018, 5:33pm UTC](https://forums.openmv.io/t/script-autostart/633/16 "2018-07-09T17:33:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![levinpqr](https://avatars.discourse-cdn.com/v4/letter/l/9de0a6/32.png) [@levinpqr](https://forums.openmv.io/u/levinpqr)\
**Post date:** [July 10, 2018, 4:47am UTC](https://forums.openmv.io/t/script-autostart/633/17 "2018-07-10T04:47:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [July 10, 2018, 5:10am UTC](https://forums.openmv.io/t/script-autostart/633/18 "2018-07-10T05:10:10Z")

</div>

[http://docs.openmv.io/openmvcam/tutorial/software\_setup.html#linux-desktop](http://docs.openmv.io/openmvcam/tutorial/software_setup.html#linux-desktop)

It actually comes with openmv ide.

---

<div class="post-metadata">

**Author:** ![levinpqr](https://avatars.discourse-cdn.com/v4/letter/l/9de0a6/32.png) [@levinpqr](https://forums.openmv.io/u/levinpqr)\
**Post date:** [July 10, 2018, 7:50am UTC](https://forums.openmv.io/t/script-autostart/633/19 "2018-07-10T07:50:55Z")

</div>

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…

 ![OPEN.png](https://canada1.discourse-cdn.com/flex029/uploads/openmv1/original/1X/6034fd22a8aa108dccdc15e95550002419fb2bf5.png)

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [July 11, 2018, 5:52am UTC](https://forums.openmv.io/t/script-autostart/633/20 "2018-07-11T05:52:43Z")

</div>

Go to share/qtcreaotr/pydfu.

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

[Next page](https://forums.openmv.io/t/script-autostart/633.md?page=2)
