@kidswong999 运行起来感觉像是两秒一次处理,前一次图片替换到当前画面,去识别白色色块感觉实时性不高
T
the4
@the4
0
声望
16
楼层
775
资料浏览
0
粉丝
0
关注
the4 发布的帖子
-
RE: 帧差法速率问题(缩短帧差处理时间)
还有就是刚刚试了一下结构相似性帧差法例程,这个速率很快,而且参数明显,想问下SSIM算法具体是怎么评估出相似性得分的,这个阈值(MIN_TRIGGER_THRESHOLD )的划分
-
帧差法速率问题(缩短帧差处理时间)
因为实际需求,想要帧差法处理两帧间距变短,例程现在好像是2s(越快越好),然后这个clock,tick()函数虽然备注是处理时间,但是还是不知道怎么修改hhh
-
RE: 多颜色识别的时候,将各颜色矩形框X坐标定义成一个整型,最后输出整型
@kidswong999 代码我把没用的删了,求指导
import sensor, image, time, math from pyb import UART red_threshold=(0, 58, 42, 75, 21, 127) green_threshold=(44, 100, -17, -128, 6, 127) blue_threshold=(0, 37, 5, 33, -63, -17) sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QVGA) sensor.skip_frames(time = 2000) sensor.set_auto_gain(False) sensor.set_auto_whitebal(False) clock = time.clock() while(True): clock.tick() img = sensor.snapshot().lens_corr(strength = 1.8, zoom = 1.0) for code in img.find_qrcodes(): print(code) for blob in img.find_blobs([red_threshold], pixels_threshold=100, area_threshold=100): if blob.elongation() > 0.5: img.draw_rectangle(blob.rect()) img.draw_cross(blob.cx(), blob.cy()) a=blob.cx() for blob in img.find_blobs([green_threshold], pixels_threshold=100, area_threshold=100): if blob.elongation() > 0.5: img.draw_rectangle(blob.rect()) img.draw_cross(blob.cx(), blob.cy()) b=blob.cx() for blob in img.find_blobs([blue_threshold], pixels_threshold=100, area_threshold=100): if blob.elongation() > 0.5: img.draw_rectangle(blob.rect()) img.draw_cross(blob.cx(), blob.cy()) c=blob.cx() print("红:",a,"绿:",b,"蓝:",c) uart = UART(3, 19200) while(True): uart.write(code.payload()) maxn=max(a,b,c) minn=min(a,b,c) mn=a+b+c-maxn-minn if maxn == a and minn == b: uart.write("123") elif maxn == a and minn == c: uart.write ("132") elif maxn == b and minn == a: uart.write("231") elif maxn == b and minn == c: uart.write ("213") elif maxn == c and minn == a: uart.write("321") elif maxn == c and minn == b: uart.write ("312") time.sleep(1000)
-
RE: 多颜色识别的时候,将各颜色矩形框X坐标定义成一个整型,最后输出整型
import sensor, image, time, math # 颜色跟踪阈值(L Min, L Max, A Min, A Max, B Min, B Max) # 下面的阈值跟踪一般红色/绿色的东西。你不妨调整他们... red_threshold=(45, 79, 10, 127, -128, 127) # generic_red_thresholds green_threshold=(38, 75, -128, -35, -128, 127) # generic_green_thresholds blue_threshold=(9, 54, -128, 20, -120, 1) # generic_blue_thresholds # 您最多可以传递16个阈值。 # 但是,在颜色阈值开始重叠之前,实际上不可能使用16个阈值对任何场景进行分段。 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() # 只有比“pixel_threshold”多的像素和多于“area_threshold”的区域才被 # 下面的“find_blobs”返回。 如果更改相机分辨率, # 请更改“pixels_threshold”和“area_threshold”。 “merge = True”合并图像中所有重叠的色块。 while(True): clock.tick() img = sensor.snapshot() for code in img.find_qrcodes(): print(code) for blob in img.find_blobs([red_threshold], pixels_threshold=500, area_threshold=200): # These values depend on the blob not being circular - otherwise they will be shaky. if blob.elongation() > 0.5: 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)) # These values are stable all the time. img.draw_rectangle(blob.rect()) img.draw_cross(blob.cx(), blob.cy()) a=blob.cx() # Note - the blob rotation is unique to 0-180 only. img.draw_keypoints([(blob.cx(), blob.cy(), int(math.degrees(blob.rotation())))], size=20) for blob in img.find_blobs([green_threshold], pixels_threshold=500, area_threshold=200): # These values depend on the blob not being circular - otherwise they will be shaky. if blob.elongation() > 0.5: 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)) # These values are stable all the time. img.draw_rectangle(blob.rect()) img.draw_cross(blob.cx(), blob.cy()) b=blob.cx() # Note - the blob rotation is unique to 0-180 only. img.draw_keypoints([(blob.cx(), blob.cy(), int(math.degrees(blob.rotation())))], size=20) for blob in img.find_blobs([blue_threshold], pixels_threshold=500, area_threshold=200): # These values depend on the blob not being circular - otherwise they will be shaky. if blob.elongation() > 0.5: 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)) # These values are stable all the time. img.draw_rectangle(blob.rect()) img.draw_cross(blob.cx(), blob.cy()) c=blob.cx() # Note - the blob rotation is unique to 0-180 only. img.draw_keypoints([(blob.cx(), blob.cy(), int(math.degrees(blob.rotation())))], size=20) print("红:",a,"绿:",b,"蓝:",c) import time from pyb import UART uart = UART(3, 19200) while(True): uart.write(code.payload()) maxn=max(a,b,c) minn=min(a,b,c) mn=a+b+c-maxn-minn if maxn == a and minn == b: uart.write("123") elif maxn == a and minn == c: uart.write ("132") elif maxn == b and minn == a: uart.write("231") elif maxn == b and minn == c: uart.write ("213") elif maxn == c and minn == a: uart.write("321") elif maxn == c and minn == b: uart.write ("312") time.sleep(1000)
新手哈哈,有点菜的代码。
-
RE: 多颜色识别的时候,将各颜色矩形框X坐标定义成一个整型,最后输出整型
就是在做颜色识别排序,我把各种颜色的矩形框中心坐标分别赋值给a,b,c.然后运行程序的时候就会出现,当前摄像头视野里如果没有这几种颜色,他就说我未定义,比如我b赋值的是绿色阈值的块中心X坐标,然后我画面里没有绿色,程序就会报未定义的错。
-
RE: 多颜色识别的时候,将各颜色矩形框X坐标定义成一个整型,最后输出整型
就是运行程序的时候,视野里必须有三种颜色的存在,程序才能正常运行,不然会显示某一个颜色defined.