我也觉得自己表达得很不好,不好意思,
是那个模板匹配用的NCC算法只能局限于识别到大小与模板相同的图像
假如我的图像区域有这么大
但是我的模板是这个
然后我必须要把摄像头移动到画面只有上面这个模板的时候才能够识别的出来
这样就比较麻烦
所以如果我设置一个大小和这个差不多一样的ROI去识别的话
可否解决这个缺陷
G
Gloria 发布的帖子
-
RE: 关于模板匹配的参数设置问题
-
关于模板匹配的参数设置问题
想问一下假如我先设置的图片像素是QVGA, r然后再设置ROI,那所设的ROI的大小是否能够成为模板匹配的大小, 可能我表达的不是很好,但是我的意思其实是模板匹配那个函数局限比较大,只能匹配和模板大小一样的画面嘛,那设置了ROI之后的那个大小如果跟模板差不多是否能够满足那个要求呢,还有 z这个应该的作用是什么呢
-
RE: 为什么使用找圆程序会出现内存问题
可是为什么这样又可以呢,这个也是QVGA,难道是因为我单独定义了ROI吗
import sensor, image, time sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QVGA) sensor.skip_frames(time = 2000) sensor.set_auto_gain(False) # must be turned off for color tracking sensor.set_auto_whitebal(False) # must be turned off for color tracking clock = time.clock() ROI=(240,160,50,50) threshold_100 = (44, 52, 33, 58, -2, 19) while(True): img = sensor.snapshot() # Take a picture and return the image. for blob_100 in img.find_blobs([threshold_100], roi = ROI, pixels_threshold = 200, area_threshold = 200, merge = True): img.draw_rectangle(blob_100.rect()) img.draw_cross(blob_100.cx(), blob_100.cy()) img.draw_string(blob_100.cx(),blob_100.cy(),"100yuan",color = 0) for c in img.find_circles(roi = ROI, threshold = 2000, x_margin = 10, y_margin = 10, r_margin = 10): img.draw_circle(c.x(), c.y(), c.r(), color = (255, 0, 0)) print(c) img.draw_rectangle(ROI)```
-
RE: 为什么使用找圆程序会出现内存问题
import sensor, image, time threshold_100 = (44, 52, 33, 58, -2, 19) threshold_1 = (39, 59, -13, -2, 7, 23) threshold_5 = (23, 52, 1, 30, -16, 5) threshold_10 = (44, 78, -7, 9, 11, 4) threshold_20 = (31, 49, 9, 30, 3, 13) threshold_50 = (40, 67, -26, -6, -3, 15) sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QVGA) sensor.skip_frames(time = 2000) sensor.set_auto_gain(False) # must be turned off for color tracking sensor.set_auto_whitebal(False) # must be turned off for color tracking clock = time.clock() # Only blobs that with more pixels than "pixel_threshold" and more area than "area_threshold" are # returned by "find_blobs" below. Change "pixels_threshold" and "area_threshold" if you change the # camera resolution. "merge=True" merges all overlapping blobs in the image. while(1): clock.tick() img = sensor.snapshot().lens_corr(1.8) for blob_100 in img.find_blobs([threshold_100], pixels_threshold = 200, area_threshold = 200, merge = True): img.draw_rectangle(blob_100.rect()) img.draw_cross(blob_100.cx(), blob_100.cy()) img.draw_string(blob_100.cx(),blob_100.cy(),"100yuan",color = 0) for blob_20 in img.find_blobs([threshold_20], pixels_theshold = 200, area_threshold = 200, merge = True): img.draw_rectangle(blob_20.rect(),color = (255,0,0)) img.draw_cross(blob_20.cx(), blob_20.cy()) img.draw_string(blob_20.cx(),blob_20.cy(),"20yuan",color = (255,0,0)) for blob_10 in img.find_blobs([threshold_10], pixels_theshold = 200, area_threshold = 200, merge = True): img.draw_rectangle(blob_10.rect(),color = (0,255,0)) img.draw_cross(blob_10.cx(), blob_10.cy()) img.draw_string(blob_10.cx(),blob_10.cy(),"10yuan",color = (0,255,0)) for blob_5 in img.find_blobs([threshold_5], pixels_theshold = 200, area_threshold = 200, merge = True): img.draw_rectangle(blob_5.rect(),color = (0,0,255)) img.draw_cross(blob_5.cx(), blob_5.cy()) img.draw_string(blob_5.cx(),blob_5.cy(),"5yuan",color = (0,0,255)) for blob_1 in img.find_blobs([threshold_1], pixels_theshold = 200, area_threshold = 200, merge = True): img.draw_rectangle(blob_1.rect(),color = 0) img.draw_cross(blob_1.cx(), blob_1.cy()) img.draw_string(blob_1.cx(),blob_1.cy(),"1yuan",color = 255) for blob_50 in img.find_blobs([threshold_50], pixels_theshold = 200, area_threshold = 200, merge = True): img.draw_rectangle(blob_50.rect(),color = (0,100,100)) img.draw_cross(blob_50.cx(), blob_50.cy()) img.draw_string(blob_50.cx(),blob_50.cy(),"50yuan",color = (0,100,255)) for c in img.find_circles(threshold = 2000, x_margin = 10, y_margin = 10, r_margin = 10): img.draw_circle(c.x(), c.y(), c.r(), color = (255, 0, 0)) # print(c) # print(clock.fps()) print("FPS %f" % clock.fps())