I’d like to be able to do some machine vision calculations on an image … but display the original image afterwards and not the modified image.
For instance, normally, to do edge detection like so:
#inside the while loop and assuming the kernel is defined, etc . . . img = sensor.snapshot() # Take a picture and return the image. img.morph(kernel_size, kernel) img.binary(thresholds) # Erode pixels with less than 2 neighbors using a 3x3 image kernel img.erode(1, threshold = 2)
BUT! This modifies the original image snapshot … and doesn’t allow me to display the detected edges on top of the original image. Is there a way to do this?
I thought of doing something like this:
#inside the while loop ... with the proper settings above . . . img = sensor.snapshot() if snapshot_source else img_reader.next_frame(copy_to_fb=True, loop=True) img_MV = img img_MV.binary(binary_thresholds, invert = False) img_MV.morph(kernel_size, kernel) img_MV.binary(edge_thresholds, invert = False) # Erode pixels with less than 2 neighbors using a 3x3 image kernel img_MV.erode(1, threshold = 2) #and then DISPLAY the img with the img_MV on top of it