opencv 获取rtsp流媒体视频

Xylona ·
更新时间:2024-11-10
· 999 次阅读

      在opencv3.2.0+vs2015的环境下,是可以使用opencv读取rtsp流的. 

      cv::VideoCapture vcap; const std::string videoStreamAddress = "rtsp://admin:test123456@192.168.1.19:55/MPEG-4/ch1/main/av_stream";

      rtsp://192.168.1.19/vod/mp4://BigBuckBunny_175k.mov

if (!vcap.open(videoStreamAddress)) { std::cout << "Error opening video stream or file" << std::endl; return -1; }

代码如下:

#include "stdafx.h" #include  #include  using namespace std; using namespace cv; int main() {         VideoCapture cap;         cap.open("rtsp://192.168.1.19/stream1");         Mat Camera_CImg;         Mat Camera_GImg;         cap.set(CV_CAP_PROP_FRAME_HEIGHT,768);         cap.set(CV_CAP_PROP_FRAME_WIDTH,1024);         if (!cap.isOpened())          return 1024;         while (1)         { cap>> Camera_CImg; if(Camera_CImg.empty()) break; cvtColor(Camera_CImg,Camera_GImg, CV_RGB2GRAY); imshow("input", Camera_CImg); if (cvWaitKey(10) == 'q') break;         }     system("pause"); return 0; }
作者:老樊Lu码



rtsp opencv

需要 登录 后方可回复, 如果你还没有账号请 注册新账号