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



    • import sensor, image, time, pyb, time
      
      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()
      
      while(True):
          clock.tick()
          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())                  #area为识别到的圆的区域,即圆的外接矩形框
              statistics = img.get_statistics(roi=area)                            #像素颜色统计
              print(statistics)
              #(0,100,0,120,0,120)是红色的阈值,所以当区域内的众数(也就是最多的颜色),范围在这个阈值内,就说明是红色的圆。
              #l_mode(),a_mode(),b_mode()是L通道,A通道,B通道的众数。
              if 0<statistics.l_mode()<100 and 0<statistics.a_mode()<127 and 0<statistics.b_mode()<127:#if the circle is red
                  img.draw_circle(c.x(), c.y(), c.r(), color = (255, 0, 0))        #识别到的红色圆形用红色的圆框出来
              else:
                  img.draw_rectangle(area, color = (255, 255, 255))
                  #将非红色的圆用白色的矩形框出来
          print("FPS %f" % clock.fps())
          statistics=200
          uart.write(str(kpts2))
      
          #200回传到飞控  再n35模式里设置飞机悬停 也就是锁定xyz轴等待几秒运行下图拍照。
      
      
      RED_LED_PIN = 1
      BLUE_LED_PIN = 3
      
      pyb.LED(RED_LED_PIN).on()
      sensor.skip_frames(time = 2000) # 给用户一个时间来准备
      
      pyb.LED(RED_LED_PIN).off()
      pyb.LED(BLUE_LED_PIN).on()
      
      print("You're on camera!")
      img = sensor.snapshot()
      
      img.morph(1, [+2, +1, +0,\
                    +1, +1, -1,\
                    +0, -1, -2]) # 浮雕图像
      
      img.save("1.jpg") # or "example.bmp" (or others)
      
      pyb.LED(BLUE_LED_PIN).off()
      print("Done! Reset the camera to see the saved image.")
      time.sleep_ms(1000)       #延迟多久
      
      


    • 没看懂你具体要做什么。哪个函数循环3次?



    • 就是识别出形状和颜色然后拍照,然后回到识别形状和颜色在拍照。