导航

    • 登录
    • 搜索
    • 版块
    • 产品
    • 教程
    • 论坛
    • 淘宝
    1. 主页
    2. oyeh
    O
    • 举报资料
    • 资料
    • 关注
    • 粉丝
    • 屏蔽
    • 帖子
    • 楼层
    • 最佳
    • 群组

    oyeh

    @oyeh

    0
    声望
    20
    楼层
    1366
    资料浏览
    0
    粉丝
    0
    关注
    注册时间 最后登录

    oyeh 关注

    oyeh 发布的帖子

    • if t==2zuo.pgm or t==2you.pgm : 她说这个是无效语法
      import time, sensor, image
      from image import SEARCH_EX, SEARCH_DS
      
      
      sensor.reset()
      
      
      sensor.set_contrast(1)
      sensor.set_gainceiling(16)
      
      sensor.set_framesize(sensor.QQVGA)
      
      sensor.set_pixformat(sensor.GRAYSCALE)
      
      
      templates = ["/2zuo.pgm","/2you.pgm","/6zuo.pgm","/6you.pgm"] #保存多个模板
      #加载模板图片
      
      
      sensor.set_vflip(True) #设置图像水平方向的翻转
      sensor.set_hmirror(True) #设置图像垂直方向的翻转
      
      while (True):
      
          img = sensor.snapshot()
          for t in templates:
              template = image.Image(t)
              #对每个模板遍历进行模板匹配
              r = img.find_template(template, 0.60, step=4, search=SEARCH_EX)#,roi=(0, 0, 160, 160))
              if r :
                 if t==2zuo.pgm or t==2you.pgm :
                    templates = ["/2zuo.pgm","/2you.pgm"]
                    
                 if t==6zuo.pgm or t==6you.pgm :
                    templates = ["/6zuo.pgm","/6you.pgm"]
                   while True :
                       img = sensor.snapshot()
                       for t in templates:
                           template = image.Image(t)
                           #对每个模板遍历进行模板匹配
                           r = img.find_template(template, 0.60, step=4, search=SEARCH_EX)#,roi=(0, 0, 160, 160))
                           if r:
                              img.draw_rectangle(r)
                              print(t) #打印模板名字
                              #print(r) #输出识别到的目标的坐标(x,y,w,h)这个高度中间是64,r[0]就是x的坐标
                              if r[0]<64 : 
                                 print("左边")  
                                    
                              if r[0]>64 :
                                 print("右边")
      
      
      
      
      发布在 OpenMV Cam
      O
      oyeh
    • 多模板匹配的例程用不了,保存图片到内存了,出现报错,报错在图片上
      # Template Matching Example - Normalized Cross Correlation (NCC)
      #
      # 这个例子展示了如何使用OpenMV凸轮的NCC功能将小部分图像与图像的各个部分
      # 进行匹配...期望获得极其可控的环境NCC并不是全部有用的。
      #
      # 警告:NCC支持需要重做!到目前为止,这个功能需要做大量的工作才能有用。
      # 这个脚本将重新表明功能的存在,但在目前的状态是不足的。
      
      import time, sensor, image
      from image import SEARCH_EX, SEARCH_DS
      #从imgae模块引入SEARCH_EX和SEARCH_DS。使用from import仅仅引入SEARCH_EX, 
      #SEARCH_DS两个需要的部分,而不把image模块全部引入。
      
      # Reset sensor
      sensor.reset()
      
      # Set sensor settings
      sensor.set_contrast(1)
      sensor.set_gainceiling(16)
      # Max resolution for template matching with SEARCH_EX is QQVGA
      sensor.set_framesize(sensor.QQVGA)
      # You can set windowing to reduce the search image.
      #sensor.set_windowing(((640-80)//2, (480-60)//2, 80, 60))
      sensor.set_pixformat(sensor.GRAYSCALE)
      
      # Load template.
      # Template should be a small (eg. 32x32 pixels) grayscale image.
      templates = ["/5.pgm", "/1.pgm"] #保存多个模板
      #加载模板图片
      
      clock = time.clock()
      
      # Run template matching
      while (True):
          clock.tick()
          img = sensor.snapshot()
      
          # find_template(template, threshold, [roi, step, search])
          # ROI: The region of interest tuple (x, y, w, h).
          # Step: The loop step used (y+=step, x+=step) use a bigger step to make it faster.
          # Search is either image.SEARCH_EX for exhaustive search or image.SEARCH_DS for diamond search
          #
          # Note1: ROI has to be smaller than the image and bigger than the template.
          # Note2: In diamond search, step and ROI are both ignored.
          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))
          #find_template(template, threshold, [roi, step, search]),threshold中
          #的0.7是相似度阈值,roi是进行匹配的区域(左上顶点为(10,0),长80宽60的矩形),
          #注意roi的大小要比模板图片大,比frambuffer小。
          #把匹配到的图像标记出来
              if r:
                  img.draw_rectangle(r)
                  print(t) #打印模板名字
      
          #print(clock.fps())
      
      

      0_1689930943593_屏幕截图 2023-07-21 170734.png

      发布在 OpenMV Cam
      O
      oyeh
    • 巡线小车,怎么判断画面中的直线只有一条的时候才处理

      巡线小车,怎么判断画面中的直线只有一条的时候才处理

      发布在 OpenMV Cam
      O
      oyeh
    • RE: 我不小心接了3.3V供电怎么办,还是和USB一起接的。。。。。。。。。。

      就是我接了3.3V那个引脚供电,而且还插着USB,但是没环,不是不能用3.3V引脚供电吗,他现在还能用,好像没什么异常。。。。怎么办

      发布在 OpenMV Cam
      O
      oyeh
    • 我不小心接了3.3V供电怎么办,还是和USB一起接的。。。。。。。。。。

      我不小心接了3.3V供电怎么办,还是和USB一起接的。。。。。。。。。。

      发布在 OpenMV Cam
      O
      oyeh
    • 串口通信发送负数问题,我发的是负1,但是单片机接收那边是255

      import time, pyb
      from pyb import UART

      uart = UART(3, 9600) #参数1:使用串口3 参数2:波特率是4800
      led1 = pyb.LED(1) #红
      led2 = pyb.LED(2) #绿
      led3 = pyb.LED(3) #蓝
      while(True):
      #串口发送数据
      uart.writechar(-1)#发送数字
      time.sleep(3)

      发布在 OpenMV Cam
      O
      oyeh
    • 识别圆的数量报错xxxxxxxxxxxxxxxx

      0_1685411225470_屏幕截图 2023-05-30 094632.png
      帮我看一下哪里错了

      发布在 OpenMV Cam
      O
      oyeh
    • 识别圆的问题,圆心与圆心连线,夹角

      0_1685285439161_屏幕截图 2023-05-28 225027.png

      如何通过识别下方的圆心,告诉小车下方任意两个圆心之间的连线与小车形成的夹角

      发布在 OpenMV Cam
      O
      oyeh