如何获得MJPG流视频从android IPWebcam使用opencv
How to get MJPG stream video from android IPWebcam using opencv
我在android上使用IP摄像头程序,并通过WiFi在我的PC上接收它。我想要的是在Visual Studio, c++中使用opencv来获得视视流,有一个选项可以通过以下URL获得MJPG流:http://MyIP:port/videofeed如何使用opencv获得它?
老问题,但我希望这能帮助别人(和我在这里的答案一样)
OpenCV期望它的videoccapture参数的文件名扩展名,即使不总是必要的(就像你的情况)。
你可以通过传递一个以。结尾的虚拟参数来"欺骗"它
mjpg
扩展:
不妨试试:
VideoCapture vc;
ipCam.open("http://MyIP:port/videofeed/?dummy=param.mjpg")
安装IP摄像机适配器并配置为捕获视频流。然后安装ManyCam,你会在相机部分看到"MPEG相机"。(如果你打开如何为skype设置IPWebCam的链接,你会看到相同的说明)现在你可以通过openCV访问你的MJPG流,就像一个网络摄像头一样。我用OpenCV 2.2 + QT尝试了这个,效果很好。
我做了一个肮脏的补丁使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);
AVInputFormat* iformat = av_find_input_format("mjpeg");
int err = av_open_input_file(&ic, _filename, iformat, 0, NULL);
ic->iformat = iformat;
和评论:
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);
}
应该可以。
这就是解决方案(我在android上使用IP Webcam):
CvCapture* capture = 0;
capture = cvCaptureFromFile("http://IP:Port/videofeed?dummy=param.mjpg");
我不能评论,所以我发布新的帖子。在原来的答案是一个错误-使用/前哑巴。
我的工作例子
// OpenCVTest.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "opencv2/highgui/highgui.hpp"
/**
* @function main
*/
int main( int argc, const char** argv )
{
CvCapture* capture;
IplImage* frame = 0;
while (true)
{
//Read the video stream
capture = cvCaptureFromFile("http://192.168.1.129:8080/webcam.mjpeg");
frame = cvQueryFrame( capture );
// create a window to display detected faces
cvNamedWindow("Sample Program", CV_WINDOW_AUTOSIZE);
// display face detections
cvShowImage("Sample Program", frame);
int c = cvWaitKey(10);
if( (char)c == 27 ) { exit(0); }
}
// clean up and release resources
cvReleaseImage(&frame);
return 0;
}
用vlc从网络摄像头广播mjpeg,如何描述在http://tumblr.martinml.com/post/2108887785/how-to-broadcast-a-mjpeg-stream-from-your-webcam-with
- 使用C++库在Android项目中修改gradle中的cmake参数,用于插入指令的测试
- 如何使用ndk-build.cmd构建Android.so文件
- Android NDK传感器向事件队列报告奇怪的间隔
- Android P-9.0.0_r53 Logcat主缓冲区超出定义大小
- OpenCV Android C++ imwrite not found
- Android NDK 编译 LAME HAVE_MPGLIB > 'interface.h' 文件未找到
- 如何使用 Boost Asio 在 Android 上获取我的本地 udp IP 地址?
- Android Studio 中带有静态库的原生C++代码
- 如何在 Android Studio 4 中编译 C/C++ 原生代码
- Android NDK clang 编译器错误在 Windows 上显示'No such file or directory'
- Android 在编译二进制文件时重建静态库
- 我只想在Android 4.4中使用C++11库
- 无法将标准库导入本机 android 项目中的头文件
- Android Java USB for native cpp
- 来自 Android 应用程序内部的 boost 类型的 boost::wrapexcept<boost::system::system_error> 的未捕获异常
- Android Studio:如何在build.gradle中定义自定义宏(针对不同的构建变体),并让原生C / C++
- 在Android原生C++中使用Facemark opencv contrib
- 最小的CMake构建为Android
- 更新后的Android Studio现在需要Clang,不再链接到GCC的库
- 如何获得MJPG流视频从android IPWebcam使用opencv