怎么写呀不太懂 怎么历遍
F
fd26
@fd26
0
声望
19
楼层
413
资料浏览
0
粉丝
0
关注
fd26 发布的帖子
-
对于基数为101的整数,语法无效
第一个openmv
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! while(True):#抓 6无 1234垃圾分类 7 8起 dat接收的数据 datat发送的数据 if uart.any(): dat = uart.readline().decode().strip() if int(dat)==5: break elif int(dat)==1 or int(dat)==2 or int(dat)==3 or int(dat)==4: while(True): #寻找终点 第二个openmv!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # Edge Impulse - OpenMV Image Classification Example import sensor, image, time, os, tf import pwm from pyb import UART from pyb import Servo from pyb import LED pan_servo=Servo(1) tilt_servo=Servo(2) pan_servo.calibration(500,2500,500) tilt_servo.calibration(500,2500,500) sensor.reset() # Reset and initialize the sensor. sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE) sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA (320x240) sensor.set_windowing((240, 240)) # Set 240x240 window. sensor.skip_frames(time=2000) # Let the camera adjust. uart = UART(3, 115200) dat=0 what=0 number=0 LED(1).on() LED(2).on() LED(3).on() net = "trained.tflite" labels = [line.rstrip('\n') for line in open("labels.txt")] clock = time.clock() while(True): clock.tick() img = sensor.snapshot() if uart.any(): dat = uart.readline().decode().strip() if int(dat)==6: pan_servo.angle(85,300) tilt_servo.angle(120,300) time.sleep(1.5) pwm.pw(3)#爪子 time.sleep(1.5) dat=0 if int(dat)==5: while(True): clock.tick() img = sensor.snapshot() for obj in tf.classify(net, img, min_scale=1.0, scale_mul=0.8, x_overlap=0.5, y_overlap=0.5): #print("**********\nPredictions at [x=%d,y=%d,w=%d,h=%d]" % obj.rect()) img.draw_rectangle(obj.rect()) if obj.output()[0]>=0.7 : #电池 if what!=3: number=0 else : number=number+1 what=3 #红色 elif obj.output()[1]>=0.7 : #瓶子 if what!=1: number=0 else : number=number+1 what=1 #蓝色 elif obj.output()[2]>=0.7 : #杯子 if what!=4: number=0 else : number=number+1 what=4 #黑灰色 elif obj.output()[3]>=0.7 : #没有 if what!=5: number=0 else : number=number+1 what=5 #没有识别到东西 elif obj.output()[4]>=0.7 : #橘子 if what!=2: number=0 else : number=number+1 what=2 #绿色 elif obj.output()[5]>=0.7 : #纸团 if what!=1: number=0 else : number=number+1 what=1 #蓝色 if number>=2: number=0 break #predictions_list = list(zip(labels, obj.output())) ''' for i in range(len(predictions_list)): print("%s = %f" % (predictions_list[i][0], predictions_list[i][1])) print(obj.output()[1]) ''' if what!=0: dat=10 pan_servo.angle(69,500) tilt_servo.angle(148,500) time.sleep(0.7) pwm.pw(9)#爪子 time.sleep(1.5) pan_servo.angle(160,300) tilt_servo.angle(100,300) if int(dat)==10: pan_servo.angle(160,300) tilt_servo.angle(120,300) pwm.pw(9)#爪子 uart.write(str(what)+'\r\n') else: pwm.pw(3)#爪子 time.sleep(1.5) pan_servo.angle(148,300) tilt_servo.angle(80) print(dat) print(what)
-
怎么锁定一个物体,让他检测到别的符合物体仍然锁定先前物体
怎么锁定一个物体,让他检测到别的符合物体仍然锁定先前物体
就是先检测到a小车往a走 快走到了 却将目标转移到了b 怎么让他锁定一个目标
-
怎么查找到一个物体a就追踪过去 中途如果识别到别的物体b 他仍然继续追踪原来的物体a
怎么查找到一个物体a就追踪过去 中途如果识别到别的物体b 他仍然继续追踪原来的物体a
-
RE: 串口 十进制整数的无效语法 和列表索引超出范围
# Blob Detection Example # # This example shows off how to use the find_blobs function to find color # blobs in the image. This example in particular looks for dark green objects. import sensor, image, time import car from pid import PID from pyb import UART # You may need to tweak the above settings for tracking green things... # Select an area in the Framebuffer to copy the color settings. 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. # For color tracking to work really well you should ideally be in a very, very, # very, controlled enviroment where the lighting is constant... green_threshold = (99, 100, 127, 127, 127, 127) size_threshold = 2000 x_pid = PID(p=0.5, i=1, imax=100) h_pid = PID(p=0.05, i=0.1, imax=50) a=0 datx=0 daty=0 uart = UART(3, 115200) 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. #for blob in img.find_blobs(green_threshold,invert=True,merge=True): blobs = img.find_blobs([green_threshold],invert=False,merge=True) if uart.any(): dat = uart.readline().decode().strip().split(',') datx=int(dat[0])#机械臂x daty=int(dat[1])#机械臂y print(datx) print(daty) if blobs: max_blob = find_max(blobs) x_error = max_blob[5]-img.width()/2 h_error = max_blob[2]*max_blob[3]-size_threshold ''' for b in blobs: # Draw a rect around the blob. img.draw_rectangle(b[0:4]) # rect img.draw_cross(b[5], b[6]) # cx, cy ''' img.draw_rectangle(max_blob[0:4]) # rect img.draw_cross(max_blob[5], max_blob[6]) # cx, cy if h_error<-500: if h_error<-1500: a=1 if h_error>-1700: h_output=(abs(h_error))/100-3 #print("h_output",h_output) if x_error>0: car.run((h_output-2)*10-x_error*2,h_output*10) elif x_error<0: car.run(h_output*10,(h_output-2)*10+x_error*2) else: car.run(h_output*10,h_output*10) # print("h_utput",-h_output-x_output) else: if x_error>0: car.run(100-x_error*2,100) elif x_error<0: car.run(100,100+x_error*2) else: car.run(100,100) else: car.run(0,0) time.sleep(0.001) if a==1: car.run(-99,-99) time.sleep(0.1) a=0 if h_error>8000: if x_error>0: car.run(-40,-20) elif x_error<0: car.run(-20,-40) else: car.run(-40,-40) elif h_error<3000: if x_error>0: car.run(20,40) elif x_error<0: car.run(40,20) else: car.run(40,40) else: if x_error>5: car.run(-30,30) elif x_error<-5: car.run(30,-30) else: car.run(50,-50)