def main():
global Bd_num
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.VGA)
print("Initial exposure == %d" % sensor.get_exposure_us())
print("db == %d" % sensor.get_gain_db())
sensor.skip_frames(time = 500)
sensor.set_auto_gain(False )
sensor.set_auto_whitebal(False)
sensor.set_auto_exposure(False,exposure_us=2000)
# sensor.set_hmirror(True)
# sensor.set_vflip(True)
sensor.skip_frames(time = 2000)
clock = time.clock() # Create a clock object to track the FPS.
uart2 = pyb.UART(3)
uart2.init(115200, bits=8, parity=None, stop=1,read_buf_len=500)
while(True):
clock.tick() # Update the FPS clock.
img = sensor.snapshot()
print("Initial exposure == %d" % sensor.get_exposure_us())
print("db == %d" % sensor.get_gain_db())
print(clock.fps(),sensor.get_rgb_gain_db())
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):
img.draw_circle(c.x(), c.y(), c.r(), color = (255, 0, 0))
print(c)你得把完整的,可以直接运行出错的代码放上来。
from pyb import UART
import sensor, image, time,pyb,struct
import json
import cpufreq
EXPOSURE_TIME_SCALE = 1.0
def main():
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.VGA)
print("Initial exposure == %d" % sensor.get_exposure_us())
print("db == %d" % sensor.get_gain_db())
sensor.skip_frames(time = 500)
sensor.set_auto_gain(False)
sensor.set_auto_whitebal(False)
sensor.set_auto_exposure(False,exposure_us=2000)
sensor.skip_frames(time = 2000)#跳过多少毫秒的帧
clock = time.clock() # Create a clock object to track the FPS.
uart2 = pyb.UART(3)
uart2.init(115200, bits=8, parity=None, stop=1,read_buf_len=500)
while(True):
clock.tick() # Update the FPS clock.
img = sensor.snapshot()
print("Initial exposure == %d" % sensor.get_exposure_us())
print("db == %d" % sensor.get_gain_db())
print(clock.fps(),sensor.get_rgb_gain_db())
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):
img.draw_circle(c.x(), c.y(), c.r(), color = (255, 0, 0))
print(c)
main()OpenMV4 H7,find_circles不能用vga图像,因为内存太小了。
要么减小分辨率,要么换OpenMV4 H7 Plus。
@kidswong999 请问用findcircles()函数是不是需要知道圆大概占多少像素?
https://book.openmv.cc/example/09-Feature-Detection/find-circles.html
r_min, r_max可以筛选圆的尺寸。