"OpenCV" plays the RTSP stream based on the LIBVLC SDK and OpenCV

Source: Internet
Author: User

RTST stream: Using VLC as the RTSP server

vlc2.1.2

vs2013+opencv3.0

C++


1, compile to remember to import VLC Vlc.dll, Vlccore.dll and Plugins folder, these can be downloaded from VLC official website after installation import

2, need to configure the OPENCV in VS2013



#include <opencv2\opencv.hpp> #include <iostream> #include <string> #include "vlc.h" #include "
StdAfx.h "#include" string.h "using namespace CV;

using namespace Std;
int video_width = 1024;
int video_height = 578;
static char * videobuf = 0;
String vlc_vertion= "";
	void *lock (void *data, void**p_pixels) {*p_pixels = Videobuf;
return NULL; 
	} void display (void *data, void *id) {iplimage *img = Cvcreateimage (Cvsize (Video_width, Video_height), ipl_depth_8u, 4);
	Img->imagedata = Videobuf;
	Cvshowimage (Libvlc_get_version (), IMG);
	Cvwaitkey (10);
Cvreleaseimage (&AMP;IMG);
	} void Unlock (void *data, void *id, void *const *p_pixels) {(void) data;
ASSERT (id = = NULL);
	} int main () {Cvnamedwindow ("image", cv_window_autosize);
	libvlc_media_t* media = NULL;
	libvlc_media_player_t* mediaPlayer = NULL;
	Char const* vlc_args[] = {"-I", "dummy", "--ignore-config",};
	Vlc_vertion=libvlc_get_version (); Videobuf = (char*) malloc ((Video_width * video_height) <<
	2);
	
	memset (videobuf, 0, (video_width * video_height) << 2);	
	
	libvlc_instance_t* instance = libvlc_new (sizeof (Vlc_args)/sizeof (Vlc_args[0]), Vlc_args);
	Media = Libvlc_media_new_location (instance, "Rtsp://192.168.200.20:8554/test");
	MediaPlayer = Libvlc_media_player_new_from_media (media);

	Libvlc_media_release (media);
	Libvlc_media_player_set_media (MediaPlayer, media);
	Libvlc_video_set_callbacks (MediaPlayer, lock, unlock, display, NULL);
	Libvlc_video_set_format (MediaPlayer, "RV32", Video_width, Video_height, video_width<<2);
	
	Libvlc_media_player_play (MediaPlayer);
while (1) {} return 0; }

Resources:


VLC to do client-side solution for RTSP bitstream

http://blog.csdn.net/q339659207/article/details/38303831


Read MMS Stream for open CV

Http://stackoverflow.com/questions/9104842/read-mms-stream-for-open-cv


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.