- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试通过读取 openCV 中的网络摄像头流来制作一些计算机视频。我已经尝试使用内部网络摄像头和外部 USB 网络摄像头,它们都可以很好地处理 camorama、streamer 等程序。
我的部分代码:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include "pic_manipulation.hpp"
#include "colorDetector.h"
#include <time.h>
using namespace std;
int main ( int argc, char **argv ){
string file="../test.avi";
cv::VideoCapture capture(0);//les video
if(!capture.isOpened()){
cout <<"could not read file"<<endl;
return -1;
}
double rate=capture.get(CV_CAP_PROP_FPS);
bool stop(false);
cv::Mat frame;
cv::namedWindow("Extract frame");
int delay=1000/rate;
while(!stop){
if(!capture.read(frame))break;
cv::imshow("Extract frame", frame);
sleep(delay/1000);
if(cv::waitKey(delay)>=0){
cout<<"stop"<<endl;
stop=true;
capture.release();
}
cout<< "one loop finished"<<endl;
}
return 0;
}
当我编译并运行程序时,我没有收到任何错误或警告,它只是在 if(!capture.isOpened()) 处返回(或者如果我跳过 isOpened,它会在下一个 if(...) 处返回) .它读取视频文件完全没有问题。任何人都知道我安装的 opencv 是否存在错误,或者是否是导致问题的 linux 网络摄像头设置?我正在使用 linux mint 并使用 cmake/g++ 构建项目
最佳答案
再看看你的代码:
cv::VideoCapture capture(0); // open the default camera
if(!capture.isOpened()) // check if it succeeded
{
//...
}
isOpened()
对索引 0
失败的事实告诉您它无法打开默认相机。因为你有其他相机连接到你的电脑,你也可以尝试传递 1
, 2
, 3
, ...
总是好的check the docs并了解这些方法的作用和返回的内容。
Here is a list of supported webcams ,您的某些相机可能不受 OpenCV 支持。这可以解释为什么默认相机不起作用。
关于c++ - VideoCapture dosnt 从网络摄像头读取 openCV2.4.0 linux,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12685408/
我有不放在“/usr/lib”下的第 3 方库。我在 eclipse library search path 中定义了它们的路径。该项目编译和链接很好,但是当我运行项目时,我遇到了找不到库的异常。如果
我正在尝试通过读取 openCV 中的网络摄像头流来制作一些计算机视频。我已经尝试使用内部网络摄像头和外部 USB 网络摄像头,它们都可以很好地处理 camorama、streamer 等程序。 我的
beforeAll(async () => { mongo = new MongoMemoryServer(); const mongoURI = await mongo.getCon
我是一名优秀的程序员,十分优秀!