没有USB串口调试扩展板怎么办?
5
5lv3
@5lv3
0
声望
9
楼层
327
资料浏览
0
粉丝
0
关注
5lv3 发布的帖子
-
关于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())
-
怎么插入多模板匹配(或者特征点检测)然后通过串口发送数据,每次添加东西都会不匹配外部缩进
from pyb import UART import json white_threshold = ( 40, 99, -6, 17, -11, 16) red_threshold = ( 32, 55, 30, 64, 8, 38) self_threshold = ( 60, 78, 20, 47, 10, 45) sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QQVGA) sensor.skip_frames(10) sensor.set_auto_whitebal(False) clock = time.clock() uart = UART(3, 115200) def find_max(blobs): max_size=10 for blob in blobs: if blob.pixels() > max_size: max_blob=blob max_size = blob.pixels() return max_blob while(True): img = sensor.snapshot() blobs = img.find_blobs([white_threshold]) output_str = json.dumps(blobs) if blobs: for b in blobs: img.draw_rectangle(b[0:4]) img.draw_cross(b[5], b[6]) max_blob=find_max(blobs)