# Single Color RGB565 Blob Tracking Example
#
# This example shows off single color RGB565 tracking using the OpenMV Cam.
import sensor, image, time, math
threshold_index = 0 # 0 for red, 1 for green, 2 for blue
# Color Tracking Thresholds (L Min, L Max, A Min, A Max, B Min, B Max)
# The below thresholds track in general red/green/blue things. You may wish to tune them...
thresholds = [(14, 87, -83, 127, -113, -14)] # generic_red_thresholds
#(30, 100, -64, -8, -32, 32), # generic_green_thresholds
#(0, 30, 0, 64, -128, 0)] # generic_blue_thresholds
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(True):
clock.tick()
img = sensor.snapshot()
for blob in img.find_blobs([thresholds[threshold_index]], pixels_threshold=200, area_threshold=200, merge=True):
# 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())
# 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(blob.cx(),blob.cy())
print(clock.fps())
查找蓝色的颜色,cx,cy打印出来,单颜色查找
原创XGLIYOUQUAN 博主文章分类:单片机 ©著作权
©著作权归作者所有:来自51CTO博客作者XGLIYOUQUAN的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:小车a_p程序i_d
下一篇:编码器改造,得到方向和脉冲
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Python获取颜色RGB值
Python获取颜色RGB值
Python 图像处理 屏幕截图 -
python输入打印出来 python打印出none
1.问题描述 在使用python打印输出验证结果是否符合预期时,有时候会多出一个None。 程序示例:def get_my_info(): print('my name
python输入打印出来 python 开发语言 调用函数 -
java集合怎么打印出来
1. HashSet概述:HashSet实现Set接口,由哈希表(实际上是一个HashMap实例)支持。它不保证set 的迭代顺序;特别是它不保证该顺序恒久不变。此类允许使用null元素。 2. HashSet的实现: 对于HashSet而言,它是基于HashMap实现
java集合怎么打印出来 class java hashmap iterator