TinyCamML / Boron-and-OpenMV

This repo is continued progress between Boron and OpenMV as a self contained device that can successfully monitoring flooding on roadways.
MIT License
0 stars 0 forks source link

TooDark as an option (not just flood/noFlood #41

Closed ebgoldstein closed 1 month ago

ebgoldstein commented 2 months ago

psuedocode to do this would be:


# Set the threshold for detecting dark images
brightness_threshold = 10  # Adjust this value as needed

while True:
    img = sensor.snapshot()

    # Calculate the average brightness of the image
    avg_brightness = img.get_statistics().mean()

    # Check if the image is too dark
    if avg_brightness > brightness_threshold:
        # TF image and send Flood or NoFlood
    else:
        #send 'tooDark to Boron
ebgoldstein commented 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?

ebgoldstein commented 1 month ago

i committed the change, via https://github.com/TinyCamML/Boron-and-OpenMV/commit/e52709d024e355e2a98bf9cb9b583711de385b0d