万用表测量openmv的gnd和 vcc与p5引脚直接连通
-
万用表测量openmv的gnd和vcc直接连通,gnd和p5引脚直接连通,openmv的p5引脚我们代码里面配置的蓝牙串口的RX功能
请在这里粘贴代码4# Edge Impulse - OpenMV Object Detection Exampleimport sensor, image, time, os, tf, math, uos, gc, pybfrom pyb import UART, Pin, LEDuart1 = UART(1, 9600) # P0-Rx, P1-Tx----舵机控制uart3 = UART(3, 38400) # P5-Rx, P4-Tx----蓝牙通讯# openmv 内置led灯red_led = LED(1)green_led = LED(2)blue_led = LED(3)#设置输入引脚,并开启上拉电阻, 控制按钮pin_7 = Pin('P7', Pin.IN, Pin.PULL_UP) # 正转, 输出 0pin_8 = Pin('P8', Pin.IN, Pin.PULL_UP) # 反转, 输出 1pin_9 = Pin('P9', Pin.IN, Pin.PULL_UP) # 数字识别模式#p_in = Pin('P7', Pin.IN, Pin.PULL_UP)#设置p_in为输入引脚,并开启上拉电阻#value = p_in.value() # get value, 0 or 1#读入p_in引脚的值###############################################################################################################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.sensor.set_hmirror(True) #水平方向翻转sensor.set_vflip(True) #垂直方向翻转net = Nonelabels = Nonemin_confidence = 0.5try: # load the model, alloc the model file on the heap if we have at least 64K free after loading net = tf.load("trained.tflite", load_to_fb=uos.stat('trained.tflite')[6] > (gc.mem_free() - (64*1024)))except Exception as e: raise Exception('Failed to load "trained.tflite", did you copy the .tflite and labels.txt file onto the mass-storage device? (' + str(e) + ')')try: labels = [line.rstrip('\n') for line in open("labels.txt")]except Exception as e: raise Exception('Failed to load "labels.txt", did you copy the .tflite and labels.txt file onto the mass-storage device? (' + str(e) + ')')colors = [ # Add more colors if you are detecting more than 7 types of classes at once. (255, 0, 0), ( 0, 255, 0), (255, 255, 0), ( 0, 0, 255), (255, 0, 255), ( 0, 255, 255), (255, 255, 255), (128, 128, 0), (128, 128, 128)]###############################################################################################################count_lists = [0, 0, 0, 0, 0, 0, 0, 0, 0] # 记录每个数出现的次数shots_number = 0 # shots_number 记录拍照的次数k = 1 # k 用于发送1次串口给舵机receive_sign = ['UU',0x05,0x08,0x00,0x01,0x00]clock = time.clock()while(True): clock.tick() value_7 = pin_7.value() value_8 = pin_8.value() value_9 = pin_9.value() if (value_7 == 0): # 正转, 发送 0 red_led.on() pyb.delay(1000) red_led.off() uart3.write("0") elif(value_8 == 0): # 反转, 发送 1 green_led.on() pyb.delay(1000) green_led.off() uart3.write("1") elif(value_9 == 0): # 数字识别模式 blue_led.on() pyb.delay(1000) blue_led.off() running = True while(running): img = sensor.snapshot() shots_number = shots_number + 1 if(k==1): # k 值调整来控制舵机是否动 data = bytearray([0x55, 0x55, 0x05, 0x06, 0x00, 0x01, 0x00]) #驱动云台, 第0组动作,执行1次 uart1.write(data) k=0 for i, detection_list in enumerate(net.detect(img, thresholds=[(math.ceil(min_confidence * 255), 255)])): if (i == 0): continue # background class if (len(detection_list) == 0): continue #取出识别数字 number = int(labels[i]) count_lists[number] = count_lists[number] + 1 if (shots_number%10 == 0): max_index = max(enumerate(count_lists), key=lambda x: x[1])[0] # 取出出现概率最高的数 print(max_index) # max_index 为识别的数字 print() count_lists = [0, 0, 0, 0, 0, 0, 0, 0, 0] if (max_index%2 == 1): # 奇数, 发送0, 正转 uart3.write("0") if (max_index%2 == 0): # 偶数, 发送1, 反转 uart3.write("1") #画面圈出数字 for d in detection_list: [x, y, w, h] = d.rect() center_x = math.floor(x + (w / 2)) center_y = math.floor(y + (h / 2)) # print('x %d\ty %d' % (center_x, center_y)) img.draw_circle((center_x, center_y, 12), color=colors[i], thickness=2) if uart1.any(): a = uart1.read() print(a) if receive_sign == a: running = False value_7 = pin_7.value() if (value_7 == 0): # 点击P7,退出数字识别模式 blue_led.on() pyb.delay(1000) blue_led.off() running = False k=1 # print(clock.fps(), "fps", end="\n\n")
-
硬件坏了,寄回卖家维修。