logo

我买的摄像头也出现这个问题 运行hellword 不会 一运行颜色识别的代码就出现

2021-10-04 15:13
4
ionb

回复: [Openmv帧缓冲区颜色突然变化,颜色变得偏红](/topic/4416/openmv帧缓冲区颜色突然变化-颜色变得偏红)

4
ionb

我用我同学的摄像头(同样在淘宝买的) 运行就不会 所以应该是摄像头问题

4
ionb

问客服 客服回答也太慢了吧

2021-10-04 15:31
4
ionb

代码是官网的代码

4
ionb

import sensor, image, time

sensor.reset()

sensor.set_pixformat(sensor.RGB565)

sensor.set_framesize(sensor.QQVGA)

sensor.skip_frames(time = 2000)

sensor.set_auto_gain(False) # must be turned off for color tracking

sensor.set_auto_whitebal(False) # must be turned off for color tracking

clock = time.clock()

while(True):

clock.tick()

img = sensor.snapshot().lens_corr(1.8)

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):

area = (c.x()-c.r(), c.y()-c.r(), 2*c.r(), 2*c.r())

#area为识别到的圆的区域,即圆的外接矩形框

statistics = img.get_statistics(roi=area)#像素颜色统计

print(statistics)

#(0,100,0,120,0,120)是红色的阈值,所以当区域内的众数(也就是最多的颜色),范围在这个阈值内,就说明是红色的圆。

#l_mode(),a_mode(),b_mode()是L通道,A通道,B通道的众数。

if 0<statistics.l_mode()<100 and 0<statistics.a_mode()<127 and 0<statistics.b_mode()<127:#if the circle is red

img.draw_circle(c.x(), c.y(), c.r(), color = (255, 0, 0))#识别到的红色圆形用红色的圆框出来

else:

img.draw_rectangle(area, color = (255, 255, 255))

#将非红色的圆用白色的矩形框出来

print("FPS %f" % clock.fps())

4
ionb

https://book.openmv.cc/image/blob_circle.html

2021-10-07 19:11
I
网红小智智 星瞳科技

@ionb 国庆放假了啊,不上班的。

I
网红小智智 星瞳科技

硬件是什么?固件版本是什么?

具体的图片发一下。