我将这个程序封装成函数并在下方调用函数但得到的值却一直没变一直是初始值0,我把函数解除后,进行里面的循环得到的值又对的
我能看到的错误是4到9行的sensor设置不应该在死循环里。其他的没看出来什么问题。
图像识别算法的识别扩展
你说的红外传感器,光学传感器,具体是什么?是摄像头sensor?还是简单的PIR或者亮度传感器。
RuntimeError:Frame cpature has timed out 请问这种问题咋解决?是啥原因造成的?
看上去是sensor超时了,看一下摄像头模组和主板的链接是不是稳固。如果不行就寄回维修。
wifi扩展板上的串口通信,配置好串口后,星瞳助手显示乱码,并且只发一次消息。请问是怎么回事?
import sensor, image, time, network, usocket, sys
from pyb import UART
uart = UART(3, 9600)
while(True):
uart.write("123\r\t")
time.sleep_ms(1000)
特征点识别,想让他循环识别的同时不影响摄像头拍摄的画面
import sensor, image, time
import pyb
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
last = pyb.millis()
while(True):
clock.tick()
img = sensor.snapshot()
if pyb.millis() - last > 2000:
last = pyb.millis()
print("match_descriptor every 2s")
##match_descriptor
#print(clock.fps())
OPENMV H7 PLUS 输出方波波形不对
import sensor, image, time
from pyb import Pin, Timer
tim = Timer( 4 ,freq = 500)
tim.channel(2,Timer.PWM,pin=Pin("P8"),pulse_width_percent=50)
while(True):
time.sleep_ms(1000)
保存特征点出现OSError:Failed to write requested bytes!
Keypoints descriptor example.
This example shows how to save a keypoints descriptor to file. Show the camera an object
and then run the script. The script will extract and save a keypoints descriptor and the image.
You can use the keypoints_editor.py util to remove unwanted keypoints.
NOTE: Please reset the camera after running this script to see the new file.
import sensor, time, image
Reset sensor
sensor.reset()
Sensor settings
sensor.set_contrast(3)
sensor.set_gainceiling(16)
sensor.set_framesize(sensor.VGA)
sensor.set_windowing((320, 240))
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.skip_frames(time = 2000)
sensor.set_auto_gain(False, value=100)
FILE_NAME = "alphabet_A2"
img = sensor.snapshot()
NOTE: See the docs for other arguments
NOTE: By default find_keypoints returns multi-scale keypoints extracted from an image pyramid.
A= img.find_keypoints(max_keypoints=150, threshold=10, scale_factor=1.2)
if (A == None):
raise(Exception("Couldn't find any keypoints!"))
image.save_descriptor(A, "/%s.orb"%(FILE_NAME))
img.save("/%s.pgm"%(FILE_NAME))
img.draw_keypoints(A)
sensor.snapshot()
time.sleep(1000)
raise(Exception("Done! Please reset the camera"))
关于错误:RuntimeError: Sensor Timeout!!
sensor.sleep(True)之后,就不能snapshopt()了,我把tick_4里面的sensor.sleep(True)注释掉可能就好了。
PS:你这个代码也写的实在没必要,一秒一秒的定时,根本不需要自己用定时器,http://doc.singtown.com/openmv_zh/openmvcam/quickref.html#id2,直接time.ticks_diff(time.ticks_ms(), start),就行了。其实外部中断也没什么必要,直接while里检查就行了。
比如整个代码只有:
import sensor, image, utime, pyb
from pyb import Pin
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
p8 = pyb.Pin('P8', Pin.IN, Pin.PULL_UP)
while(True):
if p8.value()==0:
start = utime.ticks_ms()
print("sensor active~~~")
sensor.sleep(False)
sensor.snapshot()
print("snapshot")
print("wait 12s")
while utime.ticks_diff(utime.ticks_ms(), start)<12000:
pass
print("sensor sleep~~~")
sensor.sleep(True)
Openmv 移植
想要移植openmv里的程序,可是sensor,image等的实现代码及函数定义未知,是不是这些都是不可查的?
二值化后,如何去除其他杂点,我只要正中间区域,如何获取正中间区域的ROI,如何是的这个区域周围边界圆滑不是锯齿状
import pyb, sensor, image, math
sensor.reset()
sensor.set_framesize(sensor.QVGA)
sensor.set_pixformat(sensor.GRAYSCALE)
low_threshold = (0, 50)
while(True):
for i in range(100):
img = sensor.snapshot()
img.binary([low_threshold])