@kidswong999 我接LCD显示模块也是这样
S
syxh
@syxh
0
声望
17
楼层
760
资料浏览
0
粉丝
0
关注
syxh 发布的帖子
-
IDE中预览时出现黑色条纹轮播
import sensor, image, time sensor.reset() # 初始化sensor sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE #设置图像色彩格式,有RGB565色彩图和GRAYSCALE灰度图两种 sensor.set_framesize(sensor.QQVGA) # or sensor.QVGA (or others) sensor.set_saturation(3) sensor.set_contrast(3) sensor.set_brightness(3) sensor.skip_frames(time = 1000) sensor.set_auto_exposure(False, 4532) sensor.set_auto_gain(False,gain_db=8.95857) sensor.set_auto_whitebal(False,rgb_gain_db=(-4.64378, -6.02073, -3.05939)) sensor.skip_frames(time = 3000) clock = time.clock() while(True): clock.tick() img = sensor.snapshot()#.find_edges(image.EDGE_CANNY,threshold=(70, 100)) '''cs=img.find_circles(threshold = 3000, x_margin = 50, y_margin = 50, r_margin = 10,r_min = 2, r_max = 100, r_step = 2) if cs: for c in cs: img.draw_circle(c.x(), c.y(), c.r(), color = (255, 0, 0)) print(c) else: print("None")''' print(clock.fps())
-
启动后亮度不一致,而且串口打印的白平衡也与设定的不一致
import sensor, image, time,car from pyb import LED from pid import PID sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QQVGA) sensor.set_vflip(True) sensor.set_hmirror(True) sensor.set_auto_gain(False,gain_db=6.02) #sensor.set_auto_whitebal(False,rgb_gain_db=(63.4416, 60.2071, 63.7403))#H7 PLUS sensor.set_auto_whitebal(False,rgb_gain_db=(-5,-6,-3))#H7 '''sensor.set_saturation(3)#饱和度 sensor.set_contrast(3)#对比度 sensor.set_brightness(3)#亮度''' sensor.skip_frames(time = 2000) clock = time.clock() # 跟踪FPS帧率 rho_pid = PID(p=0.6, i=0) theta_pid = PID(p=0.001, i=0) THRESHOLD= (32, 69, -12, 22, -13, 15) BLACK=((100,100),[250,255]) while(True): clock.tick() img = sensor.snapshot().lens_corr(strength = 1.8, zoom = 1.0).mean(2).binary([THRESHOLD]) line = img.get_regression([BLACK[0]],roi=(0,sensor.height()-40,sensor.width(),40),x_stride=2,y_stride=2,pixels_threshold=1,robust = True) if (line): rho_err = abs(line.rho())-img.width()/2 if line.theta()>90: theta_err = line.theta()-180 else: theta_err = line.theta() img.draw_line(line.line(), color = 127) print(rho_err,line.magnitude(),theta_err) #if -40<b_err<40 and -30<t_err<30: rho_output = rho_pid.get_pid(rho_err,1) theta_output = theta_pid.get_pid(theta_err,1) output = rho_output+theta_output car.run(30+output, 30-output) else: car.run(20,-20) pass print(clock.fps(),sensor.get_gain_db())
-
识别矩形时识别对象不稳定,经常框到图像边缘
# Untitled - By: Misaki - 周六 12月 19 2020 import sensor, image, time sensor.reset() sensor.set_pixformat(sensor.GRAYSCALE) #sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QQVGA) sensor.skip_frames(time = 2000) clock = time.clock() def find_max(rects): max_size=0 max_rect=rects for rect in rects: if rect[2]*rect[3] > max_size: max_rect=rects max_size = rect[2]*rect[3] return max_rect def find_max_rects(img): rects=img.find_rects(threshold=12000) for max_rect in find_max(rects): img.draw_rectangle(max_rect.rect(), color = (255, 255, 255)) #img.draw_edges(max_rect.corners(), color = (255, 255, 255)) return max_rect else: return 0 while(True): clock.tick() img = sensor.snapshot().gaussian(1).find_edges(image.EDGE_CANNY,threshold=(50, 90)) print(find_max_rects(img)) '''for c in img.find_circles(threshold = 2500, x_margin =10, y_margin = 10, r_margin = 10,r_min = 50, r_max = 200, r_step = 2): img.draw_circle(c.x(), c.y(), c.r(), color = (255, 255, 255)) print(c) for l in img.find_line_segments(merge_distance = 0, max_theta_diff = 0): img.draw_line(l.line(), color = (255, 0, 0)) print(l)''' print(clock.fps())
-
更新固件后运行旧程序时内存不足
# Untitled - By: Misaki - 周六 12月 19 2020 import sensor, image, time,lcd lcd.init(freq=15000000) sensor.reset() #sensor.set_pixformat(sensor.GRAYSCALE) sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QVGA) sensor.skip_frames(time = 2000) clock = time.clock() while(True): clock.tick() img = sensor.snapshot() lcd.display(img) '''for c in img.find_circles(threshold = 2500, x_margin =10, y_margin = 10, r_margin = 10,r_min = 50, r_max = 200, r_step = 2): img.draw_circle(c.x(), c.y(), c.r(), color = (255, 255, 255)) print(c) for l in img.find_line_segments(merge_distance = 0, max_theta_diff = 0): img.draw_line(l.line(), color = (255, 0, 0)) print(l)''' for r in img.find_rects(threshold=13000): img.draw_rectangle(r.rect(), color = (255, 255, 255)) img.draw_edges(r.corners(), color = (0, 0, 0)) for p in r.corners(): img.draw_circle(p[0], p[1], 5, color = (255, 255, 255)) print(r) print(clock.fps())
-
7 Puls关闭白平衡,IDE显示黑屏
sensor.set_auto_whitebal(False,rgb_gain_db=(-5,-6,-3))
H7运行结果:
H7 Plus运行结果: