r_r = (87,22,20,25) #right half of ROI left_angle = 70 # these values are the angles of the largest line-segment ... with 90degrees right_angle = 110 # being "straight down from the top of the frame". It was found empirically ... #*************************************************************************************************** # Input from Speedy Packer #*************************************************************************************************** # Pull Pin 0 LOW when about to dispense foam # pin0 = Pin('P0', Pin.IN, Pin.PULL_UP) # IO Placeholder ... #*************************************************************************************************** # Recorded Image #*************************************************************************************************** img_reader = None if snapshot_source else image.ImageReader("/FU_IR_33_9V.bin") #*************************************************************************************************** while(True): clock.tick() # if pin0.value() == FALSE : # Do the rest of the loop ... you'll need to indent everything below. img = sensor.snapshot() if snapshot_source else img_reader.next_frame(copy_to_fb=True, loop=True) #img.draw_rectangle(l_r, color = 155 ) #commented out unless needed by user #img.draw_rectangle(r_r, color = 155 ) # histogram of ROI ##hist = img.get_histogram(roi = r) # this is the mean brightness of the ROI and was found to be approximately the "low end of the # brightness" of the IR LEDs as seen through the bag
# Image Reader Example # # USE THIS EXAMPLE WITH A USD CARD! # # This example shows how to use the Image Reader object to replay snapshots of what your # OpenMV Cam saw saved by the Image Writer object for testing machine vision algorithms. import sensor, image, time snapshot_source = False # Set to true once finished to pull data from sensor. sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QQVGA) sensor.skip_frames(time = 2000) clock = time.clock() img_reader = None if snapshot_source else image.ImageReader("/stream.bin") while(True): clock.tick() img = sensor.snapshot() if snapshot_source else img_reader.next_frame(copy_to_fb=True, loop=True) # Do machine vision algorithms on the image here. print(clock.fps())
print("Loading model") person_cascade = image.HaarCascade( "/PeopleCounting/people_counting_cascade.cascade", stages=25) height = None width = None count = 0 direction = 0 isCounted = False i = 1 j = 1 b_boxes = [] vid = image.ImageReader("/PeopleCounting/walking.bin") while (True): clock.tick() #img = image.Image("/PeopleCounting/person.bmp", copy_to_fb = True) img = vid.next_frame(copy_to_fb=True) if not img: print("video end") break height = img.height() width = img.width() line_x1 = width // 2 #0 line_y1 = 0 #height//2