赞
踩
视频教程7 - LCD显示屏的使用:OpenMV使用LCD显示屏 | 星瞳科技
在IDE中运行下面的代码:
此代码适用于4.5.1至最新的固件版本。
- # LCD显示例程
- #
- # 注意:要运行这个例子,你需要一个用于OpenMV的LCD扩展板。
- #
- # LCD扩展板允许您在运行时查看您的OpenMV Cam的帧缓冲区。
- #
- # 此代码适用于4.5.1至最新的固件版本。
-
- import sensor
- import display
-
- sensor.reset() # 初始化sensor
- sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE
- sensor.set_framesize(sensor.QQVGA2) # 128x160大小的特定液晶屏。
- # 初始化lcd屏幕。
- # 注意:如果支持,可以使用 DAC 或 PWM 背光控制器来控制背光强度:
- # lcd = display.SPIDisplay(backlight=display.DACBacklight(channel=2))
- # lcd.backlight(25) # 25% intensity
- # 否则,将使用默认的 GPIO(开on/关off)控制器。
- lcd = display.SPIDisplay()
-
- while True:
- lcd.write(sensor.snapshot()) # 拍照并显示图像。
效果如下图:
以下代码适用于4.4.3及之前的固件版本。
- # LCD显示例程
- #
- # 注意:要运行这个例子,你需要一个用于OpenMV的LCD扩展板。
- #
- # LCD扩展板允许您在运行时查看您的OpenMV Cam的帧缓冲区。
- #
- # 此代码适用于4.4.3及之前的固件版本。
-
- import sensor, image, lcd
-
- sensor.reset() # 初始化sensor
- sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE
- #设置图像色彩格式,有RGB565色彩图和GRAYSCALE灰度图两种
-
- sensor.set_framesize(sensor.QQVGA2) # 128x160大小的特定液晶屏。
- lcd.init() # 初始化lcd屏幕。
-
- while(True):
- lcd.display(sensor.snapshot()) # 拍照并显示图像。
视频教程12 - WIFI无线图传:OpenMV Wi-Fi图传 | 星瞳科技
OpenMV官方扩展板采用ATWINC1500模组,可以传输图像。
- import sensor, image, time, network, usocket, sys, json
-
- SSID ='OPENMV_AP' # Network SSID
- KEY ='1234567890' # Network key (must be 10 chars)
- HOST = '' # Use first available interface
- PORT = 8080 # Arbitrary non-privileged port
-
- green_threshold = ( 0, 80, -70, -10, -0, 30)
-
- # 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: application/json\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.
-
- img = sensor.snapshot()
- blobs = img.find_blobs([green_threshold])
- if blobs:
- for b in blobs:
- img.draw_rectangle(b[0:4]) # rect
- img.draw_cross(b[5], b[6]) # cx, cy
-
- client.send(json.dumps(blobs))
- 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)
与传输图像类似,浏览器输入192.168.1.1:8080
就可以获得json数据
如果想在自己的代码中获得数据,只需要GET 192.168.1.1:8080
就会获得JSON。
例如python:
- import requests
- r = requests.get('192.168.1.1:8080')
- 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)
浏览器输入192.168.1.1:8080,即可查看一张图片。
视频教程2 - 开箱介绍:OpenMV教程02: 开箱 | 星瞳科技
OpenMV的洞洞板可以扩展OpenMV的功能。可以在洞洞板上焊接元器件、传感器或者连线等。
视频教程29 - SD内存卡的使用:OpenMV SD内存卡的使用 | 星瞳科技
那如果我的代码有10万行,内置的flash不够用怎么办?我想保存图片怎么办?
答案是,可以使用SD卡!
那么SD卡怎么用呢?SD卡也是一个文件系统,当上电的时候,如果插入SD卡,那么SD卡的文件系统就会自动取代内置的Flash文件系统,每次上电,就会运行SD卡中的main.py
啦,是不是很直观,很方便。SD卡最大支持2TB的容量。
视频教程2 - 开箱介绍:OpenMV教程02: 开箱 | 星瞳科技
OpenMV的排母是专用的长脚排母,一端为插针,一端为插座。这种长脚排母,方便了OpenMV配件的叠层使用。其他的普通插针则实现不了这种效果。
视频教程2 - 开箱介绍:OpenMV教程02: 开箱 | 星瞳科技
OpenMV的直角固定板,可以将OpenMV竖直固定。
直角片安装:
螺丝直接拧到OpenMV主板上方的安装孔里(螺丝与孔大小贴合的,直接用螺丝刀拧进去就可以), 螺丝与直角片之间加一个白色绝缘垫圈,直角片相当于螺母。
新款直角固定片:
旧款直角固定板:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。