大佬请问为什么二值化之后找线段在正对矩形的时候找的到 歪了就不行
import pyb
from pyb import LED #导入LED
from machine import UART
import sensor, image, time, math, os, tf
uart = UART(1, baudrate=115200)
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QVGA)
sensor.set_auto_exposure(False, 1000)
sensor.__write_reg(0x03,0x04)
sensor.__write_reg(0x04,0x05)
sensor.__write_reg(0xB2,0x40)
sensor.__write_reg(0xB3,0x00)
sensor.__write_reg(0xB4,0x40)
sensor.__write_reg(0xB5,0x00)
sensor.__write_reg(0x03,0x03)
sensor.__write_reg(0x5B,0x60)
sensor.__write_reg(0x03,0x08)
sensor.set_auto_whitebal(False, (0x80,135,0x80))
sensor.set_brightness(500)
sensor.set_auto_gain(False)
sensor.skip_frames(time = 2000)
clock = time.clock()
Large_area=[0,0,320,180]
min_degree = 45
max_degree = 135
i=0
yzb=[0,0]
he=[]
ypj=[]
yjd=[]
lbypj=[]
lbyjd=[]
suibian=[]
red_threshold = (0,150)
def get_pj(point):
point_1 = point[0]
point_2 = point[1]
he = int((point_1+ point_2)/2)
return he
while(True):
img = sensor.snapshot()
img.binary([red_threshold])
#img.draw_rectangle(Large_area, color = (255, 0, 0))
for l in img.find_line_segments(roi=Large_area,merge_distance = 10, max_theta_diff = 10):
#if (min_degree <= l.theta()) and (l.theta() <= max_degree):
img.draw_line(l.line(), color = (255, 0, 0))
#print(l.line())
yzb = [l.y1(),l.y2()]
#yjd= [l.theta()]
ypj = get_pj(yzb)
if(i<5):
lbypj.append(ypj)
#lbyjd.append(yjd)
i=i+1
if (i==5):
#suibian=lbypj
ypjmax=max(lbypj)
juliy=240-ypjmax
img.draw_line([0,ypjmax,320,ypjmax], color = (255, 0, 0))
#zuidixian=suibian.index(max(suibian))
#outjd =lbyjd[zuidixian]
print(juliy)
lbypj=[]
#lbyjd=[]
i=0
无法把图片读入framebuffer,求教
import sensor, image, time
# 仍然需要初始化 sensor
sensor.reset()
# 设置 sensor
sensor.set_contrast(1)
sensor.set_gainceiling(16)
# 设置sensor的 pixel format
sensor.set_framesize(sensor.QQVGA)
sensor.set_pixformat(sensor.GRAYSCALE)
# 导入 image
img = image.Image("/example.bmp", copy_to_fb=True)
# 添加画线的代码
# img.draw_line(...)
# Flush FB
sensor.flush()
# Add a small delay to allow the IDE to read the flushed image.
time.sleep(100)
想做MT9V034的Binning操作,但是配置寄存器没有效果
sensor.__write_reg(0x0D,0x003A)
新买的openmv4plus在rpg565下拍摄的图片发绿发暗
OpenMV4 Plus用的是ov5640的sensor,OpenMV3用的是ov7725的sensor。
在暗光情况下ov5640会比ov7725更暗一些。
7 Puls关闭白平衡,IDE显示黑屏
gain_db的值不对。
运行这个程序,可以获得当前的gain_db
https://book.openmv.cc/example/21-Sensor-Control/sensor-manual-whitebal-control.html
追踪色块程序关掉白平衡后,开盖启动程序时随机出现三种不同的色调
sensor.set_auto_whitebal(False),要添加第二个参数的。
代码:https://book.openmv.cc/example/21-Sensor-Control/sensor-manual-whitebal-control.html
同理,sensor.set_auto_gain你也得改。
想问一下如何调节图片色温呢?感谢!!
https://book.openmv.cc/example/21-Sensor-Control/sensor-manual-whitebal-control.html
色温就是调节白平衡。
sensor.set_auto_whitebal(False, rgb_gain_db = (0.0, 0.0, 0.0))
里面设置值。
openmv有没有一个函数可以将RGB图像转换成灰度图?如果没有那么PIL的模块有没有?能不能直接导入
import sensor, image, tv
from PIL import Image
sensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE
sensor.set_framesize(sensor.QQVGA)
tv.init() # Initialize the tv.
while(True):
img = sensor.snapshot()
img.convert('L')
tv.display(img)
关于摄像头在高低亮度环境下上电,获取图像亮度不同的问题
你可以把sensor.get_gain_db(), sensor.get_exposure_us()打印出来。
用的是什么感光元件?
参考:https://book.openmv.cc/example/21-Sensor-Control/sensor-auto-gain-control.html