I'm new with OpenMW and hope, someone could give me some hints to get the most of my Cam M7.
My first project should be the following:
I have a labeling machine. It put product labels on bottles. This works fine.
The machine has an ink-jet printer which should print some character (which always start with CH-B.).
Sometimes the ink-jet printer just doesn't print and I would like to test with the Cam M7 if the text get's printed.
The printer prints black on a white background. I know the position and could set the camera directly to this position.
Every time one label is printed (and transported) I get a signal to pin0, a buzzer is connected to pin2 and a reset-Button is on pin1.
Here is my code:
Code: Select all
import sensor, image, time from pyb import Pin from pyb import LED from image import SEARCH_EX, SEARCH_DS sensor.reset() # Reset and initialize the sensor. sensor.set_contrast(1) sensor.set_gainceiling(16) sensor.set_framesize(sensor.VGA) sensor.set_windowing(((640-160)//2, (480-120)//2, 160, 120)) sensor.set_pixformat(sensor.GRAYSCALE) template = image.Image("/template.pgm") clock = time.clock() # Create a clock object to track the FPS. pinStart = Pin('P0', Pin.IN) pinReset = Pin('P1', Pin.IN) pinBeep = Pin('P2', Pin.OUT_PP, Pin.OUT_PP) pinBeep.value(0) found = 1 err = 0 while(True): clock.tick() img = sensor.snapshot() print(clock.fps()) if err==0: r = img.find_template(template, 0.50, step=4, search=SEARCH_DS) #, roi=(10, 0, 50, 40)) if r: img.draw_rectangle(r) found = 1 if pinStart.value()==1: if found==0: err = 1 pinBeep.value(1) else: found=0 if pinReset.value()==1: green_led.on() err = 0 found = 1 pinBeep.value(0)
What parameter, resolution, threshold could I optimize to get the best results?
Which distance from the camera to the label would you use?
What's the best way to create a template (the camera image is not so sharp and has some noise errors), but creating the text in an image program is not so good because of different bold and line width.
So what's the best way to create a template?
Any help is welcome,