关于openmv向stm32f1发送数据代码是否存在问题
-
请在这里粘贴代码 ```import sensor, image, time from image import SEARCH_EX, SEARCH_DS from pyb import UART import json thresholds = [(10, 100, -19, 12, -21, 16), (32, 55, 30, 64, 8, 38), (17, 100, -34, 24, -6, 40)] sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QQVGA) sensor.skip_frames(time = 2000) sensor.set_auto_gain(False) sensor.set_auto_whitebal(False) clock = time.clock() uart = UART(3, 115200) uart.init(115200, bits=8, parity=None, stop=1) #def send_data_packet(x, y): # temp = struct.pack("<bbii", #格式为俩个字符俩个整型 # 0xAA, #帧头1 # 0xAE, #帧头2 # int(x), # up sample by 4 #数据1 # int(y)) # up sample by 4 #数据2 # uart.write(temp) templates = ["/13.pgm", "/14.pgm", "/15.pgm"] #保存多个模板 while(True): clock.tick() img = sensor.snapshot() for blob in img.find_blobs(thresholds, pixels_threshold=100, area_threshold=100): #output_str = json.dumps(blob) #img.draw_rectangle(blob,color=(255,0,0)) #img.draw_cross(blob.cx(), blob.cy()) #print(blob.code()) x=blob.cx() y=blob.cy() img = img.to_grayscale() for t in templates: template = image.Image(t) #对每个模板遍历进行模板匹配 r = img.find_template(template, 0.70, step=4, search=SEARCH_EX) #, roi=(10, 0, 60, 60)) if r: FH = bytearray([0xb3,0xb3]) uart.write(FH) img.draw_rectangle(r, color=255) print(blob.code(), t) output_str="[%d,%d]" % (blob.cx(), blob.cy()) data = bytearray([x,y]) uart.write(data) print(output_str) else: print('not found!') #print(clock.fps())
-
https://singtown.com/learn/50235/
用串口调试扩展板,或者其他的ttl转USB模块,用串口助手查看数据。可以判断是否有问题。
-
没有USB串口调试扩展板怎么办?
-
用其他的USB转TTL模块,或者示波器,或者逻辑分析仪,看电平的数据。