最开始的sensor.__write_reg添加了之后,sensor的图像不能更新。
最后一行sensor.snapshot()是什么用?
我注释掉了这两个。
以下的代码是可以的。
import sensor, time, image
sensor.reset()
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 = "666"
img = sensor.snapshot()
kernel_size = 1 # kernel width = (size*2)+1, kernel height = (size*2)+1
kernel = [-1, -1, -1,\
-1, +8, -1,\
-1, -1, -1]
thresholds = [(100, 255)] # grayscale thresholds设置阈值
clock = time.clock() # 追踪FPS
#if (sensor.get_id() == sensor.OV7725):
#sensor.__write_reg(0xAC, 0xDF)
#sensor.__write_reg(0x8F, 0xFF)
while(True):
clock.tick() # Track elapsed milliseconds between snapshots().
img = sensor.snapshot() # Take a picture and return the image.
img.morph(kernel_size, kernel)
img.binary(thresholds)
img.erode(1, threshold = 2)
print(clock.fps()) # Note: Your OpenMV Cam runs about half as fast while
#time.sleep(100)
kpts = img.find_keypoints(max_keypoints=150, threshold=10, scale_factor=1.2)
if (kpts == None):
raise(Exception("Couldn't find any keypoints!"))
image.save_descriptor(kpts, "/%s.orb"%(FILE_NAME))
img.draw_keypoints(kpts)