a big patch; use special proxy types (Input/OutputArray, Input/OutputArrayOfArrays) for passing in vectors, matrices etc.
This commit is contained in:
@@ -59,7 +59,7 @@ namespace cv
|
||||
{
|
||||
|
||||
BackgroundSubtractor::~BackgroundSubtractor() {}
|
||||
void BackgroundSubtractor::operator()(const Mat&, Mat&, double)
|
||||
void BackgroundSubtractor::operator()(const InputArray&, OutputArray, double)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -381,15 +381,17 @@ static void process8uC3( BackgroundSubtractorMOG& obj, const Mat& image, Mat& fg
|
||||
}
|
||||
}
|
||||
|
||||
void BackgroundSubtractorMOG::operator()(const Mat& image, Mat& fgmask, double learningRate)
|
||||
void BackgroundSubtractorMOG::operator()(const InputArray& _image, OutputArray _fgmask, double learningRate)
|
||||
{
|
||||
Mat image = _image.getMat();
|
||||
bool needToInitialize = nframes == 0 || learningRate >= 1 || image.size() != frameSize || image.type() != frameType;
|
||||
|
||||
if( needToInitialize )
|
||||
initialize(image.size(), image.type());
|
||||
|
||||
CV_Assert( image.depth() == CV_8U );
|
||||
fgmask.create( image.size(), CV_8U );
|
||||
_fgmask.create( image.size(), CV_8U );
|
||||
Mat fgmask = _fgmask.getMat();
|
||||
|
||||
++nframes;
|
||||
learningRate = learningRate >= 0 && nframes > 1 ? learningRate : 1./min( nframes, history );
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -289,29 +289,25 @@ cvCamShift( const void* imgProb, CvRect windowIn,
|
||||
return itersUsed;
|
||||
}
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
RotatedRect CamShift( const Mat& probImage, Rect& window,
|
||||
cv::RotatedRect cv::CamShift( const InputArray& _probImage, Rect& window,
|
||||
TermCriteria criteria )
|
||||
{
|
||||
CvConnectedComp comp;
|
||||
CvBox2D box;
|
||||
CvMat _probImage = probImage;
|
||||
cvCamShift(&_probImage, window, (CvTermCriteria)criteria, &comp, &box);
|
||||
CvMat c_probImage = _probImage.getMat();
|
||||
cvCamShift(&c_probImage, window, (CvTermCriteria)criteria, &comp, &box);
|
||||
window = comp.rect;
|
||||
return RotatedRect(Point2f(box.center), Size2f(box.size), box.angle);
|
||||
}
|
||||
|
||||
int meanShift( const Mat& probImage, Rect& window, TermCriteria criteria )
|
||||
int cv::meanShift( const InputArray& _probImage, Rect& window, TermCriteria criteria )
|
||||
{
|
||||
CvConnectedComp comp;
|
||||
CvMat _probImage = probImage;
|
||||
int iters = cvMeanShift(&_probImage, window, (CvTermCriteria)criteria, &comp );
|
||||
CvMat c_probImage = _probImage.getMat();
|
||||
int iters = cvMeanShift(&c_probImage, window, (CvTermCriteria)criteria, &comp );
|
||||
window = comp.rect;
|
||||
return iters;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* End of file. */
|
||||
|
||||
@@ -42,18 +42,15 @@
|
||||
#include <float.h>
|
||||
#include <stdio.h>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
void calcOpticalFlowPyrLK( const Mat& prevImg, const Mat& nextImg,
|
||||
const vector<Point2f>& prevPts,
|
||||
vector<Point2f>& nextPts,
|
||||
vector<uchar>& status, vector<float>& err,
|
||||
void cv::calcOpticalFlowPyrLK( const InputArray& _prevImg, const InputArray& _nextImg,
|
||||
const InputArray& _prevPts, InputOutputArray _nextPts,
|
||||
OutputArray _status, OutputArray _err,
|
||||
Size winSize, int maxLevel,
|
||||
TermCriteria criteria,
|
||||
double derivLambda,
|
||||
int flags )
|
||||
{
|
||||
Mat prevImg = _prevImg.getMat(), nextImg = _nextImg.getMat(), prevPtsMat = _prevPts.getMat();
|
||||
derivLambda = std::min(std::max(derivLambda, 0.), 1.);
|
||||
double lambda1 = 1. - derivLambda, lambda2 = derivLambda;
|
||||
const int derivKernelSize = 3;
|
||||
@@ -66,16 +63,34 @@ void calcOpticalFlowPyrLK( const Mat& prevImg, const Mat& nextImg,
|
||||
CV_Assert( prevImg.size() == nextImg.size() &&
|
||||
prevImg.type() == nextImg.type() );
|
||||
|
||||
size_t npoints = prevPts.size();
|
||||
nextPts.resize(npoints);
|
||||
status.resize(npoints);
|
||||
size_t npoints = prevPtsMat.total();
|
||||
if( npoints == 0 )
|
||||
{
|
||||
_nextPts.release();
|
||||
_status.release();
|
||||
_err.release();
|
||||
return;
|
||||
}
|
||||
|
||||
CV_Assert( prevPtsMat.isContinuous() );
|
||||
const Point2f* prevPts = (const Point2f*)prevPtsMat.data;
|
||||
|
||||
_nextPts.create((int)npoints, 1, prevPtsMat.type(), -1, true);
|
||||
Mat nextPtsMat = _nextPts.getMat();
|
||||
CV_Assert( nextPtsMat.isContinuous() );
|
||||
Point2f* nextPts = (Point2f*)nextPtsMat.data;
|
||||
|
||||
_status.create((int)npoints, 1, CV_8U, -1, true);
|
||||
Mat statusMat = _status.getMat();
|
||||
CV_Assert( statusMat.isContinuous() );
|
||||
uchar* status = statusMat.data;
|
||||
for( size_t i = 0; i < npoints; i++ )
|
||||
status[i] = true;
|
||||
err.resize(npoints);
|
||||
_err.create((int)npoints, 1, CV_32F, -1, true);
|
||||
Mat errMat = _err.getMat();
|
||||
CV_Assert( errMat.isContinuous() );
|
||||
float* err = (float*)errMat.data;
|
||||
|
||||
if( npoints == 0 )
|
||||
return;
|
||||
|
||||
vector<Mat> prevPyr, nextPyr;
|
||||
|
||||
int cn = prevImg.channels();
|
||||
@@ -334,8 +349,6 @@ void calcOpticalFlowPyrLK( const Mat& prevImg, const Mat& nextImg,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
intersect( CvPoint2D32f pt, CvSize win_size, CvSize imgSize,
|
||||
CvPoint* min_pt, CvPoint* max_pt )
|
||||
@@ -1852,18 +1865,14 @@ cvEstimateRigidTransform( const CvArr* matA, const CvArr* matB, CvMat* matM, int
|
||||
return 1;
|
||||
}
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
Mat estimateRigidTransform( const Mat& A,
|
||||
const Mat& B,
|
||||
bool fullAffine )
|
||||
cv::Mat cv::estimateRigidTransform( const InputArray& A,
|
||||
const InputArray& B,
|
||||
bool fullAffine )
|
||||
{
|
||||
Mat M(2, 3, CV_64F);
|
||||
CvMat matA = A, matB = B, matM = M;
|
||||
CvMat matA = A.getMat(), matB = B.getMat(), matM = M;
|
||||
cvEstimateRigidTransform(&matA, &matB, &matM, fullAffine);
|
||||
return M;
|
||||
}
|
||||
}
|
||||
|
||||
/* End of file. */
|
||||
|
||||
@@ -442,38 +442,40 @@ cvSegmentMotion( const CvArr* mhiimg, CvArr* segmask, CvMemStorage* storage,
|
||||
}
|
||||
|
||||
|
||||
void cv::updateMotionHistory( const Mat& silhouette, Mat& mhi,
|
||||
void cv::updateMotionHistory( const InputArray& _silhouette, InputOutputArray _mhi,
|
||||
double timestamp, double duration )
|
||||
{
|
||||
CvMat _silhouette = silhouette, _mhi = mhi;
|
||||
cvUpdateMotionHistory( &_silhouette, &_mhi, timestamp, duration );
|
||||
CvMat c_silhouette = _silhouette.getMat(), c_mhi = _mhi.getMat();
|
||||
cvUpdateMotionHistory( &c_silhouette, &c_mhi, timestamp, duration );
|
||||
}
|
||||
|
||||
void cv::calcMotionGradient( const Mat& mhi, Mat& mask,
|
||||
Mat& orientation,
|
||||
void cv::calcMotionGradient( const InputArray& _mhi, OutputArray _mask,
|
||||
OutputArray _orientation,
|
||||
double delta1, double delta2,
|
||||
int aperture_size )
|
||||
{
|
||||
mask.create(mhi.size(), CV_8U);
|
||||
orientation.create(mhi.size(), CV_32F);
|
||||
CvMat _mhi = mhi, _mask = mask, _orientation = orientation;
|
||||
cvCalcMotionGradient(&_mhi, &_mask, &_orientation, delta1, delta2, aperture_size);
|
||||
Mat mhi = _mhi.getMat();
|
||||
_mask.create(mhi.size(), CV_8U);
|
||||
_orientation.create(mhi.size(), CV_32F);
|
||||
CvMat c_mhi = mhi, c_mask = _mask.getMat(), c_orientation = _orientation.getMat();
|
||||
cvCalcMotionGradient(&c_mhi, &c_mask, &c_orientation, delta1, delta2, aperture_size);
|
||||
}
|
||||
|
||||
double cv::calcGlobalOrientation( const Mat& orientation, const Mat& mask,
|
||||
const Mat& mhi, double timestamp,
|
||||
double cv::calcGlobalOrientation( const InputArray& _orientation, const InputArray& _mask,
|
||||
const InputArray& _mhi, double timestamp,
|
||||
double duration )
|
||||
{
|
||||
CvMat _orientation = orientation, _mask = mask, _mhi = mhi;
|
||||
return cvCalcGlobalOrientation(&_orientation, &_mask, &_mhi, timestamp, duration);
|
||||
CvMat c_orientation = _orientation.getMat(), c_mask = _mask.getMat(), c_mhi = _mhi.getMat();
|
||||
return cvCalcGlobalOrientation(&c_orientation, &c_mask, &c_mhi, timestamp, duration);
|
||||
}
|
||||
|
||||
void cv::segmentMotion(const Mat& mhi, Mat& segmask,
|
||||
void cv::segmentMotion(const InputArray& _mhi, OutputArray _segmask,
|
||||
vector<Rect>& boundingRects,
|
||||
double timestamp, double segThresh)
|
||||
{
|
||||
segmask.create(mhi.size(), CV_32F);
|
||||
CvMat c_mhi = mhi, c_segmask = segmask;
|
||||
Mat mhi = _mhi.getMat();
|
||||
_segmask.create(mhi.size(), CV_32F);
|
||||
CvMat c_mhi = mhi, c_segmask = _segmask.getMat();
|
||||
Ptr<CvMemStorage> storage = cvCreateMemStorage();
|
||||
Seq<CvConnectedComp> comps = cvSegmentMotion(&c_mhi, &c_segmask, storage, timestamp, segThresh);
|
||||
Seq<CvConnectedComp>::const_iterator it(comps);
|
||||
|
||||
@@ -561,22 +561,24 @@ FarnebackUpdateFlow_GaussianBlur( const Mat& _R0, const Mat& _R1,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void calcOpticalFlowFarneback( const Mat& prev0, const Mat& next0,
|
||||
Mat& flow0, double pyr_scale, int levels, int winsize,
|
||||
void cv::calcOpticalFlowFarneback( const InputArray& _prev0, const InputArray& _next0,
|
||||
OutputArray _flow0, double pyr_scale, int levels, int winsize,
|
||||
int iterations, int poly_n, double poly_sigma, int flags )
|
||||
{
|
||||
Mat prev0 = _prev0.getMat(), next0 = _next0.getMat();
|
||||
const int min_size = 32;
|
||||
const Mat* img[2] = { &prev0, &next0 };
|
||||
Mat fimg;
|
||||
|
||||
int i, k;
|
||||
double scale;
|
||||
Mat prevFlow, flow;
|
||||
Mat prevFlow, flow, fimg;
|
||||
|
||||
CV_Assert( prev0.size() == next0.size() && prev0.channels() == next0.channels() &&
|
||||
prev0.channels() == 1 && pyr_scale < 1 );
|
||||
flow0.create( prev0.size(), CV_32FC2 );
|
||||
_flow0.create( prev0.size(), CV_32FC2 );
|
||||
Mat flow0 = _flow0.getMat();
|
||||
|
||||
for( k = 0, scale = 1; k < levels; k++ )
|
||||
{
|
||||
@@ -643,7 +645,6 @@ void calcOpticalFlowFarneback( const Mat& prev0, const Mat& next0,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
CV_IMPL void cvCalcOpticalFlowFarneback(
|
||||
const CvArr* _prev, const CvArr* _next,
|
||||
|
||||
Reference in New Issue
Block a user