对于基数为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)
-
你不用int函数,先把里面的数据打印出来,你看看是啥。肯定不是10进制字符串。