wifi模块,传输图片。希望大佬回复
加入了传输图片的程序
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)
为什么关闭了自动曝光,设置了固定曝光时间,但是曝光还是一直在变化
第37行,自动增益你也得关掉。你的代码没关掉。
你运行一下这个代码;
# Template Matching Example - Normalized Cross Correlation (NCC)
#
# This example shows off how to use the NCC feature of your OpenMV Cam to match
# image patches to parts of an image... expect for extremely controlled enviorments
# NCC is not all to useful.
#
# WARNING: NCC supports needs to be reworked! As of right now this feature needs
# a lot of work to be made into somethin useful. This script will reamin to show
# that the functionality exists, but, in its current state is inadequate.
import time, sensor, image
from image import SEARCH_EX, SEARCH_DS
from pyb import UART
import json
#从imgae模块引入SEARCH_EX和SEARCH_DS。使用from import仅仅引入SEARCH_EX,
#SEARCH_DS两个需要的部分,而不把image模块全部引入。
# Reset sensor
sensor.reset()
# Set sensor settings
sensor.set_contrast(1)
sensor.set_gainceiling(16)
# Max resolution for template matching with SEARCH_EX is QQVGA
sensor.set_framesize(sensor.QQVGA)
# You can set windowing to reduce the search image.
#sensor.set_windowing(((640-80)//2, (480-60)//2, 80, 60))
sensor.set_pixformat(sensor.GRAYSCALE)
#加载模板图片
sensor.skip_frames(10) # Let new settings take affect.
sensor.set_auto_whitebal(False) # turn this off.
sensor.set_auto_exposure(False, \
exposure_us = 37945)
sensor.set_auto_gain(False, gain_db_ceiling = 16.0) # Default gain.
clock = time.clock() # Tracks FPS.
while (True):
clock.tick()
img = sensor.snapshot()
print(clock.fps())
请问我h7进行模板匹配出现 Frame capture has timed out,怎么解决?
# Template Matching Example - Normalized Cross Correlation (NCC)
#
# This example shows off how to use the NCC feature of your OpenMV Cam to match
# image patches to parts of an image... expect for extremely controlled enviorments
# NCC is not all to useful.
#
# WARNING: NCC supports needs to be reworked! As of right now this feature needs
# a lot of work to be made into somethin useful. This script will reamin to show
# that the functionality exists, but, in its current state is inadequate.
import time, sensor, image
from image import SEARCH_EX, SEARCH_DS
# Reset sensor
sensor.reset()
# Set sensor settings
sensor.set_contrast(1)
sensor.set_gainceiling(16)
# Max resolution for template matching with SEARCH_EX is QQVGA
sensor.set_framesize(sensor.QVGA)
# You can set windowing to reduce the search image.
#sensor.set_windowing(((640-80)//2, (480-60)//2, 80, 60))
sensor.set_pixformat(sensor.GRAYSCALE)
# Load template.
# Template should be a small (eg. 32x32 pixels) grayscale image.
template = image.Image("/2.pgm")
clock = time.clock()
# Run template matching
while (True):
clock.tick()
img = sensor.snapshot()
# find_template(template, threshold, [roi, step, search])
# ROI: The region of interest tuple (x, y, w, h).
# Step: The loop step used (y+=step, x+=step) use a bigger step to make it faster.
# Search is either image.SEARCH_EX for exhaustive search or image.SEARCH_DS for diamond search
#
# Note1: ROI has to be smaller than the image and bigger than the template.
# Note2: In diamond search, step and ROI are both ignored.
r = img.find_template(template, 0.70, step=4, search=SEARCH_EX) #, roi=(10, 0, 60, 60))
if r:
img.draw_rectangle(r)
print(clock.fps())
wifi图传视频流的例程报错
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_framesize(sensor.QQVGA)
sensor.set_pixformat(sensor.RGB565)
# Init wlan module in AP mode.
wlan = network.WLAN(network.AP_IF)
wlan.config(ssid=SSID, key=KEY, channel=2)
wlan.active(True)
# 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)
sensor.snapshot()
img.save("%s.jpg"%tim)
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)

Memory Error, out of fast Frame Buffer Stack报警问题?
find_circles示例程序
import sensor, image, time
sensor.reset()
sensor.set_pixformat(sensor.RGB565) # grayscale is faster
sensor.set_framesize(sensor.QQVGA)
#将里面的QQVGA改成QVGA就会出现报警
#报警信息:Memory Error, out of fast Frame Buffer Stack。
我的产品是:OpenMV3 R3 OV7725-M7
sensor.skip_frames(time = 2000)
clock = time.clock()
请在这里粘贴代码
为什么定时器和拍照同时运行,程序会卡死?
import sensor, image, time
from pyb import Pin, Timer
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
def tick(timer):
uart.write(uart)
print("111111")
tim = Timer(4, freq=1)
tim.callback(tick)
while (True):
img = sensor.snapshot()
openmv如何读取sd卡里的图片并且显示在缓冲区中,使用image函数,但是一直报错
import sensor, image, time,machine
from pyb import LED
sensor.reset()
sensor.set_vflip(False)
sensor.set_hmirror(False)
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA) # 80x60 (4,800 pixels) - O(N^2) max = 2,3040,000.
#sensor.set_windowing([0,20,80,40])
sensor.skip_frames(time = 2000) # WARNING: If you use QQVGA it may take seconds
clock = time.clock() # to process a frame sometimes.
LED(1).on()
LED(2).on()
LED(3).on()
while(True):
clock.tick()
img=image.Image("test.jpg",copy_to_fb=True)
image.Image(copy_to_fb=True)
为什么霍夫变换查找直线检测不到到黄色直线?
@1qx5 enable_lens_corr = False # turn on for straighter lines...
import sensor, image, time
sensor.reset()
sensor.set_pixformat(sensor.RGB565) # grayscale is faster
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
min_degree = 0
max_degree = 179
while(True):
clock.tick()
img = sensor.snapshot()
if enable_lens_corr: img.lens_corr(1.8) # for 2.8mm lens...
for l in img.find_lines(threshold = 1000, theta_margin = 30, rho_margin = 30):
if (min_degree <= l.theta()) and (l.theta() <= max_degree):
img.draw_line(l.line(), color = (255, 0, 0))
print("FPS %f" % clock.fps())
怎么有效的提高识别圆的帧率,我这儿是fps5左右
import sensor, image, time, pyb
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE) # grayscale is faster
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time = 2000)
#sensor.skip_frames(time = 2000)
clock = time.clock()
while(True):
#time_start1 = pyb.millis()
clock.tick()
img = sensor.snapshot()#.lens_corr(1.8)
time_start = pyb.millis()
for c in img.find_circles(threshold = 3500, x_margin = 10, y_margin = 10,
r_margin = 10,r_min = 2, r_max = 100, r_step = 2):
duration = pyb.elapsed_millis(time_start)
print(duration)
img.draw_circle(c.x(), c.y(), c.r(), color = (255, 0, 0))
print(clock.fps())
可以查找某个函数库属于哪个dll文件吗
单片机上没有dll。所有的程序都编译进固件里。