max*_*mus 5 c++ android opencv video-streaming
我在Android上使用IP网络摄像头程序,并通过WiFi在我的电脑上接收它.我想要的是在Visual Studio,C++中使用opencv来获取该视频流,有一个选项可以通过以下URL获取MJPG流:http:// MyIP:port/videofeed 如何使用opencv获取它?
老问题,但我希望这可以帮助别人(和我的回答一样)
OpenCV期望其VideoCapture参数的文件扩展名,即使并非总是需要(例如你的情况).
您可以通过传入以
mjpg扩展名结尾的伪参数来"欺骗"它 :
所以也许尝试:
VideoCapture vc;
ipCam.open("http://MyIP:port/videofeed/?dummy=param.mjpg")
Run Code Online (Sandbox Code Playgroud)
小智 1
我做了一个肮脏的补丁来使 openCV 与 android ipWebcam 一起工作:
在文件 OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp 中
在函数 bool CvCapture_FFMPEG::open( const char* _filename )
代替:
int err = av_open_input_file(&ic, _filename, NULL, 0, NULL);
Run Code Online (Sandbox Code Playgroud)
经过
AVInputFormat* iformat = av_find_input_format("mjpeg");
int err = av_open_input_file(&ic, _filename, iformat, 0, NULL);
ic->iformat = iformat;
Run Code Online (Sandbox Code Playgroud)
并评论:
err = av_seek_frame(ic, video_stream, 10, 0);
if (err < 0)
{
filename=(char*)malloc(strlen(_filename)+1);
strcpy(filename, _filename);
// reopen videofile to 'seek' back to first frame
reopen();
}
else
{
// seek seems to work, so we don't need the filename,
// but we still need to seek back to filestart
filename=NULL;
int64_t ts = video_st->first_dts;
int flags = AVSEEK_FLAG_FRAME | AVSEEK_FLAG_BACKWARD;
av_seek_frame(ic, video_stream, ts, flags);
}
Run Code Online (Sandbox Code Playgroud)
那应该有效。希望能帮助到你。
| 归档时间: |
|
| 查看次数: |
11745 次 |
| 最近记录: |