报错:TypeError: NoneType' object isn't callable
-
目的:设定右半边图像为感兴趣区域,进行颜色识别,判断是否存在与阈值匹配的像素点
问题:采图范围无目标时无事发生,一旦采图范围内进入了与阈值匹配的物体,IDE就会立马报错,如图import sensor, image, time, network, usocket, sys, math, pyb C_thresholds =[(12, 41, 44, 23, 34, -11)] #C线识别的阈值 #T_thresholds =[(16, 54, -10, 28, -29, 2)] #T线识别的阈值 sensor.reset() #相机初始化 #sensor.set_contrast(1) #设置相机图像对比度(-3,+3) #sensor.set_brightness(1) #设置相机图像亮度(-3,+3) #sensor.set_saturation(1) #设置相机图像饱和度(-3,+3) #sensor.set_gainceiling(16) #设置相机图像增益上限(2、4、8、16、32、64、128) sensor.set_pixformat(sensor.RGB565) #设置彩色模式 sensor.set_framesize(sensor.VGA) #设置相机分辨率 sensor.skip_frames(time = 2000) #延时2s sensor.set_auto_gain(False) #关闭相机自动增益 sensor.set_auto_whitebal(False) #关闭相机自动白平衡 right_roi= [320,0,320,480] left_roi = [0,0,320,480] while(True): img = sensor.snapshot() for blob in img.find_blobs(C_thresholds, roi=right_roi, x_stride=2, y_stride=1, invert=False, area_threshold=4, pixels_threshold=4, merge=True, margin=1, threshold_cb=None, merge_cb=None): if blob.pixels() > 10: print("试纸检测成功!") img.draw_edges(blob.min_corners(), color=(255,0,0)) img.draw_line(blob.major_axis_line(), color=(0,255,0)) img.draw_line(blob.minor_axis_line(), color=(0,0,255)) #img.draw_rectangle(blob.rect()) #img.draw_cross(blob.cx(), blob.cy()) #img.draw_keypoints([(blob.cx(), blob.cy(), int(math.degrees(blob.rotation())))], size=20) else: print("未检测到试纸!")
-
for blob in img.find_blobs(C_thresholds, roi=right_roi, x_stride=2, y_stride=1, invert=False, area_threshold=4, pixels_threshold=4, merge=True, margin=1, threshold_cb=None, merge_cb=None):
改为
for blob in img.find_blobs(C_thresholds, roi=right_roi, x_stride=2, y_stride=1, invert=False, area_threshold=4, pixels_threshold=4, merge=True, margin=1):