We use an OpenMV H7 camera to track LCD defects during production:
At the moment I am using Color tracking + blob to count all segments in the display. Unfortunately, I ran into a problem - different cameras have different images. Because There are many cameras, very long and difficult to calibrate and configure them. The segments on the displays are checked at predetermined positions, the camera is fixed rigidly:
if test_number == '01': test = CheckResult(tests(1, [35 + cal_factor_x, 33 - cal_factor_y, 580, 180], long_delay, thresholds, 'merge_on')) if test == False: return elif test_number == '02' or test_number == '03' or test_number == '04': #2-4 test = CheckResult(tests(1, [(21 + cal_factor_x), (119 - cal_factor_y), 25, 53], long_delay, thresholds_for_T, 'merge_off')) if test == False: return test = CheckResult(tests(2, [(50 + cal_factor_x), (121 - cal_factor_y), 38, 93], long_delay, thresholds, 'merge_off')) if test == False: return test = CheckResult(tests(3, [(101 + cal_factor_x), (121 - cal_factor_y), 42, 99], long_delay, thresholds, 'merge_off')) if test == False: return
Аnd if the next LCD is checked, the image may shift a little, so I entered the calibration coefficients for X and Y:
def calibrate(thres,roi): global cal_factor_x, cal_factor_y clock.tick() img = sensor.snapshot() blobs = img.find_blobs(thres, roi=roi, x_stride=5, y_stride=5, pixels_threshold=10, area_threshold=10, merge=False) img.draw_rectangle(roi) for blob in blobs: img.draw_rectangle(blob.rect(), thickness=3, color=(255,0,0)) cal_factor_x = blob.x() - x_reference cal_factor_y = y_reference - blob.y() print('Coordinates:', str(blob.x()), str(blob.y())) print('Factor X = ' + str(cal_factor_x)) print('Factor Y = ' + str(cal_factor_y)) if len(blobs) == 1: outpackage(send_pass) else: outpackage(send_fail)
But this is not enough if the camera is higher or lower, or another lens and its curvature.
Please tell me how can I get rid of the camera position dependence? How to automatically scale the image and not depend on the curvature of the lens / LCD range? Maybe сolor tracking is not suitable for this task?
And the black frame around the display falls into the thresholds, so I had to use specific areas, I can’t ignore it, maybe you can tell me how.
Thank you advance!