OpenMV camera works then quits

OpenMV related project discussion.
tomkib
Posts: 10
Joined: Sun Jun 14, 2020 9:00 pm

OpenMV camera works then quits

Postby tomkib » Sun Jun 14, 2020 9:08 pm

using circle detection and system works for a bit then disconnects itself and then end by opens its internal flash drive with blue led flashing
please advise
Tom
# Find Circles Example
#
# This example shows off how to find circles in the image using the Hough
# Transform. https://en.wikipedia.org/wiki/Circle_Hough_Transform
#
# Note that the find_circles() method will only find circles which are completely
# inside of the image. Circles which go outside of the image/roi are ignored...

import sensor, image, time,pyb

sensor.reset()
sensor.set_pixformat(sensor.RGB565) # grayscale is faster
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
ledRed =pyb.LED(1)

while(True):
clock.tick()
img = sensor.snapshot().lens_corr(1.8)

# Circle objects have four values: x, y, r (radius), and magnitude. The
# magnitude is the strength of the detection of the circle. Higher is
# better...

# `threshold` controls how many circles are found. Increase its value
# to decrease the number of circles detected...

# `x_margin`, `y_margin`, and `r_margin` control the merging of similar
# circles in the x, y, and r (radius) directions.

# r_min, r_max, and r_step control what radiuses of circles are tested.
# Shrinking the number of tested circle radiuses yields a big performance boost.

for c in img.find_circles(threshold = 2000, x_margin = 10, y_margin = 10, r_margin = 10,
r_min = 2, r_max = 100, r_step = 2):
img.draw_circle(c.x(), c.y(), c.r(), color = (255, 0, 0))
ledRed.on()
print("Circle Detected");
print(c)
pyb.delay(500)
ledRed.off()

# print("FPS %f" % clock.fps())
print ("*")
User avatar
kwagyeman
Posts: 4655
Joined: Sun May 24, 2015 2:10 pm

Re: OpenMV camera works then quits

Postby kwagyeman » Sun Jun 14, 2020 10:47 pm

Hi, can you post the script using code tags and then let me know the firmware version and camera model you are using? I should be able to duplicate the issue then. Sounds like you are hitting a bug causing memory corruption causing a system reboot.
Nyamekye,
tomkib
Posts: 10
Joined: Sun Jun 14, 2020 9:00 pm

Re: OpenMV camera works then quits

Postby tomkib » Mon Jun 15, 2020 8:33 pm

Code: Select all

# Find Circles Example
#
# This example shows off how to find circles in the image using the Hough
# Transform. https://en.wikipedia.org/wiki/Circle_Hough_Transform
#
# Note that the find_circles() method will only find circles which are completely
# inside of the image. Circles which go outside of the image/roi are ignored...

import sensor, image, time,pyb

sensor.reset()
sensor.set_pixformat(sensor.RGB565) # grayscale is faster
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
ledRed =pyb.LED(1)

while(True):
    clock.tick()
    img = sensor.snapshot().lens_corr(1.8)

    # Circle objects have four values: x, y, r (radius), and magnitude. The
    # magnitude is the strength of the detection of the circle. Higher is
    # better...

    # `threshold` controls how many circles are found. Increase its value
    # to decrease the number of circles detected...

    # `x_margin`, `y_margin`, and `r_margin` control the merging of similar
    # circles in the x, y, and r (radius) directions.

    # r_min, r_max, and r_step control what radiuses of circles are tested.
    # Shrinking the number of tested circle radiuses yields a big performance boost.

    for c in img.find_circles(threshold = 2000, x_margin = 10, y_margin = 10, r_margin = 10,
            r_min = 2, r_max = 100, r_step = 2):
        img.draw_circle(c.x(), c.y(), c.r(), color = (255, 0, 0))
        ledRed.on()
        print("Circle Detected");
        print(c)
        pyb.delay(500)
        ledRed.off()

  # print("FPS %f" % clock.fps())
    print ("*")

firmware 3.6.4

