openmv视野里出现黑点
应该是sensor进灰了,按照视频1分10秒中的方法,擦干净就行。
https://singtown.com/learn/49985/
如何连续拍照保存照片
import sensor, image, time
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
i=0
while(True):
clock.tick()
img = sensor.snapshot()
img.save(str(i)+'.jpg')
i++
print(clock.fps())
怎样提高拍照的清晰度
@laoguren1122 程序如图
import time, sensor, image, math
from image import SEARCH_EX, SEARCH_DS
Reset sensor
sensor.reset()
Set sensor settings
sensor.set_contrast(1)
sensor.set_gainceiling(16)
Max resolution for template matching with SEARCH_EX is QQVGA
sensor.set_framesize(sensor.QQVGA)
You can set windowing to reduce the search image.
#sensor.set_windowing(((640-80)//2, (480-60)//2, 80, 60))
sensor.set_pixformat(sensor.GRAYSCALE)
Load template.
Template should be a small (eg. 32x32 pixels) grayscale image.
template = image.Image("/ball3.pgm")
low_threshold = (0, 50)
high_threshold = (195, 255)
clock = time.clock()
Run template matching
while (True):
clock.tick()
img = sensor.snapshot().lens_corr(1.8)
for x in range(4):
r = img.find_template(template, 0.70)
if r:
img.draw_rectangle(r,color=0)
img.find_edges(image.EDGE_CANNY, threshold=(50, 80))
for c in img.find_circles(threshold = 2500, x_margin = 20, y_margin = 20, r_margin = 20):
img.draw_circle(c.x(), c.y(), c.r(), color = (0, 0, 0))
print(c)
print(clock.fps())
在不同颜色卡纸面前打开摄像头,画面会变不同颜色
确实是白平衡的问题。因为OpenMV开机会自动调节白平衡,如果一开机就全部是红色的,白平衡就会自动偏蓝。
解决办法:手动设置白平衡。
代码:
import sensor,time
sensor.reset()
sensor.set_pixformat(sensor.RGB565) #使用RGB565
sensor.set_framesize(sensor.QVGA) #使用QQVGA
sensor.set_auto_whitebal(False, rgb_gain_db = (-6.02073, -5.886325, -4.30291))
clock = time.clock()
while(True):
clock.tick()
img = sensor.snapshot()
print(clock.fps())
这个rgb_gain_db的参数是我的环境正常的,颜色比较鲜艳。如果你想修改,可以运行这个代码获得:https://book.openmv.cc/example/21-Sensor-Control/sensor-manual-whitebal-control.html
想要实现串口接收到指令后再开始打开摄像头
如果要关闭摄像头,可以让摄像头休眠。一般不需要。https://book.openmv.cc/example/19-Low-Power/sensor-sleep.html
在使用snapshot(copy_to_fb=False)时,IDE缓冲区还是能看到图像,这是为啥?
import time, sensor, image
from image import SEARCH_EX, SEARCH_DS
sensor.reset()
sensor.set_contrast(1)
sensor.set_gainceiling(16)
sensor.set_framesize(sensor.VGA)
sensor.set_pixformat(sensor.GRAYSCALE)
clock = time.clock()
while (True):
clock.tick()
img = sensor.snapshot(copy_to_fb=False)
print(clock.fps())
为什么WiFi图传视频流,画质会变得很奇怪?
提供一下全部代码。要文本,不要图片。
和OpenMV的的硬件型号,sensor模组的型号。
为什么openmv会把二维码识别成人脸??
import sensor, image, time
sensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.RGB565) # use RGB565.
sensor.set_framesize(sensor.QQVGA) # use QQVGA for speed.
sensor.skip_frames(10) # Let new settings take affect.
sensor.set_auto_whitebal(False) # turn this off.
clock = time.clock() # Tracks FPS.
face_cascade = image.HaarCascade("frontalface", stages=25)
while(True):
clock.tick() # Track elapsed milliseconds between snapshots().
img = sensor.snapshot() # Take a picture and return the image.
objects = sensor.snapshot().to_grayscale().find_features(face_cascade, threshold=0.75, scale=1.35)
if objects:
print("检测到人脸")
for code in img.find_qrcodes():
message = code.payload()
print(message)
tflite文件找不到怎么办?
# This code run in OpenMV4 H7
import sensor, image, time, os, tf
sensor.reset() # Reset and initialize the sensor.
sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA (320x240)
sensor.set_windowing((240, 240)) # Set 240x240 window.
sensor.skip_frames(time=2000) # Let the camera adjust.
clock = time.clock()
while(True):
clock.tick()
img = sensor.snapshot().binary([(0,64)])
for obj in tf.classify("trained.tflite", img, min_scale=1.0, scale_mul=0.5, x_overlap=0.0, y_overlap=0.0):
output = obj.output()
number = output.index(max(output))
print(number)
print(clock.fps(), "fps")
OPENMV的SD卡可以保持运行程序,但是录制视频,GIF都是0K,一般是什么问题呢?
@kidswong999
IDE中的:example/video_recording/gif.py
源码:
import sensor, image, time
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
while(True):
clock.tick()
img = sensor.snapshot()
print(clock.fps())