I downloaded the firmware from OpenMV · GitHub for openmv4,and copied the main.py to the disk,The program is running normally.
but to freeze scripts to do the following:
1 Add the boot.py to the libraries folder.
2 Edit the manifest.py in the boards/OPENMV4,adding freeze (“$(OMV_LIB_DIR)/”, “boot.py”) to the manifest.py file
3 generate the firmware image for your OpenMV Cam.
when use diy firmware,I got the error message from uart,“Traceback (most recent call last):
File “boot.py”, line 85, in
RuntimeError: Frame buffer overflow, try reducing the frame size.
OpenMV 5fb041dc9a; MicroPython 7c5ab76686; OPENMV4 with STM32H743,”
How to adjust the Frame buffer of the openmv4 without changing the code from sensor.VGA to sensor.QVGA?
the codes of the boot.py is below:
import sensor, time
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.VGA)
sensor.skip_frames(time=200)
clock = time.clock()
def find_light_spots(img):
blobs = img.find_blobs([(200, 255)],
area_threshold=20,
merge=True,
margin=2
)
lastBlobs =
for blob in blobs:
if (blob.area() < 400):
if blob.roundness() > 0.4 and blob.density() > 0.5:
lastBlobs.append(blob)
detected =
if len(lastBlobs) >= 1:
lastBlobs.sort(key=lambda b: b.area(), reverse=True)
detected = [(b.cx(), b.cy()) for b in lastBlobs[:min(2, len(lastBlobs))]]
return detected
def show_debug_info(img, spots):
img.draw_string(5, 5, f"blob Num {len(spots)}“, color=255, scale=2)
if len(spots) == 0:
return
colors = [255, 200]
for i, (u, v) in enumerate(spots):
img.draw_circle(int(u), int(v), 6, color=colors[i])
img.draw_string(int(u)+5, int(v)-20, f"P{i}”, color=255)
img.draw_string(5, 20+15i, f"P{i}: ({spots[i][0]}, {spots[i][1]})“, color=200, scale=fontScale)
try:
while True:
img = sensor.snapshot()
spots = find_light_spots(img)
if debug:
show_debug_info(img, spots)
except KeyboardInterrupt:
print(“\nsystem is stopped”)