openmv平方和平方根的函数是哪个?
Z
z5l4
@z5l4
0
Reputation
67
Posts
1181
Profile views
0
Followers
0
Following
Posts made by z5l4
-
线段识别问题:在图像上画一条直线之后识别这条直线,设置阈值为什么没有作用?
thresholds = (35, 79) sensor.reset() sensor.set_pixformat(sensor.GRAYSCALE) sensor.set_framesize(sensor.VGA) 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(True): i=0 # 定义变量i,色块个数 thresholds = (35, 79)#第一次查找阈值 clock.tick() img = sensor.snapshot() for blob in img.find_blobs([thresholds],roi = [120,62,359,300], pixels_threshold=300, area_threshold=100, merge=True):#pixels像素个数阈值,area返回色块边框面积阈值(w * h),merge=True多种颜色时显示一个框框 img.draw_rectangle(120,62, 359, 300, color=127)# 在图像上绘制ROI区域 # 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)# 返回的角列表之间绘制线边 img.draw_line(blob.major_axis_line(), color=153)# 返回blob的主轴(这条线穿过最小面积矩形的最长边)的行元组(x1, y1, x2, y2),可以使用 image.draw_line() 来绘制它。 #img.draw_line(blob.minor_axis_line(), color=0)#返回blob的次轴(这条线穿过最小面积矩形的最短边)的行元组(x1, y1, x2, y2),可以使用 image.draw_line() 来绘制它。 print('I长比 %s'%blob.elongation) # These values are stable all the time. #img.draw_rectangle(blob.rect(), color=200)# 在图像上绘制一个矩形。 您可以单独传递x,y,w,h或作为元组(x,y,w,h)传递。 #img.draw_cross(blob.cx(), blob.cy(), color=227)# 在图像上绘制一个十字 # Note - the blob rotation is unique to 0-180 only. #img.draw_keypoints([(blob.cx(), blob.cy(), int(math.degrees(blob.rotation())))], size=40, color=1) #绘制圆,size 控制特征点的大小,将 fill 设置为True以填充特征点, #print(blob.cx())#逐个打印色块中心坐标 #print(blob.cy())# #print('框高%s'%blob.h())#打印刀头高度 #在特定roi找到坡口中心位置 shang =0 # blob.x() blob.y() 宽blob.w() 高blob.h() xia = 0 zuo = 0 you = 0 shang = blob.x()-5 zuo = blob.y()-5 xia = blob.h()+5+5 you = blob.w()+5+5 #print('框xia %s'%xia) #print('框shang %s'%shang) #print('框X %s'%blob.x()) #print('框y %s'%blob.y()) k=0 # 定义变量k thresholds = (0, 39)# 第二次筛选阈值 i——cx = blob.cx() i——cy = blob.cy() for blob in img.find_blobs([thresholds],roi = [shang,zuo,you,xia], pixels_threshold=75, area_threshold=10, merge=True):#pixels像素个数阈值,area返回色块边框面积阈值(w * h),merge=True多种颜色时显示一个框框 #img.draw_rectangle(shang,zuo,you,xia, color=15) # 在图像上绘制第二次ROI区域 #if blob.elongation() > 0.5:#越像圆,这个值越小,越不像圆,这个值越大。 #img.draw_edges(blob.min_corners(), color=255)# 返回的角列表之间绘制线边 #img.draw_line(blob.major_axis_line(), color=233)# 返回blob的主轴(这条线穿过最小面积矩形的最长边)的行元组(x1, y1, x2, y2),可以使用 image.draw_line() 来绘制它。 #img.draw_rectangle(blob.rect(), color=227)# 在图像上绘制一个矩形。 您可以单独传递x,y,w,h或作为元组(x,y,w,h)传递。 #img.draw_cross(blob.cx(), blob.cy(), color=227)# 在图像上绘制一个十字 k=k+1 k——cx = blob.cx() k——cy = blob.cy() i=i+1 # 每个色块加1 #print('k数量 %s'%k) # k色块个数 #过滤掉距离近的 #在坡口中心至刀头中心画一条直线 img.draw_line((k——cx, k——cy, i——cx, i——cy))# 画白线 #img.draw_line((80, 50, 100, 100), color=(255,0,0))# 画红线 #确定线的朝向/角度 thresholds = (200, 255) # 第三次筛选阈值 #img = sensor.snapshot() j = 0 # 定义线段数量 #if enable_lens_corr: img.lens_corr(1.8) # 镜头畸变矫正 for l in img.find_line_segments( roi = [120,62,359,300], merge_distance=-5, max_theta_difference=-5):#`threshold`控制从霍夫变换中监测到的直线。只返回大于或等于阈值的直线 img.draw_line(l.line(), color=200) #img.draw_line(x0, y0, x1, y1[, color[, thickness=1]]) j += 1 #print('打印l %s'%l) print('线段数量 %s'%j) ```