logo

救急,我编了一个识别绿色后驱动电机轴转90度的程序,但不知道哪里出了问题。程序如下,连接图也在下面。

2019-04-03 18:14
G
pan

import sensor, image, time

from pyb import Servo

s1 = Servo(1)

red_threshold = (30, 100, -64, -8, -32, 32)

sensor.reset() # Initialize the camera sensor.

sensor.set_pixformat(sensor.RGB565) # use RGB565.

sensor.set_framesize(sensor.QQVGA) # use QQVGA for speed.

sensor.skip_frames(10) # Let new settings take affect.

sensor.set_auto_whitebal(False) # turn this off.

clock = time.clock() # Tracks FPS.

def find_max(blobs):

max_size=0

for blob in blobs:

if blob[2]*blob[3] > max_size:

max_blob=blob

max_size = blob[2]*blob[3]

return max_blob

while(True):

clock.tick() # Track elapsed milliseconds between snapshots().

img = sensor.snapshot() # Take a picture and return the image.

blobs = img.find_blobs([red_threshold])

if blobs:

max_blob = find_max(blobs)

img.draw_rectangle(max_blob.rect()) # rect

img.draw_cross(max_blob.cx(), max_blob.cy()) # cx, cy

s1.angle(90)

ffa12198-dc25-47d6-9a03-0b9d32e8dff8.jpg
2019-04-04 15:09
I
网红小智智 星瞳科技

什么问题?具体的现象是什么?你要问什么?

帖子需要目的,你要做什么?