OpenCV 的视频流速度很慢
我正在使用 C++ 和 OpenCV 进行视频处理应用程序。这就是我编写代码来初始化网络摄像头的方式。
storage = cvCreateMemStorage( 0 );
capture = cvCaptureFromCAM(1);
cvNamedWindow( "video", 1 );
while( key != 'q' ) {
frame = cvQueryFrame( capture );
if( !frame ) {
fprintf( stderr, "Cannot query frame!\n" );
break;
}
cvFlip( frame, frame, 1 );
frame->origin = 0;
key = cvWaitKey( 1 );
}
任何人都可以建议我一个解决方案,以提高从网络摄像头捕获帧的速度。与实际网络摄像头视频流和 OpenCV 应用程序网络摄像头视频流相比,大约有 3 秒的延迟。
谢谢。
I'm doing video processing application using C++ with OpenCV. This is how I have written coding to initialize web cam.
storage = cvCreateMemStorage( 0 );
capture = cvCaptureFromCAM(1);
cvNamedWindow( "video", 1 );
while( key != 'q' ) {
frame = cvQueryFrame( capture );
if( !frame ) {
fprintf( stderr, "Cannot query frame!\n" );
break;
}
cvFlip( frame, frame, 1 );
frame->origin = 0;
key = cvWaitKey( 1 );
}
Can anyone suggest me a solution in order to increase the speed of capturing frames from web cam. There is like 3 seconds delay when compare to actual web cam video stream with OpenCV application web cam video stream.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你使用什么版本的opencv?您使用的构建是否使用英特尔线程构建模块 (tbb.dll)?如果没有,那就使用它,这就是你的加速。
您还可以尝试一个简单的代码,看看您获得什么类型的加速:
storage = cvCreateMemStorage( 0 );
捕获 = cvCaptureFromCAM(1);
而(1){
帧= cvQueryFrame(捕获);
cvWaitKey(1);
除此之外
,我建议使用 opencv 的 c++ 接口,c 接口相当丑陋,而且可能会更慢。
What version of opencv are you using? Are you using the build that uses Intel Threading Building Blocks (tbb.dll)? If not, then use it, that is your speed-up right there.
You can also try a bare-bones code just to see what type of speed up you get:
storage = cvCreateMemStorage( 0 );
capture = cvCaptureFromCAM(1);
while (1) {
frame = cvQueryFrame(capture);
cvWaitKey(1);
}
Other than that, I suggest using the c++ interface to opencv, the c interface is quite ugly and might be slower.