regards,
Tom
tomkib
Posts: 10
Joined: Sun Jun 14, 2020 9:00 pm

Re: OpenMV camera works then quits

Postby tomkib » Tue Jun 16, 2020 10:44 am

you asked for camera model it is OpenMV H7 with OV7725 image sensor

As I am testing i finding that turning off framebuffer increases the stability of operation--no crashes.

Hope this helps!
)
another question --where can i get the cifar file for net = nn.load('/cifar10.network'
please advise
Tom
User avatar
kwagyeman
Posts: 4655
Joined: Sun May 24, 2015 2:10 pm

Re: OpenMV camera works then quits

Postby kwagyeman » Tue Jun 16, 2020 11:12 am

Thanks for all the info. Should be able to debug it now. That network can be found with the IDE under tools -> Machine Vision -> CNN Library.
Nyamekye,
tomkib
Posts: 10
Joined: Sun Jun 14, 2020 9:00 pm

Re: OpenMV camera works then quits

Postby tomkib » Tue Jun 16, 2020 12:38 pm

Thank you, what is odd is that I can run HelloWorld w/o crashing. All other project and example run but at some point stop and disconnect the camera. I can easily reconnect and resume but again the disconnect occurs at some random interval . Seems like a buffer overflow? I am running under Window 10 and using an HP Specter with core I7 , lots of ram etc. I check both flash disk and USB all installed ok. The Open MV has a 2G SD card. It is not visible to Windows probably only the camera processor.
Hope this helps.
Regards,
Tom
User avatar
kwagyeman
Posts: 4655
Joined: Sun May 24, 2015 2:10 pm

Re: OpenMV camera works then quits

Postby kwagyeman » Wed Jun 17, 2020 1:39 am

Hi, I ran your code for over 1 hour and it didn't crash on my H7.

That said, I've noticed your code doesn't quite do what you think...

Code: Select all

for c in img.find_circles(threshold = 2000, x_margin = 10, y_margin = 10, r_margin = 10,
            r_min = 2, r_max = 100, r_step = 2):
        img.draw_circle(c.x(), c.y(), c.r(), color = (255, 0, 0))
        ledRed.on()
        print("Circle Detected");
        print(c)
        pyb.delay(500)
        ledRed.off()
Pauses per object in a list of objects. I think you want:

Code: Select all

circles = img.find_circles(threshold = 2000, x_margin = 10, y_margin = 10, r_margin = 10,
                r_min = 2, r_max = 100, r_step = 2)
    if circles:
        ledRed.on()
    if not circles:
        ledRed.off()
    for c in circles:
        img.draw_circle(c.x(), c.y(), c.r(), color = (255, 0, 0))
        print("Circle Detected");
        print(c)
Nyamekye,
tomkib
Posts: 10
Joined: Sun Jun 14, 2020 9:00 pm

Re: OpenMV camera works then quits

Postby tomkib » Wed Jun 17, 2020 11:05 am

I tired it and unfortunately got same results. The system runs and then disconnects after a time to USB, causing a need to reconnect.
I even uninstalled and reinstalled Open MV IDE w/o difference.
with frame buffer off it runs longer before disconnecting.

I am at a lot, any advise would help greatly.
Tom
User avatar
kwagyeman
Posts: 4655
Joined: Sun May 24, 2015 2:10 pm

Re: OpenMV camera works then quits

Postby kwagyeman » Wed Jun 17, 2020 11:17 am

It sounds like the camera is fine and the issue is your PC. Does the program stop working on the camera? Like, does the camera stop showing a red light when circles are in front of it? If not, then that means the camera is working fine and that your USB system is dropping packets and the IDE is not getting a response from the camera in a fast enough interval. The IDE disconnects when it is not able to poll the camera over USB. This can happen due to packet loss. That said, the IDE has a timeout of 3 seconds... So, for that to be violated means your PC has some bad USB issues.
Nyamekye,
tomkib
Posts: 10
Joined: Sun Jun 14, 2020 9:00 pm

Re: OpenMV camera works then quits

Postby tomkib » Wed Jun 17, 2020 12:47 pm

Thanks I agree . The PC is new Windows HP Spectre with both USB 2.0 and 3.0
Has anyone else experience a similar problem? Is there a way to configure setting on USB?
Tom
User avatar
kwagyeman
Posts: 4655
Joined: Sun May 24, 2015 2:10 pm

Re: OpenMV camera works then quits

Postby kwagyeman » Wed Jun 17, 2020 1:45 pm

Try using a different USB cable and plugging it directly into the PC.

We have rather low specs for the USB cable so it shouldn't be an issue.
Nyamekye,
tomkib
Posts: 10
Joined: Sun Jun 14, 2020 9:00 pm

Re: OpenMV camera works then quits

Postby tomkib » Wed Jun 17, 2020 4:23 pm

Ok I tried several USBs ( short, long, gold plated) still occasional crash!
I use USB all the tIme with ESP32 , Arduino, PIC32 w/o issue.
The though that bugs me is that Full frame Helloword works w/o any issue no crashes High FPS, It only occurs when I do other examples.
I am purchasing another Open MV from Sparkfun to determine if the current card is an issue.
Also when I return home from Florida I try my other laptop.
Something has got to shake loose.
Other observations- if I delay the processing loop to achieve low FPS it seems to work for circles detection!?
I think your product is very cool, however, for me to use it I got to overcome this bump in the road.
I will keep you informed
Regards,
Tom
User avatar
kwagyeman
Posts: 4655
Joined: Sun May 24, 2015 2:10 pm

Re: OpenMV camera works then quits

Postby kwagyeman » Wed Jun 17, 2020 5:31 pm

Maybe it could be current then. The USB port needs to provide 500 mA of current. This is more than the other Micros you mentioned.
Nyamekye,
tomkib
Posts: 10
Joined: Sun Jun 14, 2020 9:00 pm

Re: OpenMV camera works then quits

Postby tomkib » Wed Jun 17, 2020 7:16 pm

Very interesting, could I supply power independently through a pin and ground while maintaining USB? If so what voltage level and pins .
Thanks,
Tom
User avatar
kwagyeman
Posts: 4655
Joined: Sun May 24, 2015 2:10 pm

Re: OpenMV camera works then quits

Postby kwagyeman » Wed Jun 17, 2020 7:37 pm

6V to VIN and GND to GND. As written on the back of the board and on our documentation...
Nyamekye,
tomkib
Posts: 10
Joined: Sun Jun 14, 2020 9:00 pm

Re: OpenMV camera works then quits

Postby tomkib » Mon Jun 22, 2020 5:45 pm

I tired a separate power source , same issue, FYI the unit draws less then 130ma under several different examples, more interesting though, is I purchased and received a new unit from SparkFun and it runs under same conditions flawlessly. I tested it for five hours w/0 a hiccup. What does this say?
I would be willing to ship you the faulty unit if you want so you can take a closer look at it directly.
Regards,
Tom
User avatar
kwagyeman
Posts: 4655
Joined: Sun May 24, 2015 2:10 pm

Re: OpenMV camera works then quits

Postby kwagyeman » Mon Jun 22, 2020 6:06 pm

Mmm, it's probably just damaged. Most likely some type of ESD. Really hard to tell. I don't have tools to really debug it.

The only thing I can think of is to reflash the firmware.
Nyamekye,
tomkib
Posts: 10
Joined: Sun Jun 14, 2020 9:00 pm

Re: OpenMV camera works then quits

Postby tomkib » Mon Jun 22, 2020 7:46 pm

How do I re-flash the part? What are the steps
User avatar
kwagyeman
Posts: 4655
Joined: Sun May 24, 2015 2:10 pm

Re: OpenMV camera works then quits

Postby kwagyeman » Mon Jun 22, 2020 9:48 pm

Just follow the prompts from OpenMV IDE. Click on the firmware version label in the status bar.
Nyamekye,

Return to “Project Discussion”

Who is online

Users browsing this forum: Bing [Bot] and 2 guests