find_qrcodes例程运行时出错
教程中例程在openmv ide测试
import sensor, image, time
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.VGA)
sensor.set_windowing((240, 240)) # look at center 240x240 pixels of the VGA resolution.
sensor.skip_frames(30)
sensor.set_auto_gain(False) # must turn this off to prevent image washout...
clock = time.clock()
while(True):
clock.tick()
img = sensor.snapshot()
for code in img.find_qrcodes():
print(code)
print(clock.fps())
关于OpenMV分辨率初始化命令的问题?
可以改变分辨率,就是慢,每次改变分辨率,都要有自动对白平衡和曝光时间。
import sensor, image, time
while(True):
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
img = sensor.snapshot()
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QQQVGA)
sensor.skip_frames(time = 2000)
img = sensor.snapshot()
machine vs pyb
请教一下,为啥运行下面这个简单代码会出现这个错误:
TypeError: can't convert 'int' object to str implicitly
不是说 openMV 里 已经 用 machine 替代 pyb 了吗?
代码:
import sensor, image, time
from machine import Pin
p0=Pin(0, Pin.OUT)
扫完码后如何停止扫码并得到扫码获得的那个数值赋值给a,进行下一步操作?
import sensor, image, time
a = code.payload()
red_threshold = ( 0, 100, 13, 127, 4, 63)# 已调整
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
sensor.set_auto_gain(False)
clock = time.clock()
while():
clock.tick()
img = sensor.snapshot()
img.lens_corr(1.8)#畸变矫正
for code in img.find_qrcodes():
img.draw_rectangle(code.rect(), color = (255, 0, 0))
print(code)
if a == '红色':
break
if a == "code.payload":
p7p8p9以外的io口如何输出PWM?直接将Timer里的第一参数改为定时器1会报错
timer1 用不了,因为摄像头采集用了timer1
import sensor, image, time
from pyb import Pin, Timer
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
tim = Timer(2, freq=1000) # Frequency in Hz
ch3 = tim.channel(3, Timer.PWM, pin=Pin("P4"), pulse_width_percent=50)
clock = time.clock()
while(True):
clock.tick()
img = sensor.snapshot()
print(clock.fps())
相同的相机参数,在循环拍摄的模式下,为何每次得到的图像都不相同?
亮度不同,是因为你开了自动曝光和自动增益,关了就行。
sensor.reset() # Reset and initialize the sensor.
sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.SVGA) # Set frame size to QVGA (320x240)
sensor.skip_frames(time = 2000) # Wait for settings take effect.
sensor.set_auto_exposure(False)
sensor.set_auto_gain(False)
请问这个程序采用了自适应阈值巡线(黑线),找不到黑线(屏幕全白)是什么原因
我感觉是RGB模式下结果有问题,可以暂时用灰度图:
import sensor, image, time
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
while(True):
img = sensor.snapshot()
histogram = img.get_histogram()
THRESHOLD = histogram.get_threshold()
print(THRESHOLD)
img.binary([(0, THRESHOLD.value())])
为何调用程序库失败?无法调用pickle库
import sensor, image, time, math,re,network,lcd,
import pickle
from pyb import Servo
我想在程序结束后保存新的变量,查询后发现可以使用pickle 库 ,程序输入后,没有高光,调用失败。 请问如何解决?