Merge branch '2.4'

This commit is contained in:
Andrey Kamaev
2013-04-05 19:52:42 +04:00
154 changed files with 11355 additions and 16795 deletions

View File

@@ -114,7 +114,7 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
{
int domains[] =
{
#ifdef HAVE_VIDEOINPUT
#ifdef HAVE_DSHOW
CV_CAP_DSHOW,
#endif
#if 1
@@ -168,7 +168,8 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
// try every possibly installed camera API
for (int i = 0; domains[i] >= 0; i++)
{
#if defined(HAVE_VIDEOINPUT) || \
#if defined(HAVE_DSHOW) || \
defined(HAVE_MSMF) || \
defined(HAVE_TYZX) || \
defined(HAVE_VFW) || \
defined(HAVE_LIBV4L) || \
@@ -195,11 +196,18 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
switch (domains[i])
{
#ifdef HAVE_VIDEOINPUT
#ifdef HAVE_MSMF
case CV_CAP_MSMF:
capture = cvCreateCameraCapture_MSMF (index);
if (capture)
return capture;
break;
#endif
#ifdef HAVE_DSHOW
case CV_CAP_DSHOW:
capture = cvCreateCameraCapture_DShow (index);
if (capture)
return capture;
capture = cvCreateCameraCapture_DShow (index);
if (capture)
return capture;
break;
#endif

View File

@@ -41,7 +41,7 @@
#include "precomp.hpp"
#if (defined WIN32 || defined _WIN32) && defined HAVE_VIDEOINPUT
#if (defined WIN32 || defined _WIN32) && defined HAVE_DSHOW
/*
DirectShow-based Video Capturing module is based on
@@ -3098,6 +3098,7 @@ HRESULT videoInput::routeCrossbar(ICaptureGraphBuilder2 **ppBuild, IBaseFilter *
return hr;
}
/********************* Capturing video from camera via DirectShow *********************/
class CvCaptureCAM_DShow : public CvCapture

View File

@@ -209,7 +209,7 @@ CvCapture* cvCreateFileCapture_FFMPEG_proxy(const char * filename)
if( result->open( filename ))
return result;
delete result;
#if defined WIN32 || defined _WIN32
#ifdef HAVE_VFW
return cvCreateFileCapture_VFW(filename);
#else
return 0;
@@ -263,9 +263,9 @@ CvVideoWriter* cvCreateVideoWriter_FFMPEG_proxy( const char* filename, int fourc
if( result->open( filename, fourcc, fps, frameSize, isColor != 0 ))
return result;
delete result;
#if defined WIN32 || defined _WIN32
return cvCreateVideoWriter_VFW(filename, fourcc, fps, frameSize, isColor);
#else
#ifdef HAVE_VFW
return cvCreateVideoWriter_VFW(filename, fourcc, fps, frameSize, isColor);
#else
return 0;
#endif
}

View File

@@ -153,6 +153,14 @@ extern "C" {
#define AVERROR_EOF (-MKTAG( 'E','O','F',' '))
#endif
#if LIBAVCODEC_BUILD >= CALC_FFMPEG_VERSION(54,25,0)
# define CV_CODEC_ID AVCodecID
# define CV_CODEC(name) AV_##name
#else
# define CV_CODEC_ID CodecID
# define CV_CODEC(name) name
#endif
static int get_number_of_cpus(void)
{
#if LIBAVFORMAT_BUILD < CALC_FFMPEG_VERSION(52, 111, 0)
@@ -1026,7 +1034,7 @@ static const char * icvFFMPEGErrStr(int err)
/* function internal to FFMPEG (libavformat/riff.c) to lookup codec id by fourcc tag*/
extern "C" {
enum CodecID codec_get_bmp_id(unsigned int tag);
enum CV_CODEC_ID codec_get_bmp_id(unsigned int tag);
}
void CvVideoWriter_FFMPEG::init()
@@ -1078,7 +1086,7 @@ static AVFrame * icv_alloc_picture_FFMPEG(int pix_fmt, int width, int height, bo
/* add a video output stream to the container */
static AVStream *icv_add_video_stream_FFMPEG(AVFormatContext *oc,
CodecID codec_id,
CV_CODEC_ID codec_id,
int w, int h, int bitrate,
double fps, int pixel_format)
{
@@ -1110,7 +1118,7 @@ static AVStream *icv_add_video_stream_FFMPEG(AVFormatContext *oc,
c->codec_id = oc->oformat->video_codec;
#endif
if(codec_id != CODEC_ID_NONE){
if(codec_id != CV_CODEC(CODEC_ID_NONE)){
c->codec_id = codec_id;
}
@@ -1179,10 +1187,10 @@ static AVStream *icv_add_video_stream_FFMPEG(AVFormatContext *oc,
c->gop_size = 12; /* emit one intra frame every twelve frames at most */
c->pix_fmt = (PixelFormat) pixel_format;
if (c->codec_id == CODEC_ID_MPEG2VIDEO) {
if (c->codec_id == CV_CODEC(CODEC_ID_MPEG2VIDEO)) {
c->max_b_frames = 2;
}
if (c->codec_id == CODEC_ID_MPEG1VIDEO || c->codec_id == CODEC_ID_MSMPEG4V3){
if (c->codec_id == CV_CODEC(CODEC_ID_MPEG1VIDEO) || c->codec_id == CV_CODEC(CODEC_ID_MSMPEG4V3)){
/* needed to avoid using macroblocks in which some coeffs overflow
this doesnt happen with normal video, it just happens here as the
motion of the chroma plane doesnt match the luma plane */
@@ -1290,7 +1298,7 @@ bool CvVideoWriter_FFMPEG::writeFrame( const unsigned char* data, int step, int
#if LIBAVFORMAT_BUILD < 5231
// It is not needed in the latest versions of the ffmpeg
if( c->codec_id == CODEC_ID_RAWVIDEO && origin != 1 )
if( c->codec_id == CV_CODEC(CODEC_ID_RAWVIDEO) && origin != 1 )
{
if( !temp_image.data )
{
@@ -1477,7 +1485,7 @@ void CvVideoWriter_FFMPEG::close()
bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
double fps, int width, int height, bool is_color )
{
CodecID codec_id = CODEC_ID_NONE;
CV_CODEC_ID codec_id = CV_CODEC(CODEC_ID_NONE);
int err, codec_pix_fmt;
double bitrate_scale = 1;
@@ -1518,11 +1526,11 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
/* Lookup codec_id for given fourcc */
#if LIBAVCODEC_VERSION_INT<((51<<16)+(49<<8)+0)
if( (codec_id = codec_get_bmp_id( fourcc )) == CODEC_ID_NONE )
if( (codec_id = codec_get_bmp_id( fourcc )) == CV_CODEC(CODEC_ID_NONE) )
return false;
#else
const struct AVCodecTag * tags[] = { codec_bmp_tags, NULL};
if( (codec_id = av_codec_get_id(tags, fourcc)) == CODEC_ID_NONE )
if( (codec_id = av_codec_get_id(tags, fourcc)) == CV_CODEC(CODEC_ID_NONE) )
return false;
#endif
@@ -1544,20 +1552,20 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
// set a few optimal pixel formats for lossless codecs of interest..
switch (codec_id) {
#if LIBAVCODEC_VERSION_INT>((50<<16)+(1<<8)+0)
case CODEC_ID_JPEGLS:
case CV_CODEC(CODEC_ID_JPEGLS):
// BGR24 or GRAY8 depending on is_color...
codec_pix_fmt = input_pix_fmt;
break;
#endif
case CODEC_ID_HUFFYUV:
case CV_CODEC(CODEC_ID_HUFFYUV):
codec_pix_fmt = PIX_FMT_YUV422P;
break;
case CODEC_ID_MJPEG:
case CODEC_ID_LJPEG:
case CV_CODEC(CODEC_ID_MJPEG):
case CV_CODEC(CODEC_ID_LJPEG):
codec_pix_fmt = PIX_FMT_YUVJ420P;
bitrate_scale = 3;
break;
case CODEC_ID_RAWVIDEO:
case CV_CODEC(CODEC_ID_RAWVIDEO):
codec_pix_fmt = input_pix_fmt == PIX_FMT_GRAY8 ||
input_pix_fmt == PIX_FMT_GRAY16LE ||
input_pix_fmt == PIX_FMT_GRAY16BE ? input_pix_fmt : PIX_FMT_YUV420P;
@@ -1788,7 +1796,7 @@ struct OutputMediaStream_FFMPEG
void write(unsigned char* data, int size, int keyFrame);
// add a video output stream to the container
static AVStream* addVideoStream(AVFormatContext *oc, CodecID codec_id, int w, int h, int bitrate, double fps, PixelFormat pixel_format);
static AVStream* addVideoStream(AVFormatContext *oc, CV_CODEC_ID codec_id, int w, int h, int bitrate, double fps, PixelFormat pixel_format);
AVOutputFormat* fmt_;
AVFormatContext* oc_;
@@ -1835,7 +1843,7 @@ void OutputMediaStream_FFMPEG::close()
}
}
AVStream* OutputMediaStream_FFMPEG::addVideoStream(AVFormatContext *oc, CodecID codec_id, int w, int h, int bitrate, double fps, PixelFormat pixel_format)
AVStream* OutputMediaStream_FFMPEG::addVideoStream(AVFormatContext *oc, CV_CODEC_ID codec_id, int w, int h, int bitrate, double fps, PixelFormat pixel_format)
{
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 10, 0)
AVStream* st = avformat_new_stream(oc, 0);
@@ -1915,10 +1923,10 @@ AVStream* OutputMediaStream_FFMPEG::addVideoStream(AVFormatContext *oc, CodecID
c->gop_size = 12; // emit one intra frame every twelve frames at most
c->pix_fmt = pixel_format;
if (c->codec_id == CODEC_ID_MPEG2VIDEO)
if (c->codec_id == CV_CODEC(CODEC_ID_MPEG2VIDEO))
c->max_b_frames = 2;
if (c->codec_id == CODEC_ID_MPEG1VIDEO || c->codec_id == CODEC_ID_MSMPEG4V3)
if (c->codec_id == CV_CODEC(CODEC_ID_MPEG1VIDEO) || c->codec_id == CV_CODEC(CODEC_ID_MSMPEG4V3))
{
// needed to avoid using macroblocks in which some coeffs overflow
// this doesnt happen with normal video, it just happens here as the
@@ -1955,7 +1963,7 @@ bool OutputMediaStream_FFMPEG::open(const char* fileName, int width, int height,
if (!fmt_)
return false;
CodecID codec_id = CODEC_ID_H264;
CV_CODEC_ID codec_id = CV_CODEC(CODEC_ID_H264);
// alloc memory for context
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 2, 0)
@@ -2156,23 +2164,23 @@ bool InputMediaStream_FFMPEG::open(const char* fileName, int* codec, int* chroma
switch (enc->codec_id)
{
case CODEC_ID_MPEG1VIDEO:
case CV_CODEC(CODEC_ID_MPEG1VIDEO):
*codec = ::VideoCodec_MPEG1;
break;
case CODEC_ID_MPEG2VIDEO:
case CV_CODEC(CODEC_ID_MPEG2VIDEO):
*codec = ::VideoCodec_MPEG2;
break;
case CODEC_ID_MPEG4:
case CV_CODEC(CODEC_ID_MPEG4):
*codec = ::VideoCodec_MPEG4;
break;
case CODEC_ID_VC1:
case CV_CODEC(CODEC_ID_VC1):
*codec = ::VideoCodec_VC1;
break;
case CODEC_ID_H264:
case CV_CODEC(CODEC_ID_H264):
*codec = ::VideoCodec_H264;
break;

View File

@@ -1714,6 +1714,7 @@ static void icvCloseCAM_V4L( CvCaptureCAM_V4L* capture ){
#endif
free(capture->deviceName);
capture->deviceName = NULL;
//v4l2_free_ranges(capture);
//cvFree((void **)capture);
}

File diff suppressed because it is too large Load Diff

View File

@@ -406,7 +406,7 @@ bool CvCaptureCAM_VFW::open( int wIndex )
fourcc = (DWORD)-1;
memset( &caps, 0, sizeof(caps));
capDriverGetCaps( hWndC, &caps, sizeof(&caps));
capDriverGetCaps( hWndC, &caps, sizeof(caps));
::MoveWindow( hWndC, 0, 0, 320, 240, TRUE );
capSetUserData( hWndC, (size_t)this );
capSetCallbackOnFrame( hWndC, frameCallback );

View File

@@ -103,14 +103,6 @@ struct CvVideoWriter
virtual bool writeFrame(const IplImage*) { return false; }
};
#if defined WIN32 || defined _WIN32
#define HAVE_VFW 1
/* uncomment to enable CMUCamera1394 fireware camera module */
//#define HAVE_CMU1394 1
#endif
CvCapture * cvCreateCameraCapture_V4L( int index );
CvCapture * cvCreateCameraCapture_DC1394( int index );
CvCapture * cvCreateCameraCapture_DC1394_2( int index );
@@ -126,6 +118,7 @@ CvVideoWriter* cvCreateVideoWriter_Win32( const char* filename, int fourcc,
CvVideoWriter* cvCreateVideoWriter_VFW( const char* filename, int fourcc,
double fps, CvSize frameSize, int is_color );
CvCapture* cvCreateCameraCapture_DShow( int index );
CvCapture* cvCreateCameraCapture_MSMF( int index );
CvCapture* cvCreateCameraCapture_OpenNI( int index );
CvCapture* cvCreateFileCapture_OpenNI( const char* filename );
CvCapture* cvCreateCameraCapture_Android( int index );

View File

@@ -57,7 +57,7 @@ CV_IMPL void cvSetWindowProperty(const char* name, int prop_id, double prop_valu
#if defined (HAVE_QT)
cvSetModeWindow_QT(name,prop_value);
#elif defined WIN32 || defined _WIN32
#elif defined(HAVE_WIN32UI)
cvSetModeWindow_W32(name,prop_value);
#elif defined (HAVE_GTK)
cvSetModeWindow_GTK(name,prop_value);
@@ -96,7 +96,7 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id)
#if defined (HAVE_QT)
return cvGetModeWindow_QT(name);
#elif defined WIN32 || defined _WIN32
#elif defined(HAVE_WIN32UI)
return cvGetModeWindow_W32(name);
#elif defined (HAVE_GTK)
return cvGetModeWindow_GTK(name);
@@ -113,7 +113,7 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id)
#if defined (HAVE_QT)
return cvGetPropWindow_QT(name);
#elif defined WIN32 || defined _WIN32
#elif defined(HAVE_WIN32UI)
return cvGetPropWindowAutoSize_W32(name);
#elif defined (HAVE_GTK)
return cvGetPropWindowAutoSize_GTK(name);
@@ -126,7 +126,7 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id)
#if defined (HAVE_QT)
return cvGetRatioWindow_QT(name);
#elif defined WIN32 || defined _WIN32
#elif defined(HAVE_WIN32UI)
return cvGetRatioWindow_W32(name);
#elif defined (HAVE_GTK)
return cvGetRatioWindow_GTK(name);
@@ -139,7 +139,7 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id)
#if defined (HAVE_QT)
return cvGetOpenGlProp_QT(name);
#elif defined WIN32 || defined _WIN32
#elif defined(HAVE_WIN32UI)
return cvGetOpenGlProp_W32(name);
#elif defined (HAVE_GTK)
return cvGetOpenGlProp_GTK(name);
@@ -440,11 +440,11 @@ int cv::createButton(const String&, ButtonCallback, void*, int , bool )
#endif
#if defined WIN32 || defined _WIN32 // see window_w32.cpp
#if defined(HAVE_WIN32UI) // see window_w32.cpp
#elif defined (HAVE_GTK) // see window_gtk.cpp
#elif defined (HAVE_COCOA) // see window_carbon.cpp
#elif defined (HAVE_COCOA) // see window_carbon.cpp
#elif defined (HAVE_CARBON)
#elif defined (HAVE_QT) //YV see window_QT.cpp
#elif defined (HAVE_QT) //YV see window_QT.cpp
#else