merged the trunk r8735:8766, r8769, r8777:8780, r8790 and r8800:8811

This commit is contained in:
Marina Kolpakova
2012-06-28 17:07:17 +00:00
parent b156e2f7ed
commit 162f9fd7ea
61 changed files with 2738 additions and 1726 deletions

View File

@@ -43,6 +43,11 @@
#include "precomp.hpp"
#include "opencv2/videostab/frame_source.hpp"
#include "opencv2/opencv_modules.hpp"
#ifdef HAVE_OPENCV_HIGHGUI
# include "opencv2/highgui/highgui.hpp"
#endif
using namespace std;
namespace cv
@@ -50,25 +55,74 @@ namespace cv
namespace videostab
{
struct VideoFileSource::VideoReader
{
#ifdef HAVE_OPENCV_HIGHGUI
mutable VideoCapture vc;
#endif
};
VideoFileSource::VideoFileSource(const string &path, bool volatileFrame)
: path_(path), volatileFrame_(volatileFrame) { reset(); }
: path_(path), volatileFrame_(volatileFrame), reader_(VideoReader()) { reset(); }
void VideoFileSource::reset()
{
reader_.release();
reader_.open(path_);
if (!reader_.isOpened())
#ifdef HAVE_OPENCV_HIGHGUI
reader_.vc.release();
reader_.vc.open(path_);
if (!reader_.vc.isOpened())
throw runtime_error("can't open file: " + path_);
#else
CV_Error(CV_StsNotImplemented, "OpenCV has been compiled without video I/O support");
#endif
}
Mat VideoFileSource::nextFrame()
{
Mat frame;
reader_ >> frame;
#ifdef HAVE_OPENCV_HIGHGUI
reader_.vc >> frame;
#endif
return volatileFrame_ ? frame : frame.clone();
}
int VideoFileSource::width()
{
#ifdef HAVE_OPENCV_HIGHGUI
return static_cast<int>(reader_.vc.get(CV_CAP_PROP_FRAME_WIDTH));
#else
return 0;
#endif
}
int VideoFileSource::height()
{
#ifdef HAVE_OPENCV_HIGHGUI
return static_cast<int>(reader_.vc.get(CV_CAP_PROP_FRAME_HEIGHT));
#else
return 0;
#endif
}
int VideoFileSource::count()
{
#ifdef HAVE_OPENCV_HIGHGUI
return static_cast<int>(reader_.vc.get(CV_CAP_PROP_FRAME_COUNT));
#else
return 0;
#endif
}
double VideoFileSource::fps()
{
#ifdef HAVE_OPENCV_HIGHGUI
return reader_.vc.get(CV_CAP_PROP_FPS);
#else
return 0;
#endif
}
} // namespace videostab
} // namespace cv

View File

@@ -50,7 +50,6 @@
#include <stdexcept>
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/video/video.hpp"
#include "opencv2/features2d/features2d.hpp"