简体   繁体   English

OpenCV无法连接到视频流-缺少某些编解码器?

[英]OpenCV cannot connect to video stream - lack of some codec?

I use application IPCamera on my mobile phone with Android to output (share) video image from it's camera to LAN. 我将手机上的应用程序IPCamera与Android一起使用,以将视频图像从其相机输出(共享)到LAN。 I can access it on PC browser - that is ok. 我可以在PC浏览器上访问它-可以。

However, I want to make OpenCV capture this video stream from IP address by typing 但是,我想通过键入以下内容使OpenCV从IP地址捕获此视频流

VideoCapture cap("http://admin:admin@192.168.0.11:8081/?action=stream?dummy=param.mjpg");
 while( cap.isOpened() )
 {
    Mat frame;
    if ( ! cap.read(frame) )
        break;

    cout << "Connected!!";

    imshow("lalala",frame);
    int k = waitKey(10);
    if ( k==27 )
        break;
}

and i got error: 我得到了错误:

在此处输入图片说明

Actual codec, which is used by phone is mjpeg (i read it from application on my mobile). 电话使用的实际编解码器是mjpeg (我从手机上的应用程序中读取了它)。 I don't know if OpenCV supports this, but is that about mobile application uses some kind of unique codec, or my PC lacks it, or maybe C++/OpenCV code is wrong? 我不知道OpenCV是否支持此功能,但是关于移动应用程序是否使用某种独特的编解码器,或者我的PC缺少它,或者C ++ / OpenCV代码是否错误?

On PC opencv can capture your video stream from your mobile prone.. Like. 在PC上,opencv可以从易于移动的设备捕获视频流。 You are using right connection string, like this for rtsp stream in my case. 您正在使用正确的连接字符串,在我的情况下,这样用于rtsp流。

VideoCapture capture("rtsp://USER:PASS@xxx.xxx.xxx.xxx/axis-media/media.amp?camera=2");

Probably, You don't have FFMPEG instaled corectly. 可能您根本没有安装FFMPEG。 You need to reinstall Opencv. 您需要重新安装Opencv。 First you need to install FFMPEG and Opencv After that. 首先,您需要安装FFMPEG和Opencv。 In opencv 3.0.0 and 3.1 try to add 在opencv 3.0.0和3.1中尝试添加

#include <opencv2\videoio.hpp>
#include <opencv2\imgcodecs.hpp>

Some tips how to install ffmpeg and sample in C++ on linux debian Here Code and tips and tricks 在Linux debian上如何在C ++中安装ffmpeg和示例的一些技巧这里的代码和技巧与窍门

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM