• 免费好用的星瞳AI云服务上线!简单标注,云端训练,支持OpenMV H7和OpenMV H7 Plus。可以替代edge impulse。 https://forum.singtown.com/topic/9519
  • 我们只解决官方正版的OpenMV的问题(STM32),其他的分支有很多兼容问题,我们无法解决。
  • 如果有产品硬件故障问题,比如无法开机,论坛很难解决。可以直接找售后维修
  • 发帖子之前,请确认看过所有的视频教程,https://singtown.com/learn/ 和所有的上手教程http://book.openmv.cc/
  • 每一个新的提问,单独发一个新帖子
  • 帖子需要目的,你要做什么?
  • 如果涉及代码,需要报错提示全部代码文本,请注意不要贴代码图片
  • 必看:玩转星瞳论坛了解一下图片上传,代码格式等问题。
  • 请问 用openmv如何判断色卡的颜色,并找出相对应颜色的小球?(小白不懂,求大佬帮忙解答一下啊) 谢谢啦!



    • ☹



    • https://book.openmv.cc/image/statistics.html

      使用统计信息可以获得颜色的阈值,然后就可以调用find_blobs了



    • 好的谢谢!我试试看呜呜呜,不懂可以再问问你吗



    • @kidswong99

      import sensor, image, time
      
      sensor.reset()                  
      sensor.set_pixformat(sensor.RGB565) 
      sensor.set_framesize(sensor.QVGA)   
      sensor.skip_frames(time = 10)    
      sensor.set_auto_whitebal(False)
      sensor.set_auto_gain(False)
      clock = time.clock()                、
      ROI=(0,0,80,80)
      while(True):
          clock.tick()                    
          img = sensor.snapshot()        
          statistics=img.get_statistics(roi=ROI)
          color_l=statistics.l_mode()
          color_a=statistics.a_mode()
          color_b=statistics.b_mode()
          print(color_l,color_a,color_b)
          img.draw_rectangle(ROI)                                 
          pyb.delay(2000)
          img = sensor.snapshot().lens_corr(1.8)
          for c in img.find_circles(threshold = 3500, x_margin = 10, y_margin = 10, r_margin = 10, r_min = 2, r_max = 100, r_step = 2):
              area = (c.x()-c.r(), c.y()-c.r(), 2*c.r(), 2*c.r())
             statistics = img.get_statistics(roi=area)#像素颜色统计
              print(statistics)
             
              if 20<statistics.l_mode()<100 and 15<statistics.a_mode()<127 and 15<statistics.b_mode()<12:#if the circle is red
                  img.draw_circle(c.x(), c.y(), c.r(), color = (255, 0, 0))#识别到的红色圆形用红色的圆框出来
             if 30<statistics.l_mode()<100 and -64<statistics.a_mode()<-8 and -32<statistics.b_mode()<32:#if the corcle is green
                  img.draw_circle(c.x(),c.y(),c.r(),color=(0,255,0))
             if 0<statistics.l_mode()<15 and 0<statistics.a_mode()<40 and -80<statistics.b_mode()<-20:#if the circle is blue
                  img.draw_circle(c.x(),c.y(),c.r(),color=(0,0,255))
              else:
                  img.draw_rectangle(area, color = (255, 255, 255))
                  #将非红色的圆用白色的矩形框出来
          print("FPS %f" % clock.fps())