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



    • # MJPEG Streaming AP.
      #
      # This example shows off how to do MJPEG streaming in AccessPoint mode.
      # Chrome, Firefox and MJpegViewer App on Android have been tested.
      # Connect to OPENMV_AP and use this URL: http://192.168.1.1:8080 to view the stream.
      
      import sensor, image, time, network, usocket, sys ,math
      
      SSID ='OPENMV_AP'    # Network SSID
      KEY  ='1234567890'    # Network key (must be 10 chars)
      HOST = ''           # Use first available interface
      PORT = 8080         # Arbitrary non-privileged port
      
      # Color Tracking Th1resholds (Grayscale Min, Grayscale Max)颜色跟踪阈值(最小灰度,最大灰度)
      threshold_list = [(200,255)]
      
      # Set the target temp range here在此处设置目标温度范围
      min_temp_in_celsius = 22.0
      max_temp_in_celsius = 35.0
      
      print("Resetting Lepton...")
      # These settings are applied on reset这些设置在重置时适用
      # Reset sensor
      sensor.reset()
      # Set sensor settings
      
      sensor.ioctl(sensor.IOCTL_LEPTON_SET_MEASUREMENT_MODE, True)
      sensor.ioctl(sensor.IOCTL_LEPTON_SET_MEASUREMENT_RANGE, min_temp_in_celsius, max_temp_in_celsius)
      print("Lepton Res (%dx%d)" % (sensor.ioctl(sensor.IOCTL_LEPTON_GET_WIDTH),
                                    sensor.ioctl(sensor.IOCTL_LEPTON_GET_HEIGHT)))
      print("Radiometry Available: " + ("Yes" if sensor.ioctl(sensor.IOCTL_LEPTON_GET_RADIOMETRY) else "No"))
      
      
      
      sensor.set_contrast(1)
      sensor.set_brightness(1)
      sensor.set_saturation(1)
      sensor.set_gainceiling(16)
      sensor.set_framesize(sensor.QQVGA)
      sensor.set_pixformat(sensor.RGB565)
      
      sensor.skip_frames(time=1000)
      # You can block waiting for client to connect
      #print(wlan.wait_for_sta(10000))
      
      # Init wlan module in AP mode.
      wlan = network.WINC(mode=network.WINC.MODE_AP)
      wlan.start_ap(SSID, key=KEY, security=wlan.WEP, channel=2)
      
      
      def map_g_to_temp(g):
          return ((g * (max_temp_in_celsius - min_temp_in_celsius)) / 255.0) + min_temp_in_celsius
      
      
      def start_streaming(s):
          print ('Waiting for connections..')
          client, addr = s.accept()
          # set client socket timeout to 2s
          client.settimeout(2.0)
          print ('Connected to ' + addr[0] + ':' + str(addr[1]))
      
          # Read request from client
          data = client.recv(1024)
          # Should parse client request here
      
          # Send multipart header
          client.send("HTTP/1.1 200 OK\r\n" \
                      "Server: OpenMV\r\n" \
                      "Content-Type: multipart/x-mixed-replace;boundary=openmv\r\n" \
                      "Cache-Control: no-cache\r\n" \
                      "Pragma: no-cache\r\n\r\n")
      
          # FPS clock
          clock = time.clock()
      
          # Start streaming images
          # NOTE: Disable IDE preview to increase streaming FPS.
      
      
          while (True):
              clock.tick() # Track elapsed milliseconds between snapshots().
              img = sensor.snapshot()
      
              blob_stats = []
              blobs = img.find_blobs(threshold_list,pixels_threshold=100, area_threshold=100,merge=False)
              # Collect stats into a list of tuples将统计信息收集到元组列表中
              for blob in blobs:
                  blob_stats.append((blob.x(), blob.y(), map_g_to_temp(img.get_statistics(thresholds=threshold_list,
                                                                                       roi=blob.rect()).mode())))
                  
              img.to_rainbow(color_palette=sensor.PALETTE_IRONBOW) # color it
          # Draw stuff on the colored image在彩色图像上画东西
              for blob in blobs:
                  img=img.draw_rectangle(blob.rect())
                  img.draw_rectangle(blob.x()+5,blob.y()+5,blob.w()-10,blob.h()-10,color=(0,255,0 ))
                  img.draw_cross(blob.cx(), blob.cy())    
              
              for blob_stat in blob_stats:
                  img.draw_string(blob_stat[0]+7, blob_stat[1]+7, "%.2f C" % blob_stat[2], mono_space=False)
              print("FPS %f - Lepton Temp: %f C" % (clock.fps(), sensor.ioctl(sensor.IOCTL_LEPTON_GET_FPA_TEMPERATURE)))
              cframe = img.compressed(quality=35)
              header = "\r\n--openmv\r\n" \
                           "Content-Type: image/jpeg\r\n"\
                           "Content-Length:"+str(cframe.size())+"\r\n\r\n"
              client.send(header)
              client.send(cframe)
              print(clock.fps())
              
             
      
      
      while (True):
          # Create server socket
          s = usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM)
          try:
              # Bind and listen
              s.bind([HOST, PORT])
              s.listen(5)
      
              # Set server socket timeout
              # NOTE: Due to a WINC FW bug, the server socket must be closed and reopened if
              # the client disconnects. Use a timeout here to close and re-create the socket.
              s.settimeout(3)
              start_streaming(s)
          except OSError as e:
              s.close()
              print("socket error: ", e)
              #sys.print_exception(e)
      
      


    • 直接换上lepton,然后运行Wi-Fi的程序就行。



    • 此回复已被删除!


    • @kidswong999 如果我们需要将处理过的热成像图传输出来,怎么修改代码。比如我们需要在温度高的地方画框标记,然后将标记后的图像通过wifi传出视频流



    • https://book.openmv.cc/example/27-Lepton/lepton_target_temp_hotspot_rgb565_color_tracking.html
      目标温度热点彩色追踪

      运行例子。
      需要自己改一下代码。



    • @kidswong999 我们运行了一下,但是传输出来的是没有经过处理的热成像图,请问怎么可以把经过算法处理的图像传出来,我们运行的是下面的代码

      # MJPEG Streaming AP.
      #
      # This example shows off how to do MJPEG streaming in AccessPoint mode.
      # Chrome, Firefox and MJpegViewer App on Android have been tested.
      # Connect to OPENMV_AP and use this URL: http://192.168.1.1:8080 to view the stream.
      
      import sensor, image, time, network, usocket, sys ,math
      
      SSID ='OPENMV_AP'    # Network SSID
      KEY  ='1234567890'    # Network key (must be 10 chars)
      HOST = ''           # Use first available interface
      PORT = 8080         # Arbitrary non-privileged port
      
      # Color Tracking Th1resholds (Grayscale Min, Grayscale Max)颜色跟踪阈值(最小灰度,最大灰度)
      threshold_list = [(200,255)]
      
      # Set the target temp range here在此处设置目标温度范围
      min_temp_in_celsius = 22.0
      max_temp_in_celsius = 35.0
      
      print("Resetting Lepton...")
      # These settings are applied on reset这些设置在重置时适用
      # Reset sensor
      sensor.reset()
      # Set sensor settings
      
      sensor.ioctl(sensor.IOCTL_LEPTON_SET_MEASUREMENT_MODE, True)
      sensor.ioctl(sensor.IOCTL_LEPTON_SET_MEASUREMENT_RANGE, min_temp_in_celsius, max_temp_in_celsius)
      print("Lepton Res (%dx%d)" % (sensor.ioctl(sensor.IOCTL_LEPTON_GET_WIDTH),
                                    sensor.ioctl(sensor.IOCTL_LEPTON_GET_HEIGHT)))
      print("Radiometry Available: " + ("Yes" if sensor.ioctl(sensor.IOCTL_LEPTON_GET_RADIOMETRY) else "No"))
      
      
      
      sensor.set_contrast(1)
      sensor.set_brightness(1)
      sensor.set_saturation(1)
      sensor.set_gainceiling(16)
      sensor.set_framesize(sensor.QQVGA)
      sensor.set_pixformat(sensor.RGB565)
      
      sensor.skip_frames(time=1000)
      # You can block waiting for client to connect
      #print(wlan.wait_for_sta(10000))
      
      # Init wlan module in AP mode.
      wlan = network.WINC(mode=network.WINC.MODE_AP)
      wlan.start_ap(SSID, key=KEY, security=wlan.WEP, channel=2)
      
      
      def map_g_to_temp(g):
          return ((g * (max_temp_in_celsius - min_temp_in_celsius)) / 255.0) + min_temp_in_celsius
      
      
      def start_streaming(s):
          print ('Waiting for connections..')
          client, addr = s.accept()
          # set client socket timeout to 2s
          client.settimeout(2.0)
          print ('Connected to ' + addr[0] + ':' + str(addr[1]))
      
          # Read request from client
          data = client.recv(1024)
          # Should parse client request here
      
          # Send multipart header
          client.send("HTTP/1.1 200 OK\r\n" \
                      "Server: OpenMV\r\n" \
                      "Content-Type: multipart/x-mixed-replace;boundary=openmv\r\n" \
                      "Cache-Control: no-cache\r\n" \
                      "Pragma: no-cache\r\n\r\n")
      
          # FPS clock
          clock = time.clock()
      
          # Start streaming images
          # NOTE: Disable IDE preview to increase streaming FPS.
      
      
          while (True):
              clock.tick() # Track elapsed milliseconds between snapshots().
              img = sensor.snapshot()
      
              blob_stats = []
              blobs = img.find_blobs(threshold_list,pixels_threshold=100, area_threshold=100,merge=False)
              # Collect stats into a list of tuples将统计信息收集到元组列表中
              for blob in blobs:
                  blob_stats.append((blob.x(), blob.y(), map_g_to_temp(img.get_statistics(thresholds=threshold_list,
                                                                                       roi=blob.rect()).mode())))
                  
              img.to_rainbow(color_palette=sensor.PALETTE_IRONBOW) # color it
          # Draw stuff on the colored image在彩色图像上画东西
              for blob in blobs:
                  img.draw_rectangle(blob.rect())
                  img.draw_rectangle(blob.x()+5,blob.y()+5,blob.w()-10,blob.h()-10,color=(0,255,0 ))
                  img.draw_cross(blob.cx(), blob.cy())    
              
              for blob_stat in blob_stats:
                  img.draw_string(blob_stat[0]+7, blob_stat[1]+7, "%.2f C" % blob_stat[2], mono_space=False)
              print("FPS %f - Lepton Temp: %f C" % (clock.fps(), sensor.ioctl(sensor.IOCTL_LEPTON_GET_FPA_TEMPERATURE)))
              cframe = img.compressed(quality=35)
              header = "\r\n--openmv\r\n" \
                           "Content-Type: image/jpeg\r\n"\
                           "Content-Length:"+str(cframe.size())+"\r\n\r\n"
              client.send(header)
              client.send(cframe)
              
              
             
      
      
      while (True):
          # Create server socket
          s = usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM)
          try:
              # Bind and listen
              s.bind([HOST, PORT])
              s.listen(5)
      
              # Set server socket timeout
              # NOTE: Due to a WINC FW bug, the server socket must be closed and reopened if
              # the client disconnects. Use a timeout here to close and re-create the socket.
              s.settimeout(3)
              start_streaming(s)
          except OSError as e:
              s.close()
              print("socket error: ", e)
              #sys.print_exception(e)
      
      


    • 此回复已被删除!


    • 过几天我测试一下。