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



    • 0_155256584024K5C.png



    • 我不知道你这代码是个啥...
      不过你的引号打错了



    • 我想调用另一个程序的一个结果

      # Scan Example
      #
      # This example shows how to scan for networks with the WiFi shield.
      
      import time, network
      
      
      SSID='TP-LINK_6A73' # Network SSID
      KEY='12345678'  # Network key
      
      wlan = network.WINC()
      wlan.connect(SSID, key=KEY, security=wlan.WPA_PSK)
      
      print("\nFirmware version:", wlan.fw_version())
      while (True):
          print(wlan.ifconfig())
          scan_result = wlan.scan()
          for ap in scan_result:
              print("Channel:%d RSSI:%d Auth:%d BSSID:%s SSID:%s"%(ap))
              a=(ap[1])
              b = (ap[4])
              if a>=-60:
      
                    d=print("Channel:%d RSSI:%d Auth:%d BSSID:%s SSID:%s"%(ap))
                    print("信号强度:%d"%a)
                    print ('SSID:%s'%b)
      
                    wlan = network.WINC()
                    wlan.connect(SSID, key=KEY, security=wlan.WPA_PSK)
      
          time.sleep(5000)
      这是第一个程序,想在下面这个程序中调用d,并想让下面这个程序连上这个WiFi
      
      

      import sensor, image, time, network, usocket, sys
      SSID ='206-1' # Network SSID
      KEY ='12345678' # Network key
      HOST ='0.0.0.0' # Use first available interface
      PORT = 8080 # Arbitrary non-privileged port

      Reset sensor

      sensor.reset()
      sensor.set_contrast(1) #设置相机图像的对比度。-3至+3
      sensor.set_brightness(1) #设置相机图像亮度。-3至+3
      sensor.set_saturation(1) #设置相机图像饱和度。 —3至+3
      sensor.set_gainceiling(16) #设置相机图像增益上限 2,4,6,8,16,32,64,128
      sensor.set_framesize(sensor.QQVGA) #设置相机模块的帧大小
      sensor.set_pixformat(sensor.GRAYSCALE)

      Init wlan module and connect to network

      print("Trying to connect... (may take a while)...")
      import sys
      sys.path.append('C:\Users\DELL\Desktop\a.py')
      import a
      a.d()
      wlan = network.WINC()
      wlan.connect(SSID, key=KEY, security=wlan.WPA_PSK)

      We should have a valid IP now via DHCP

      print(wlan.ifconfig())

      Create server socket

      s = usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM)

      Bind and listen

      s.bind([HOST, PORT])
      s.listen(5)

      Set server socket to non-blocking

      s.settimeout(0)

      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().
          frame = sensor.snapshot()
          cframe = frame.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):
      try:
      start_streaming(s)
      except OSError as e:
      print("socket error: ", e)
      #sys.print_exception(e)
      请问具体怎么做

      
      


    • 写在一个程序里。



    • 是不是不支持调用啊



    • 不是你理解的程序调用。
      OpenMV的编程思路是函数,不是程序文件。