@kidswong999 import sensor
import image
import time
import network
import usocket
import sys
import sensor
import image
import time
import network
import usocket
import sys
import math
from pyb import UART
from pyb import LED
enable_lens_corr = True
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
min_degree = 60
max_degree = 120
left_roi = [0,0,160,20]
while(True):
clock.tick()
img = sensor.snapshot()
if enable_lens_corr: img.lens_corr(1.8)
for l in img.find_lines(roi=left_roi, x_stride=4, y_stride=2, threshold=1000, theta_margin=25, rho_margin=25):
if (min_degree <= l.theta()) and (l.theta() <= max_degree):
img.draw_line(l.line(), color = (255, 0, 0))
print(l.theta())
statistics = img.get_statistics(roi=left_roi)
print(statistics)
if 12<statistics.l_mode()<30 and -15<statistics.a_mode()<10 and -6<statistics.b_mode()<14:
img.draw_rectangle(0,0,160,20, color = (255, 255, 255))
print("FPS %f" % clock.fps())
我分别用了线段识别和数据统计,但是这两个是分离的没有统一起来