我正在尝试使用open cv将cp plus ip camera连接到我的应用程序。我尝试了很多方法来捕捉画面。使用"rtsp“协议帮助我捕获帧。IP摄像头的URL是"rtsp://admin:admin@192.168.1.108:554/VideoInput/1/mpeg4/1“。我用VLC播放器试过了。它起作用了。如果有办法通过libvlc捕获帧,并传递到开放的简历,请提到方法。
发布于 2013-08-15 19:43:44
尝试使用"rtsp://admin:admin@192.168.1.108:554/VideoInput/1/mpeg4/1?.mjpg“opencv查看视频流类型的url结尾。
发布于 2017-07-01 19:22:37
您可以直接访问提供摄像头jpg快照的URL。有关如何使用onvif查找它的详细信息,请参阅此处:
http://me-ol-blog.blogspot.co.il/2017/07/getting-still-image-urluri-of-ipcam-or.html
发布于 2018-01-01 01:16:53
第一步是发现您的rtsp url,并在vlc中测试它。你说过你已经有了。
如果有人需要发现rtsp url,我推荐软件onvif-device-tool (link)或gsoap-onvif (link),这两个软件都可以在Linux上运行,看看你的终端,rtsp url就在那里。发现rtsp url后,我建议在vlc player (link)上测试它,您可以使用菜单选项“打开网络流”或从命令行进行测试:
vlc rtsp://your_url
如果你已经有了rtsp url并且在vlc测试成功,那么创建一个cv::VideoCapture并抓取帧。你可以这样做:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
int main() {
cv::VideoCapture stream = cv::VideoCapture("rtsp://admin:admin@192.168.1.108:554/VideoInput/1/mpeg4/1");
if (!stream.isOpened()) return -1; // if not success, exit program
double width = stream.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video
double height = stream.get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of frames of the video
std::cout << "Frame size : " << width << " x " << height << std::endl;
cv::namedWindow("Onvif",CV_WINDOW_AUTOSIZE); //create a window called "Onvif"
cv::Mat frame;
while (1) {
// read a new frame from video
if (!stream.read(frame)) { //if not success, break loop
std::cout << "Cannot read a frame from video stream" << std::endl;
cv::waitKey(30); continue;
}
cv::imshow("Onvif", frame); //show the frame in "Onvif" window
if (cv::waitKey(15)==27) //wait for 'esc'
break;
}
}
要编译:
g++ main.cpp `pkg-config --cflags --libs opencv`
https://stackoverflow.com/questions/18250934
复制相似问题