从HighGUI的一段代码中看OpenCV打开视频的方式
* Videoreader dispatching method: it tries to find the first
* API that can access a given filename.
*/
CV_IMPL CvCapture * cvCreateFileCaptureWithPreference ( const char * filename, int apiPreference)
{
CvCapture * result = 0;
switch(apiPreference) {
default :
// user specified an API we do not know
// bail out to let the user know that it is not available
if (apiPreference) break;
# ifdef HAVE_FFMPEG
case CV_CAP_FFMPEG :
TRY_OPEN(result, cvCreateFileCapture_FFMPEG_proxy (filename))
if (apiPreference) break;
# endif
case CV_CAP_VFW :
# ifdef HAVE_VFW
TRY_OPEN(result, cvCreateFileCapture_VFW (filename))
# endif
# if defined HAVE_LIBV4L || defined HAVE_CAMV4L || defined HAVE_CAMV4L2 || defined HAVE_VIDEOIO
TRY_OPEN(result, cvCreateCameraCapture_V4L(filename))
# endif
if (apiPreference) break;
case CV_CAP_MSMF :
# ifdef HAVE_MSMF
TRY_OPEN(result, cvCreateFileCapture_MSMF (filename))
# endif
# ifdef HAVE_XINE
TRY_OPEN(result, cvCreateFileCapture_XINE (filename))
# endif
if (apiPreference) break;
# ifdef HAVE_GSTREAMER
case CV_CAP_GSTREAMER :
TRY_OPEN(result, cvCreateCapture_GStreamer (CV_CAP_GSTREAMER_FILE, filename))
if (apiPreference) break;
# endif
# if defined(HAVE_QUICKTIME) || defined(HAVE_QTKIT)
case CV_CAP_QT :
TRY_OPEN(result, cvCreateFileCapture_QT (filename))
if (apiPreference) break;
# endif
# ifdef HAVE_AVFOUNDATION
case CV_CAP_AVFOUNDATION :
TRY_OPEN(result, cvCreateFileCapture_AVFoundation (filename))
if (apiPreference) break;
# endif
# ifdef HAVE_OPENNI
case CV_CAP_OPENNI :
TRY_OPEN(result, cvCreateFileCapture_OpenNI (filename))
if (apiPreference) break;
# endif
# ifdef HAVE_OPENNI2
case CV_CAP_OPENNI2 :
TRY_OPEN(result, cvCreateFileCapture_OpenNI2 (filename))
if (apiPreference) break;
# endif
case CV_CAP_IMAGES :
TRY_OPEN(result, cvCreateFileCapture_Images (filename))
}
return result;
}
It also decodes multimedia files like AVI, MOV, WMV, and MP3 from local disk
drives, and displays multimedia streamed over the Internet.
It interprets many of the most common multimedia formats available – and some
of the most uncommon formats, too.