|
本帖最后由 zhangzhenzhao 于 2023-8-22 11:42 编辑
如题,请问rk3588 安装的opencv 是否支持打开MIPI摄像头并预览?
mipi摄像头节点为video0,使用gst打开是没问题,可以预览
gst-launch-1.0 v4l2src device=/dev/video0 io-mode=4 ! queue ! video/x-raw,format=NV12,width=1920,height=1080,framerate=30/1 ! glimagesink
使用opencv无法打开摄像头
报错如下
- [ 8621.495155] rockchip-mipi-csi2 fdd30000.mipi2-csi2: stream ON
- [ 8621.563468] rkcif-mipi-lvds2: ERROR: csi size err, intstat:0x1000001, lastline:0x1, cnt 1
- [ 8621.563468] rkcif-mipi-lvds2: ERROR: csi size err, intstat:0x1000001, lastline:0x1, cnt 1
- [ 8621.596562] mipi2-csi2 ERR1:0x10 (fs/fe mis,vc: 0)
- [ 8621.596686] rkcif-mipi-lvds2: ERROR: csi size err, intstat:0x1000[ 8621.596562] mipi2-csi2 ERR1:0x10 (fs/fe mis,vc: 0)
- [ 8621.596686] rkcif-mipi-lvds2: ERROR: csi size 0err, intstat:0x1000001, lastline:0x2, cnt 2
- 1, lastline:0x2, cnt 2
- [ 8621.629946] rkcif-mipi-lvds2: ERROR: csi size err, intstat:0x1000000, lastline:0x1, cnt 3
- [ 8621.629946] rkcif-mipi-lvds2: ERROR: csi size err, intstat:0x1000000, lastline:0x1, cnt 3
- [ 8621.663327] rkcif-mipi-lvds2: ERROR: csi size err, intstat:0x1000000, lastline:0x1, cnt 4
- [ 8621.663327] rkcif-mipi-lvds2: ERROR: csi size err, intstat:0x1000000, lastline:0x1, cnt 4
- [ 8621.696792] rkcif-mipi-lvds2: ERROR: csi size err, intstat:0x1000001, lastline:0x4, cnt 5
- [ 8621.696792] rkcif-mipi-lvds2: ERROR: csi size err, intstat:0x1000001, lastline:0x4, cnt 5
- [ 8621.730033] rkcif-mipi-lvds2: ERROR: csi size err, intstat:0x1000001, lastline:0x3, cnt 6
- [ 8621.730033] rkcif-mipi-lvds2: ERROR: csi size err, intstat:0x1000001, lastline:0x3, cnt 6
- [ 8621.763241] rkcif-mipi-lvds2: ERROR: csi size err, intstat:0x1000000, lastline:0x1, cnt 7
- [ 8621.763241] rkcif-mipi-lvds2: ERROR: csi size err, intstat:0x1000000, lastline:0x1, cnt 7
- [ 8621.796796] rkcif-mipi-lvds2: ERROR: csi size err, intstat:0x1000001, lastline:0x4, cnt 8
- [ 8621.796796] rkcif-mipi-lvds2: ERROR: csi size err, intstat:0x1000001, lastline:0x4, cnt 8
- [ 8621.830014] rkcif-mipi-lvds2: ERROR: csi size err, intstat:0x1000001, lastline:0x3, cnt 9
- [ 8621.830014] rkcif-mipi-lvds2: ERROR: csi size err, intstat:0x1000001, lastline:0x3, cnt 9
- [ 8621.863388] rkcif-mipi-lvds2: ERROR: csi size err, intstat:0x1000001, lastline:0x4, cnt 10
代码如下:- int main() {
- cv::VideoCapture cap(0);
- if (!cap.isOpened()) {
- std::cerr << "无法打开摄像头!" << std::endl;
- return -1;
- }
- cap.set(cv::CAP_PROP_FRAME_WIDTH, 1920);
- cap.set(cv::CAP_PROP_FRAME_HEIGHT, 1080);
- cap.set(cv::CAP_PROP_FPS, 30);
- cv::namedWindow("Camera Preview", cv::WINDOW_NORMAL);
- while (true) {
- cv::Mat frame;
- cap.read(frame);
- if (frame.empty()) {
- std::cerr << "无法从摄像头读取图像!" << std::endl;
- break;
- }
- cv::imshow("Camera Preview", frame);
- if (cv::waitKey(1) == 27) {
- break;
- }
- }
- cap.release();
- cv::destroyAllWindows();
- return 0;
- }
|
|