无法使用Ubuntu OpenCV C 打开相机
cannot open camera with ubuntu opencv c++
我有一个问题,我无法打开我的PC的相机0
这是我使用的代码:
#include "opencv2/opencv.hpp"
#include <iostream>
using namespace cv;
using namespace std;
int main(int, char**)
{
VideoCapture cap(0); // open the default camera
if(!cap.isOpened()) { // check if we succeeded
cout << "cannot open camera "<< endl;
return -1;
}
Mat edges;
namedWindow("edges",1);
for(;;){
Mat frame;
cap >> frame; // get a new frame from camera
cvtColor(frame, edges, COLOR_BGR2GRAY);
GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
Canny(edges, edges, 0, 30, 3);
imshow("edges", edges);
if(waitKey(30) >= 0) break;
}
return 0;
}
它正在显示
无法打开相机
因为等级返回false
请确保正确检测到相机。您可以执行:
$ls /dev/video*
我还发现其他程序为您提供了更详细的输出,例如带有V4L的FFMPEG执行,例如
ffmpeg -f v4l2 -i /dev/video0 -vf scale=640:480 -r 20 -t 00:00:10 output.mp4
,它将告诉您源是否忙碌或为什么无法打开相机,而OpenCV只是返回false。
相关文章:
- OpenCV - Python 断言错误:SAD 算法 - 立体相机视差图计算
- Opencv 如何从相机读取单帧
- OpenCV - 来自相机的实时馈送不流畅
- OpenCV 错误:相机校准:断言在matrix_wrap.cpp失败
- 我无法在 OpenCV 中从相机捕获帧
- 从iPhone相机拍摄的视频似乎被OpenCV旋转了90度?我该如何解决这个问题?
- 使用OpenCV为使用GENICAM API和C++的各种相机创建程序
- C++ 不同分辨率的相机的Opencv校准
- 使用OpenCV延迟捕获相机框架
- OpenCV 将相机中的图像与相同图像进行匹配不会产生 100% 匹配
- 如何使用OpenCV从已知的3D点云(在没有I的情况下构建)估计新图像I的相机姿态矩阵
- 是否可以使用标准OPENCV校准鱼眼相机
- 无法在安卓上使用C++ OpenCV 打开相机
- OPENCV:如何使用5点算法从来自不同相机的两个图像之间的特征匹配来计算必需矩阵
- Pi 相机与 v4l2 OpenCv - 无法获得 2592x1944 分辨率
- 无法使用Ubuntu OpenCV C 打开相机
- 为什么我的实时流相机使用OpenCV QT严重滞后
- OpenCV中移动相机的深度/视差图
- 如何使用Raspberry Pi相机作为C ++ OpenCV中的视频输入
- 如何关闭相机(OpenCv Beaglebone)