Hi, this is not easy to do with any elementary methods, you’ll have to build up a complex image processing setup to do this. First, do you have a jig to mount the OpenMV Cam in to look at the part? If so, then can you take pictures using the jig?
yes i have mada jig for mount OpenMV Cam and above two image taken from that.
Our CNN for finding numbers isn’t that great. Needs a better model:
import sensor, image, time, pyb # Replace this image loading with a loop with snapshot... img = image.Image("OK.bmp", copy_to_fb=True) # load image img.binary([(90, 100)], zero=True) img.mean(7, threshold=True, offset=-40, invert=False) img.erode(1, threshold=5) blobs = img.find_blobs([(90, 100)], x_stride=1, y_stride=1) blobs = list(filter(lambda x: x.w() < 10, blobs)) # Find blobs less than 10 pix wide blobs = sorted(blobs, key=lambda x: (x.y() * x.w()) + x.x()) # index from pixel offset gs_img = img.to_grayscale(copy=True) correct = [1, 3, 5, 2, 4, -1] score = 0 for i in range(len(blobs)): b = blobs[i] new_roi = (b.x()-10, b.y()-10, 28, 28) num, conf = gs_img.find_number(roi=new_roi) img.draw_rectangle(new_roi, color=(255, 0, 0), thickness=2) img.draw_string(b.x()-10, b.y()-10, "%d" % num) score += num == correct[i] print(score) img.compress(90) # Force higher quality jpeg sensor.flush() # Send image to PC pyb.delay(1000) # Wait for the image to be displayed
Anyway, if you try out the OK.bmp versus the NG.bmp file you’ll see the score is 2 versus 0. For the CNN to work better the numbers need to be more zoomed in on.
OK.zip (59.4 KB)
Please use the lower resolution images I provided in the attached zip file in the previous post for getting started.
Also, you need to update your firmware. We just released the latest OpenMV IDE for all this stuff. The binary method was improved and was previously not able to handle the arguments passed like in the test script.
openMV ide download link not working…