• OpenMV VSCode 扩展发布了,在插件市场直接搜索OpenMV就可以安装
  • 如果有产品硬件故障问题,比如无法开机,论坛很难解决。可以直接找售后维修
  • 发帖子之前,请确认看过所有的视频教程,https://singtown.com/learn/ 和所有的上手教程http://book.openmv.cc/
  • 每一个新的提问,单独发一个新帖子
  • 帖子需要目的,你要做什么?
  • 如果涉及代码,需要报错提示全部代码文本,请注意不要贴代码图片
  • 必看:玩转星瞳论坛了解一下图片上传,代码格式等问题。
  • 关于OSError:img is not mutable!的报错求助



    • 使用官方例程,我只是加入了lcd.init和lcd.display两句函数,但是学习完颜色阈值后,lcd上并未显示绘制出的矩形

      # Automatic RGB565 Color Tracking Example
      #
      # This example shows off single color automatic RGB565 color tracking using the OpenMV Cam.
      
      import sensor, image, time, lcd
      print("Letting auto algorithms run. Don't put anything in front of the camera!")
      
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QVGA)
      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()
      lcd.init()
      # Capture the color thresholds for whatever was in the center of the image.
      r = [(320//2)-(50//2), (240//2)-(50//2), 50, 50] # 50x50 center of QVGA.
      
      print("Auto algorithms done. Hold the object you want to track in front of the camera in the box.")
      print("MAKE SURE THE COLOR OF THE OBJECT YOU WANT TO TRACK IS FULLY ENCLOSED BY THE BOX!")
      for i in range(60):
          img = sensor.snapshot()
          img.draw_rectangle(r)
      
      print("Learning thresholds...")
      threshold = [50, 50, 0, 0, 0, 0] # Middle L, A, B values.
      for i in range(60):
          img = sensor.snapshot()
          hist = img.get_histogram(roi=r)
          lo = hist.get_percentile(0.01) # Get the CDF of the histogram at the 1% range (ADJUST AS NECESSARY)!
          hi = hist.get_percentile(0.99) # Get the CDF of the histogram at the 99% range (ADJUST AS NECESSARY)!
          # Average in percentile values.
          threshold[0] = (threshold[0] + lo.l_value()) // 2
          threshold[1] = (threshold[1] + hi.l_value()) // 2
          threshold[2] = (threshold[2] + lo.a_value()) // 2
          threshold[3] = (threshold[3] + hi.a_value()) // 2
          threshold[4] = (threshold[4] + lo.b_value()) // 2
          threshold[5] = (threshold[5] + hi.b_value()) // 2
          for blob in img.find_blobs([threshold], pixels_threshold=100, area_threshold=100, merge=True, margin=10):
              img.draw_rectangle(blob.rect())
              img.draw_cross(blob.cx(), blob.cy())
              img.draw_rectangle(r)
      
      print("Thresholds learned...")
      print("Tracking colors...")
      
      while(True):
          clock.tick()
          img = sensor.snapshot()
          for blob in img.find_blobs([threshold], pixels_threshold=100, area_threshold=100, merge=True, margin=10):
              img.draw_rectangle(blob.rect())
              img.draw_cross(blob.cx(), blob.cy())
          lcd.display(sensor.snapshot())
          #print(clock.fps())
      
      

      而且我的LCD大小为240*280,使用QVGA的分辨率LCD显示会有缺失
      当我把图像分辨率设置为VGA并img.set_windowing(240,280)时,image.draw_rectangle又开始报如标题的错误,请问我该如何修改代码?



    • 问题已经解决,将分辨率设为CIF,lcd.display(img)就可以了