• 星瞳实验室APP,快速收到回复。扫描二维码或者点击 https://singtown.com/app/
  • 必看:玩转星瞳论坛了解一下图片上传,代码格式等问题。
  • 每一个新的提问,单独发一个新帖子
  • 描述一定要详细 描述一定要详细 描述一定要详细
  • 请贴出具体的的目的,就是你要做什么。
  • 请贴出具体的代码,与报错提示
  • 代码一定要让别人可以运行的文本,不要贴图片
  • wifi模块,传输图片。希望大佬回复



    • 想实现的功能:先拍一张照片,保存到sd卡里面,然后手机链接wifi模块的热点之后,输入ip地址,可以一直看到那一张照片。希望有技术人员能提供代码参考。



    • 参考传mjpeg视频流的例程

      http://book.openmv.cc/example/14-WiFi-Shield/mjpeg-streamer.html

      去掉while循环,就是仅传一次图片



    • 去掉while,改if吗?



    • 节后上班我回去试一下,header应该也需要改⁄(⁄ ⁄ ⁄ω⁄ ⁄ ⁄)⁄



    • 请问一下,节后是什么时候?我有点赶时间,现在能不能指点一下?



    • @yuan 大佬,我把while改了if,但是连接wifi并不能看到哪一张照片,直接被刷过去了。给你看这个图!![0_1523006546556_F1C58~C~F310RA}WTN9(3N.png



    • 加入了传输图片的程序

      http://book.openmv.cc/shield/wifi.html

      import sensor, image, time, network, usocket, sys
      
      SSID ='OPENMV_AP'    # Network SSID
      KEY  ='1234567890'    # Network key (must be 10 chars)
      HOST = ''           # Use first available interface
      PORT = 8080         # Arbitrary non-privileged port
      
      # Reset sensor
      sensor.reset()
      # Set sensor settings
      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.GRAYSCALE)
      
      # 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)
      
      # You can block waiting for client to connect
      #print(wlan.wait_for_sta(10000))
      
      def response(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: image/jpeg\r\n\r\n")
      
          # FPS clock
          clock = time.clock()
      
          # Start streaming images
          # NOTE: Disable IDE preview to increase streaming FPS.
      
      
          frame = sensor.snapshot()
          cframe = frame.compressed(quality=35)
          client.send(cframe)
          client.close()
      
      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)
              response(s)
          except OSError as e:
              s.close()
              print("socket error: ", e)
              #sys.print_exception(e)
      


    • 谢谢大佬,但是刚刚我用其它方法已经搞定了。