尝试使用node.js在我的覆盆子pi上运行opencv,但我有很多错误。
pi@raspberrypi:~/node $ v4l2-ctl --list-devices
Camera Board OV5647 (CSI):
/dev/video2
HD USB Camera (usb-3f980000.usb-1.2):
/dev/video0
/dev/video1
运行此代码 var cv = require(' opencv');
try {
var camera = new cv.VideoCapture(2);
var window = new cv.NamedWindow('Video', 0)
while(true)
camera.read(err,im);
window.show(im);
} catch (e){
console.log("Couldn't start camera:", e)
}
使用/ dev / video0
pi@raspberrypi:~/node $ node camera
Couldn't start camera: [ReferenceError: err is not defined]
使用/ dev / video1
pi@raspberrypi:~/node $ node camera
libv4l2: error set_fmt gave us a different result then try_fmt!
HIGHGUI ERROR: libv4l unable convert to requested pixfmt
HIGHGUI ERROR: libv4l unable to ioctl VIDIOCSPICT
Couldn't start camera: [Error: Camera could not be opened]
使用/ dev / video0
pi@raspberrypi:~/node $ node camera
/dev/video2 does not support memory mapping
munmap: Invalid argument
munmap: Invalid argument
munmap: Invalid argument
munmap: Invalid argument
Unable to stop the stream.: Bad file descriptor
munmap: Invalid argument
munmap: Invalid argument
munmap: Invalid argument
munmap: Invalid argument
Couldn't start camera: [ReferenceError: err is not defined]
usb cam具有以下格式
pi@raspberrypi:~/node $ v4l2-ctl --list-formats -d /dev/video0
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: 'MJPG' (compressed)
Name : MJPEG
Index : 1
Type : Video Capture
Pixel Format: 'YUYV'
Name : YUV 4:2:2 (YUYV)
pi@raspberrypi:~/node $ v4l2-ctl --list-formats -d /dev/video1
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: 'H264' (compressed)
Name : H.264
相机是ELP 720p Full Hd H.264 USB相机模块,虽然我怀疑其他人有一个