星瞳实验室APP,快速收到回复
  • 我们只解决官方正版的OpenMV的问题(STM32),其他的分支有很多兼容问题,我们无法解决。
  • 如果有产品硬件故障问题,比如无法开机,论坛很难解决。可以直接找售后维修
  • 发帖子之前,请确认看过所有的视频教程,https://singtown.com/learn/ 和所有的上手教程http://book.openmv.cc/
  • 每一个新的提问,单独发一个新帖子
  • 帖子需要目的,你要做什么?
  • 如果涉及代码,需要报错提示全部代码文本,请注意不要贴代码图片
  • 必看:玩转星瞳论坛了解一下图片上传,代码格式等问题。
  • 询问代码代码问题,比如这段代码里面的MAX_HIGH这几个值都是怎么判断大小的?



    • def RecognitionForm(Blobs,img):
          Top = 0
          Botton = 1
          Left = 2
          Right = 3
      
      
          cx = 0
          cy = 1
          cw = 0
          ch = 0
      
      #这几个值根据啥定义的
          MAX_WITH = 25
          MIN_WITH = 1
          MIN_HIGH = 0.000001
          MAX_HIGH = 50
      
      
          FormType = 200
          Loaction0 = 0
          Location1 = 120
          Loaction2 = 0
          Loaction3 = 0
      
      
          global length
          global erweima_flag
      #上方下方左边右边的有效区域
          TopValid = False
          BottonValid = False
          LeftValid = False
          RightValid = False
      #将FindMaxBlobs函数的四个数组中的数据存储
          TopBlob = FindMaxBlobs(Blobs[0])
          BottonBlob = FindMaxBlobs(Blobs[1])
          LeftBlob = FindMaxBlobs(Blobs[2])
          RightBlob = FindMaxBlobs(Blobs[3])
      #上方区域
          if TopBlob:
              if TopBlob.w() < MAX_WITH and TopBlob.h() > MIN_HIGH:
                      BlobLocation[Top][cx] = TopBlob.cx()#检测到下方区域最大黑块的x坐标
                      BlobLocation[Top][cy] = TopBlob.cy()#检测到下方区域最大黑块的y坐标
              else:
                  TopBlob = None
      #下方区域
          if BottonBlob:
              if BottonBlob.w() < MAX_WITH and BottonBlob.h() > MIN_HIGH:
                      BlobLocation[Botton][cx] = BottonBlob.cx()#检测到下方区域最大黑块的x坐标
                      BlobLocation[Botton][cy] = BottonBlob.cy()#检测到下方区域最大黑块的y坐标
              else:
                  BottonBlob = None
      #左边区域
          if LeftBlob:
              if LeftBlob.w() > MIN_WITH and LeftBlob.h() < MAX_HIGH and LeftBlob.h() > MIN_HIGH:
                  BlobLocation[Left][cx] = LeftBlob.cx()
                  BlobLocation[Left][cy] = LeftBlob.cy()
                  BlobLocation[Left][cw] = LeftBlob.w()
                  BlobLocation[Left][ch] = LeftBlob.h()
                  img.draw_rectangle(LeftBlob.rect())
                  #img.draw_cross(BlobLocation[Left][cx],BlobLocation[Left][cy])
              else:
                  LeftBlob = None
      #右边区域
          if RightBlob:
              if RightBlob.w() > MIN_WITH and RightBlob.h() < MAX_HIGH and RightBlob.h() > MIN_HIGH:
                  BlobLocation[Right][cx] = RightBlob.cx()
                  BlobLocation[Right][cy] = RightBlob.cy()
                  BlobLocation[Right][cw] = RightBlob.w()
                  BlobLocation[Right][ch] = RightBlob.h()
                  img.draw_rectangle(RightBlob.rect())
                  #img.draw_cross(BlobLocation[Right][cx],BlobLocation[Right][cy])
              else:
                  RightBlob = None
          if TopBlob:
              TopValid = False
          if BottonBlob:
              BottonValid = False
          if LeftBlob:
              LeftValid = True
          if RightBlob:
              RightValid = True
          # 横线
          if (not TopValid) and (not BottonValid) and LeftValid and RightValid:
              if BlobLocation[Left][cy] - BlobLocation[Right][cy] < 80 and BlobLocation[Left][cy] - BlobLocation[Right][cy] > -80 :
                  Loaction0 = (BlobLocation[Top][cx] + BlobLocation[Botton][cx])//2 #x
                  Location1 = (BlobLocation[Left][cy] + BlobLocation[Right][cy])//2  #Y
                  Loaction2 = (BlobLocation[Left][cw] + BlobLocation[Right][cw])//2 #W
                  Loaction3 = (BlobLocation[Left][ch] + BlobLocation[Right][ch])//2 #H
                  FormType = 0
                  Type = 0
          return FormType,Loaction0,Location1,Loaction2,Loaction3
      


    • 什么意思?这个代码也不是我写的,我也不知道设计思路啊。
      不太清楚你问的是什么?