# Library import doesn't work unless launched from IDE

**URL:** <https://forums.openmv.io/t/library-import-doesnt-work-unless-launched-from-ide/11385>\
**Category:** OpenMV Boards\
**Created:** [October 10, 2025, 5:05am UTC](https://forums.openmv.io/t/library-import-doesnt-work-unless-launched-from-ide/11385 "2025-10-10T05:05:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![annm](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@annm](https://forums.openmv.io/u/annm)\
**Post date:** [October 10, 2025, 5:05am UTC](https://forums.openmv.io/t/library-import-doesnt-work-unless-launched-from-ide/11385/1 "2025-10-10T05:05:30Z")

</div>

Hello. I’m using OpenMV H7 Plus board with Arduino Mega 2560.  
For my project I’m using library for OpenMV ([openrv/homography/README.md at master · nickoala/openrv · GitHub](https://github.com/nickoala/openrv/blob/master/homography/README.md)). I put files on my camera’s SD-card like this:

```auto
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 23.05.2025 15:16 rv
d----- 23.05.2025 15:16 vec
-a---- 01.01.2015 0:00 0 .openmv_disk
-a---- 24.03.2025 11:49 1904 mtx.py
-a---- 09.10.2025 14:30 171 main.py

```

My problem is that when I launch my script via OpenMV IDE - everything is great - I get messages with data on my mega and everything works. When I try to start this whole project automaticly - not via IDE but just with power source and UART connection between Mega and OpenMV - I dont get any data at all on my Arduino - unless I firstly start camera script via IDE - then unplug it cable from my computer and then it continues working and my Arduino gets data.

I probably should mention that other code like simple “Hello World!” passing from camera to arduino works perfectly, and the cable was tested - it’s not faulty. And the UART connection is correct. The problem is probably in libaries, it feels like my main.py file can’t open files in rv lib?

Can anyone help with this problem?

My code for OpenMV:

```auto
import sensor, utime
from pyb import UART
from rv.planar import Planar

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.set_auto_gain(False, gain_db=22.6067)
sensor.set_auto_whitebal(False, rgb_gain_db=(64.3917, 60.206, 62.8227))
sensor.set_auto_exposure(False, exposure_us=12000)
sensor.skip_frames(time=500)
thresholds = [(61, 94, -39, -9, -2, 39)]

uart = UART(1, 19200, timeout_char=200)
H = [[-3.53512728e-02, -1.71368433e+00, 3.98107181e+02],
[1.72228029e+00, -3.30469606e-02, -2.69140391e+02],
[1.20710983e-04, -1.79347218e-04, 1.00000000e+00]]

offset = [-100, 10]

while True:
    img = sensor.snapshot() .lens_corr(1.2) # .rotation_corr(x_rotation = -25)

    p = Planar(H, offset)

    blobs = img.find_blobs(thresholds, pixels_threshold=150, area_threshold=150)
    if len(blobs) > 0:
        blob = blobs[0]
        img.draw_rectangle(blob.rect())
        img.draw_cross(blob.cx(), blob.cy())

        coordinates = [[blob.cx(), blob.cy()]]
        result = p.project(coordinates)[0]
        print(f"x = {result[1]}, y = {result[0]}")

        uart.write("{} {}\n".format(result[1], result[0]))
        utime.sleep_ms(100)

```

Code for testing if Arduino gets any data:

```auto
void setup() {
  // put your setup code here, to run once:
  Serial.begin(19200);
  Serial3.begin(19200);
}

void loop() {
  // put your main code here, to run repeatedly:
  if (Serial3.available()) {
    // Read the most recent byte
    byte byteRead = Serial3.read();
    // ECHO the value that was read
    Serial.write(byteRead);
  }
}

```

---

<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:** [October 10, 2025, 5:45pm UTC](https://forums.openmv.io/t/library-import-doesnt-work-unless-launched-from-ide/11385/2 "2025-10-10T17:45:40Z")

</div>

Did you save your script to main.py on the camera? From the listing you posted your main.py is 171 bytes which is a lot smaller than the one you have posted here on the forums.

---

<div class="post-metadata">

**Author:** ![annm](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@annm](https://forums.openmv.io/u/annm)\
**Post date:** [October 11, 2025, 5:11am UTC](https://forums.openmv.io/t/library-import-doesnt-work-unless-launched-from-ide/11385/3 "2025-10-11T05:11:36Z")

</div>

Yes, I saved it via command in OpenMV IDE that reads something like “Save to OpenMV Cam as main.py script”. I tried running project on couple of H7 Plus cams, so I might have posted the listing for the one that I then tested simple UART-connection to check if UART is OK on.  
Sorry if it was misleading

Is there any possibility that my cam isn’t reading library files when its not connected to the PC?

---

<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:** [October 11, 2025, 7:11pm UTC](https://forums.openmv.io/t/library-import-doesnt-work-unless-launched-from-ide/11385/4 "2025-10-11T19:11:24Z")

</div>

Hi, I’d check what is inside the main.py file on the camera. 171 bytes is a very small file with a very little amount of code. You can open the file via any standard text editor.
