Hello, I tried to modify code in basic_frame_differencing.py
by replacing the stored image with previous snapshot. But the
frame buffer window becomes totally black and every pixel in
img becomes (0,0,0).
I’m using cam m4 v2.
import sensor, image, pyb, os, time sensor.reset() # Initialize the camera sensor. sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE sensor.set_framesize(sensor.QVGA) # or sensor.QQVGA (or others) sensor.set_auto_whitebal(False) # Turn off white balance. clock = time.clock() # Tracks FPS. background = sensor.snapshot() while(True): clock.tick() # Track elapsed milliseconds between snapshots(). img = sensor.snapshot() # Take a picture and return the image. img.difference(background)# Replace the image with the "abs(NEW-OLD)" frame difference. print(clock.fps()) # Note: Your OpenMV Cam runs about half as fast while # connected to your computer. The FPS should increase once disconnected.
BTW, I tried basic_frame_differencing.py and advaced_frame_differencing.py with a SD card
saving the background image file. But when it runs to sensor.snapshot().save(“temp/bg.bmp”)
the program would crash. Didn’t find out why.