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



    • 为什么有时候,在IDE里面看到的图像会泛红色呢,这是什么原因呢



    • 你用的是什么代码?

      请运行hello world

      http://book.openmv.cc/example/01-Basics/helloworld.html



    • 不是每次都会出现这种情况,只是偶尔会出现



    • 请提供出现这种现象的具体代码。



    • import sensor, image, time ,math
      from pyb import UART
      import json
      red_threshold   = (100, 38, 9, 51, 47, -82)
      yellow_threshold = (100, 6, -40, -11, -69, 116)
      black_threshold =(0, 25, -31, 26, 25, -44)
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QVGA)
      sensor.skip_frames(50)
      sensor.set_auto_whitebal(False)
      clock = time.clock()
      uart = UART(3, 115200)
      def find_max(blobs):
          max_size=0
          for blob in blobs:
              if blob[2]*blob[3] > max_size:
                  max_blob=blob
                  max_size = blob[2]*blob[3]
          return max_blob
      
      def find_red(blobs):
          max_size = 0
          for blob in blobs:
              if blob[2]*blob[3] > max_size:
                  max_blob=blob
                  max_size = blob[2]*blob[3]
          return max_size
      
      def line_filter_copy(src, dst):
        for i in range(0, len(dst), 1):
            dst[i] = src[i<<1]
      def line_filter_bw(src, dst):
        for i in range(0, len(dst), 1):
            if (src[i<<1] > 200 and src[i<<1] < 255):
                dst[i] = 0xFF
            else:
                dst[i] = 0x00
      
      
      i = 0
      max_number = 0
      
      while(True):
      
          clock.tick()
          lines = 0
          img = sensor.snapshot(line_filter = line_filter_copy)
          black_blobs = img.find_blobs([black_threshold])
          red_blobs = img.find_blobs([red_threshold])
          if black_blobs:
              max_blob=find_max(black_blobs)
              #print('sum :', len(blobs))
              if i == 0:
                  img.draw_rectangle(max_blob.rect())
                  img.draw_cross(max_blob.cx(), max_blob.cy())
              else :
                  pass
      
              bx_x=max_blob.cx()-160
              by_y=120-max_blob.cy()
              x=math.fabs(bx_x)
              y=math.fabs(by_y)
              if 0 <= x < 10 :
                  bx_value = 1
              elif 10 <= x < 100 :
                  bx_value = 2
              else :
                  bx_value = 3
      
              if 0 <= y < 10 :
                  by_value = 1
              elif 10 <= y < 100 :
                  by_value = 2
              else :
                  by_value = 3
      
      
              b_output_str="x%d%d,y%d%d" % (bx_value,bx_x,by_value,by_y)
              #print('you send:',b_output_str)
              #uart.write(b_output_str+'\r\n')
          else:
              print('not found!')
              b_output_str = "0"
              #uart.write(b_output_str+'\r\n')
      
          #img = sensor.snapshot()
          #blobs = img.find_blobs([yellow_threshold])
          if red_blobs:
              max_blob=find_max(red_blobs)
              max_number=find_red(red_blobs)
              #print('sum :', len(blobs))
              if i == 1 :
                  img.draw_rectangle(max_blob.rect())
                  img.draw_cross(max_blob.cx(), max_blob.cy())
              else :
                  pass
      
              x_x=max_blob.cx()-160
              y_y=120-max_blob.cy()
              x=math.fabs(x_x)
              y=math.fabs(y_y)
              if 0 <= x < 10 :
                  x_value = 1
              elif 10 <= x < 100 :
                  x_value = 2
              else :
                  x_value = 3
      
              if 0 <= y < 10 :
                  y_value = 1
              elif 10 <= y < 100 :
                  y_value = 2
              else :
                  y_value = 3
      
              output_str="x%d%d,y%d%d" % (x_value,x_x,y_value,y_y)
              #print('you send:',output_str)
              #uart.write(output_str+'\r\n')
          else:
              #print('not found!')
              output_str = "0"
              #uart.write(output_str+'\r\n')
      
          #print('max_number:',max_number)
      
      
          if max_number > 1250 :
              i = 1
              while(i):
                  clock.tick()
                  lines = 0
                  img = sensor.snapshot(line_filter = line_filter_copy)
                  red_blobs = img.find_blobs([red_threshold])
                  if red_blobs:
                      max_blob=find_max(red_blobs)
                      max_number=find_red(red_blobs)
                      #print('sum :', len(blobs))
                      if i == 1 :
                          img.draw_rectangle(max_blob.rect())
                          img.draw_cross(max_blob.cx(), max_blob.cy())
                      else :
                          pass
      
                      x_x=max_blob.cx()-160
                      y_y=120-max_blob.cy()
                      x=math.fabs(x_x)
                      y=math.fabs(y_y)
                      if 0 <= x < 10 :
                          x_value = 1
                      elif 10 <= x < 100 :
                          x_value = 2
                      else :
                          x_value = 3
      
                      if 0 <= y < 10 :
                          y_value = 1
                      elif 10 <= y < 100 :
                          y_value = 2
                      else :
                          y_value = 3
      
                      output_str="x%d%d,y%d%d" % (x_value,x_x,y_value,y_y)
                      #print('you send:',output_str)
                      #uart.write(output_str+'\r\n')
                  else:
                      #print('not found!')
                      output_str = "0"
                      #uart.write(output_str+'\r\n')
      
      
                  uart.write(output_str+'\r\n')
                  print('you send red:',output_str)
                  if max_number < 100 :
                      i = 0
                  else :
                      i = 1
          else :
              uart.write(b_output_str+'\r\n')
              print('you send black:',b_output_str)
              i = 0
      
          max_number = 0
      
      


    • @有点好奇摄像头 中说:

      sensor.skip_frames(50)

      改成

      sensor.skip_frames(time=2000)
      

      或者更高