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


    • 已封禁

      socket传输的图片效果
      0_1586658813677_nw.jpg

      openmv客户端

      import sensor, image, time, network, usocket, sys
      
      # 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.QVGA)
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_auto_gain(True)
      sensor.set_auto_whitebal(True)
      
      SSID='*******'
      KEY='*******'
      wlan = network.WINC()
      wlan.connect(SSID, key=KEY, security=wlan.WPA_PSK)
      print(wlan.ifconfig())
      
      addr=("******",20000)
      
      # connect to serve
      client = usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM)
      client.connect(addr)
      
      client.settimeout(0)
      
      frame = sensor.snapshot()
      cframe = frame.compressed(quality=35)
      client.send(str(cframe.size()))
      client.send(cframe)
      
      client.close()
      
      

      服务器端

      import base64
      import threading
      from socket import *
      import time
      
      print("Waiting for connection...")
      phserv = socket(AF_INET,SOCK_STREAM)
      phserv.bind(('******', 20000))
      phserv.listen(5)
      car, addr = phserv.accept()
      print("Connected to")
      print(addr)
      
      a=car.recv(4)
      size=int(a.decode())
      time.sleep(1)
      
      fl=open('nw2.jpg','wb')
      while size>0:
              data = car.recv(1024)
              fl.write(data)
              size=size-len(data)
      
      time.sleep(0.02)
      fl.close()
      car.close()