我有一台连接到NanoPi NEO Air板的CAM500B OV5640相机。使用主板附带的mjpg-streamer演示时,相机输出看起来正确。然而,当试图在Python中使用OpenCV拍摄静态图片时,图像输出看起来像是垂直拉伸的像素线。
#!/usr/bin/env python
""" Simple camera interface. """
import cv2
import time
if __name__ == "__main__":
cap = cv2.VideoCapture(0)
if not cap.isOpened():
print "Failed to create capture object."
quit(-1)
cap.set(cv2.cv.CV_CAP_PROP_FRAME_WIDTH,1280)
cap.set(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT,720)
#cap.set(cv2.cv.CV_CAP_PROP_FORMAT, cv2.cv.IPL_DEPTH_32F)
print "Ramping camera..."
for i in xrange(0, 30):
_, image = cap.read()
cv2.imwrite("test.jpg", image)
cap.release()
print "Done."