OpenCam H7 Plus automatically ejected from Raspberry Pi after a while

I am using OpenCam H7+ to capture image with pyopenmv_multi.
The code for camera is:

try:
	pyopenmv.disconnect(port)
	pyopenmv.init(port, baudrate=921600, timeout=0.050)
except Exception as e:
	print("Exception:\n{}\nChoose a valid port! Exiting...\n".format(e))
	sys.exit(-1)
pyopenmv.set_timeout(port, 1*2)
pyopenmv.stop_script(port)
pyopenmv.enable_fb(port, True)
pyopenmv.exec_script(port, script)

, where the script is:

import sensor, image, time
sensor.reset()                      # Reset and initialize the sensor.
sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.VGA)    # Set frame size to QVGA (320x240)
sensor.skip_frames(time = 2000)     # Wait for settings take effect.
sensor.set_auto_gain(False)
sensor.set_auto_whitebal(False)
sensor.skip_frames(time = 500)
while(True):
    img = sensor.snapshot()         # Take a picture and return the image.

It kept ejecting from Raspberry Pi after a random period of time. Most of the time, I just need to re-plug the camera. However, I have to reboot Raspberry Pi sometimes. Those tricks all work eventually but it is quite annoying and it is unreliable for a long-term run.

I also thought that temperature may be the issue so I make the camera shutdown if it is not used.

def disconnect(port):
        shutdown_script = 'import sensor\nsensor.shutdown(True)'
	pyopenmv.stop_script(port)
	pyopenmv.exec_script(port, shutdown_script)
	pyopenmv.disconnect(port)

However, the problem still persists.

What is the cause of the problem? Is it the USB enumeration of Raspberry Pi? Or OpenCam firmware issue? Or is there anything else?

Hi, I don’t have a way to know what’s wrong. The camera is stable on a PC. I can only think of your power supply not being enough or something and a brown out happening.

1 Like