logo

查找圆形图案中心坐标报错

2023-10-24 09:52
H
大力士
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![0_1698112339282_捕获.PNG](https://fcdn.singtown.com/bccd10ae-cfa4-4438-8179-f86bc66a7530.PNG) )
 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)
2023-10-25 18:13
I
网红小智智 星瞳科技

你得把完整的,可以直接运行出错的代码放上来。

2023-10-27 10:42
H
大力士
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()
H
大力士
40469004-bfd7-4008-b88a-62fcb4ba8437.PNG
2023-10-28 19:09
I
网红小智智 星瞳科技

OpenMV4 H7,find_circles不能用vga图像,因为内存太小了。

要么减小分辨率,要么换OpenMV4 H7 Plus。

2023-10-30 11:08
H
大力士

@kidswong999 请问用findcircles()函数是不是需要知道圆大概占多少像素?

2023-10-30 20:48
I
网红小智智 星瞳科技

https://book.openmv.cc/example/09-Feature-Detection/find-circles.html

r_min, r_max可以筛选圆的尺寸。