现在的位置: 首页 > 综合 > 正文

opencv mjpg note

2013年08月28日 ⁄ 综合 ⁄ 共 2307字 ⁄ 字号 评论关闭

I'm using openCV 1.1pre1 under Windows. I have a network camera and I need to grab frames from openCV. That camera can stream a standard mpeg4 stream over RTSP or mjpeg over http. I've seen many threads talking about using ffmpeg with openCV but I cannot make it work.

How I can grab frames from an IP camera with openCV?

Thanks

Andrea

==========

 

 

Use ffmpeglib to connect to the stream.

These functions may be useful. But take a look in the docs

av_open_input_stream(...);
av_find_stream_info
(...);
avcodec_find_decoder
(...);
avcodec_open
(...);
avcodec_alloc_frame
(...);

You would need a little algo to get a complete frame, which is available here

http://www.dranger.com/ffmpeg/tutorial01.html

Once you get a frame you could copy the video data (for each plane if needed) into a IplImage which is an OpenCV image object.

You can create an IplImage using something like...

IplImage *p_gray_image = cvCreateImage(size, IPL_DEPTH_8U, 1);

Once you have an IplImage, you could perform all sorts of image operations available in the OpenCV lib

link|flag
 

 

 

 

 
I've seen in many threads that ffmpeg is already included and used inside openCV, is this right? Maybe I need to recompile openCV with ffgmpeg support? In this case how I can do this under windows? Thanks – Grifo Apr 3 '09 at 12:36
 
I'm not aware of this. However, ffmpeg is an application where as ffmpeglib is a library. If you are new to these please look at the dranger.com tutorials. – Indeera Apr 3 '09 at 13:19
=================
 

 

OpenCV can be compiled with FFMPEG support. From ./configure --help:

--with-ffmpeg     use ffmpeg libraries (see LICENSE) [automatic]

You can then use *cvCreateFileCapture_FFMPEG* to create a CvCapture with e.g. the URL of the camera's MJPG stream.

I use this to grab frames from an AXIS camera:

CvCapture *capture = 
    cvCreateFileCapture_FFMPEG
("http://axis-cam/mjpg/video.mjpg?resolution=640x480&req_fps=10&.mjpg");
link|flag
 

 

 

 

 
Is it possible to configure openCV with ffmpeg support under Windows? – Grifo Jun 25 '09 at 9:37
===========
 

 

I just do it like this:

CvCapture *capture = cvCreateFileCapture("rtsp://camera-address");

Also make sure this dll is available at runtime else cvCreateFileCapture will return NULL

opencv_ffmpeg200d.dll

The camera needs to allow unauthenticated access too, usually set via its web interface. MJPEG format worked via rtsp but MPEG4 didn't.

hth

Si

link|flag
 

 

 

 

 
Are you using OpenCV 2.0? – Grifo Mar 2 at 8:41
 
The library version says that he is using openCV 2.0 - that's the 200 part in opencv_ffmpeg200d.dll – jamuraa Mar 17 at 20:41
===================

抱歉!评论已关闭.