Spiegazione della routine 14-WiFi-Shield->mjpeg_streamer_fir

# MJPEG Streaming with FIR
#
# 这个例子展示了如何将MJPEG流式传输到FIREFOX浏览器(IE和Chrome不起作用)。只需输入您的网络SSID和KEY,然后连接到从ifconfig输出的IP地址/端口。
import sensor, image, network, usocket, fir

SSID=''     # Network SSID
KEY=''      # Network key
HOST = ''   # 使用第一个可用的端口
PORT = 8000 # 任意非特权端口

# 重置传感器
sensor.reset()

# 设置传感器的设置
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)

# 初始化热成像传感器
fir.init()

# 初始化wlan模块并连接到网络
print("Trying to connect... (may take a while)...")
wlan = network.WINC()
wlan.connect(SSID, key=KEY, security=wlan.WPA_PSK)

# 我们现在通过DHCP应该有一个有效的IP
print(wlan.ifconfig())

# 创建服务器套接字
s = usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM)

# 绑定和监听
s.bind((HOST, PORT))
s.listen(5)

# 将超时设置为1秒
s.settimeout(1.0)

print ('Waiting for connections..')
client, addr = s.accept()
print ('Connected to ' + addr[0] + ':' + str(addr[1]))

# 从客户端读取请求
data = client.recv(1024)

# 应该在这里解析客户端请求

# 发送多部分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")

# 开始流媒体图像
while (True):
    image = sensor.snapshot()

    # 捕获FIR数据
    #   ta: Ambient temperature 环境温度
    #   ir: Object temperatures (IR array) 物体温度(IR阵列)
    #   to_min: Minimum object temperature 最小物体温度
    #   to_max: Maximum object temperature 最大物体温度
    ta, ir, to_min, to_max = fir.read_ir()

    # 缩放图像并使用framebuffer对其进行融合
    fir.draw_ir(image, ir)

    # 绘制环境温度、最小温度和最大温度。
    image.draw_string(0, 0, "Ta: %0.2f"%ta, color = (0xFF, 0x00, 0x00))
    image.draw_string(0, 8, "To min: %0.2f"%to_min, color = (0xFF, 0x00, 0x00))
    image.draw_string(0, 16, "To max: %0.2f"%to_max, color = (0xFF, 0x00, 0x00))

    cimage = image.compressed(quality=90)
    client.send("\r\n--openmv\r\n" \
                "Content-Type: image/jpeg\r\n"\
                "Content-Length:"+str(cimage.size())+"\r\n\r\n")
    client.send(cimage)

client.close()

Spiegazione ufficiale della funzione del documento cinese di Singtown Technology OpenMV:

Spiegazione ufficiale della funzione del documento cinese di Singtown Technology OpenMV:

Spiegazione ufficiale della funzione del documento cinese di Singtown Technology OpenMV:

results matching ""

    No results matching ""