星瞳实验室APP,快速收到回复
  • 我们只解决官方正版的OpenMV的问题(STM32),其他的分支有很多兼容问题,我们无法解决。
  • 如果有产品硬件故障问题,比如无法开机,论坛很难解决。可以直接找售后维修
  • 发帖子之前,请确认看过所有的视频教程,https://singtown.com/learn/ 和所有的上手教程http://book.openmv.cc/
  • 每一个新的提问,单独发一个新帖子
  • 帖子需要目的,你要做什么?
  • 如果涉及代码,需要报错提示全部代码文本,请注意不要贴代码图片
  • 必看:玩转星瞳论坛了解一下图片上传,代码格式等问题。
  • 调用find_line函数之后,打印返回image.line的对象列表会报错,携带源码和报错图片,help



    • # Single Color RGB565 Blob Tracking Example
      #
      # This example shows off single color RGB565 tracking using the OpenMV Cam.
      
      import sensor, image, time, math
      
      threshold_index = 0 # 0 for red, 1 for green, 2 for blue
      
      # Color Tracking Thresholds (L Min, L Max, A Min, A Max, B Min, B Max)
      # The below thresholds track in general red/green/blue things. You may wish to tune them...
      sb = (8, 21, -36, 9, -11, 17)
      ng=(29, 81, 30, 80, 30, 80)# generic_green_thresholds
      THRESHOLD=(70, 0, -128, 127, -128, 127)             
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QQVGA)
      sensor.skip_frames(time = 2000)
      sensor.set_auto_gain(False) # must be turned off for color tracking
      sensor.set_auto_whitebal(False) # must be turned off for color tracking
      clock = time.clock()
      
      # Only blobs that with more pixels than "pixel_threshold" and more area than "area_threshold" are
      # returned by "find_blobs" below. Change "pixels_threshold" and "area_threshold" if you change the
      # camera resolution. "merge=True" merges all overlapping blobs in the image.
      
      while(True):
          clock.tick()
          img = sensor.snapshot()
          blobsb=img.find_blobs([sb], pixels_threshold=200, area_threshold=200)
          blobng=img.find_blobs([ng], pixels_threshold=200, area_threshold=200)
          if blobsb or blobng:
              for s in blobsb:
                  img.draw_cross(s.cx(), s.cy())
                  #img.draw_rectangle(s.rect())
              for blobn in  blobng:
                  img.draw_cross(blobn.cx(), blobn.cy())
                  #img.draw_rectangle(blobn.rect())
                  img.draw_line(s.cx(), s.cy(),blobn.cx(), blobn.cy(), color = [0, 0, 255])
                  #img.binary([THRESHOLD])
                  line=img.find_line_segments()
                  if (line):
                      rho_err = abs(line.rho())-img.width()/2
                      if line.theta()>90:
                          theta_err = line.theta()-180
                      else:
                          theta_err = line.theta()
                      img.draw_line(line.line(), color = 127)
                      print(line.theta())
      
              # Note - the blob rotation is unique to 0-180 only.
              #img.draw_keypoints([(blob.cx(), blob.cy(), int(math.degrees(blob.rotation())))], size=20)
          
      
      


    • 0_1626012578541_报错.png



    • line=img.find_line_segments()

      这里返回的是数组,应该是

      lines=img.find_line_segments()
      for line in lines:
          pass