@kidswong999 反倒是扫到多个圆形以后他只会输出1
1qx5 发布的帖子
-
RE: 自动增益为什么有时候会失效
@kidswong999 在 自动增益为什么有时候会失效 中说:
你要把set_auto_gain放到reset下面,否则reset会重置所有的设置。
而且最好放到2s延迟后面。sensor.reset() sensor.set_pixformat(sensor.RGB565) # grayscale is faster sensor.set_framesize(sensor.QQVGA) sensor.skip_frames(time = 2000) sensor.set_auto_gain(False)
-
RE: 自动增益为什么有时候会失效
enable_lens_corr = False # turn on for straighter lines...
import sensor, image, time
sensor.set_auto_gain(False)
sensor.reset()
sensor.set_pixformat(sensor.RGB565) # grayscale is faster
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()min_degree = 0
max_degree = 179while(True):
clock.tick()
img = sensor.snapshot()
if enable_lens_corr: img.lens_corr(1.8) # for 2.8mm lens...for l in img.find_lines(threshold = 1000, theta_margin = 30, rho_margin = 30): if (min_degree <= l.theta()) and (l.theta() <= max_degree): img.draw_line(l.line(), color = (255, 0, 0)) print(l) print("FPS %f" % clock.fps())
-
RE: 为什么霍夫变换检测到的直线不稳定呢
import sensor, image, time
fuc_threshold_01 = (49, 100, 43, 120, -128, 22)
red_threshold_01 = (0, 100, -38, 127, 39, 127)
green_threshold_01 = (62, 75, -100, -18, -4, 127)
vio_threshold_01 = (0, 53, -128, 34, -128, -1)sensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.RGB565) # use RGB565.
sensor.set_framesize(sensor.QQVGA) # use QVGA for quailtiy ,use QQVGA for speed.
sensor.skip_frames(10) # Let new settings take affect.
sensor.set_auto_whitebal(False)
#关闭白平衡。白平衡是默认开启的,在颜色识别中,需要关闭白平衡。
clock = time.clock() # Tracks FPS.
min_degree = 0
max_degree = 179
'''
扩宽roi
'''
def expand_roi(roi):
# set for QQVGA 160120
extra = 5
win_size = (160, 120)
(x, y, width, height) = roi
new_roi = [x-extra, y-extra, width+2extra, height+2*extra]if new_roi[0] < 0: new_roi[0] = 0 if new_roi[1] < 0: new_roi[1] = 0 if new_roi[2] > win_size[0]: new_roi[2] = win_size[0] if new_roi[3] > win_size[1]: new_roi[3] = win_size[1] return tuple(new_roi)
while(True):
clock.tick() # Track elapsed milliseconds between snapshots().
img = sensor.snapshot() # Take a picture and return the image.
# pixels_threshold=100, area_threshold=100
blobs = img.find_blobs([red_threshold_01], area_threshold=150)
blobs2 = img.find_blobs([green_threshold_01], area_threshold=150)
blobs3 = img.find_blobs([fuc_threshold_01], area_threshold=150)
blobs4 = img.find_blobs([vio_threshold_01], area_threshold=150)if blobs3: # print(blobs) for blob in blobs3: #迭代找到的目标颜色区域 is_circle = False max_circle = None max_radius = -1 new_roi = expand_roi(blob.rect()) for l in img.find_lines(threshold =2000, theta_margin = 1, rho_margin =1,roi=new_roi): if (min_degree <= l.theta()) and (l.theta() <= max_degree): img.draw_line(l.line(), color = (255, 255, 0)) # print(l) print(clock.fps())
-
RE: 为什么霍夫变换查找直线检测不到到黄色直线?
@1qx5 enable_lens_corr = False # turn on for straighter lines...
import sensor, image, time
sensor.reset()
sensor.set_pixformat(sensor.RGB565) # grayscale is faster
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()min_degree = 0
max_degree = 179while(True):
clock.tick()
img = sensor.snapshot()
if enable_lens_corr: img.lens_corr(1.8) # for 2.8mm lens...for l in img.find_lines(threshold = 1000, theta_margin = 30, rho_margin = 30): if (min_degree <= l.theta()) and (l.theta() <= max_degree): img.draw_line(l.line(), color = (255, 0, 0)) print("FPS %f" % clock.fps())
-
RE: 经过霍夫变换的直线所得的角度为什么不能直接用数字去减
enable_lens_corr = False # turn on for straighter lines... import sensor, image, time sensor.reset() sensor.set_pixformat(sensor.RGB565) # grayscale is faster sensor.set_framesize(sensor.QQVGA) sensor.skip_frames(time = 2000) clock = time.clock() min_degree = 0 max_degree = 179 while(True): clock.tick() img = sensor.snapshot() if enable_lens_corr: img.lens_corr(1.8) # for 2.8mm lens... for l in img.find_lines(threshold = 1000, theta_margin = 30, rho_margin = 30): if (min_degree <= l.theta()) and (l.theta() <= max_degree): img.draw_line(l.line(), color = (255, 0, 0)) print(l) jdc =0 jdc1 =0 jdc2 =0 lines = img.find_lines() if len(lines) == 3: jd1 = lines[0].theta() jd2 = lines[1].theta() jd3 = lines[2].theta() jdc = jd1 - jd2 jdc1 = jd3 - jd2 jdc2 = jd1 - jd3 print(jdc) print(jdc1) print(jdc2) zj = 90 pj = 180 if jdc > zj: jdc = 180 - jdc print(jdc) print("FPS %f" % clock.fps())