Closed ebgoldstein closed 1 month ago
@efarq , I'm interested in integrating this in the OpenMV code... so it would be something like this:
# Set the threshold for detecting dark images
brightness_threshold = 10 # Adjust this value as needed
while(True):
#Reinitialize the sensor after sleep
sensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
#TAKE PIC
img = sensor.snapshot()
# Calculate the average brightness of the image
avg_brightness = img.get_statistics().mean()
# Check if the image is too dark. if not, classify
if avg_brightness > brightness_threshold:
TF_objs = net.classify(img)
Flood = TF_objs[0].output()[0]
NoFlood = TF_objs[0].output()[1]
if Flood > NoFlood:
#print('Flood')
uart.write('Flood.')
pyb.delay(1500)
floodstate = "Flood"
else:
#print('No Flood')
uart.write('No Flood.')
pyb.delay(1500)
floodstate = "NoFlood"
else:
#print('Too Dark')
uart.write('Too Dark.')
pyb.delay(1500)
floodstate = "TooDark"
print(floodstate)
would this break the Particle code? if you think its good, do you want me to push changes?
i committed the change, via https://github.com/TinyCamML/Boron-and-OpenMV/commit/e52709d024e355e2a98bf9cb9b583711de385b0d
psuedocode to do this would be: