Commit beb7fc3c authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

a LOT of obsolete stuff has been moved to the legacy module.

parent 7e5726e2
......@@ -361,37 +361,6 @@ CVAPI(void) cvValidateDisparity( CvArr* disparity, const CvArr* cost,
int minDisparity, int numberOfDisparities,
int disp12MaxDiff CV_DEFAULT(1) );
/* Kolmogorov-Zabin stereo-correspondence algorithm (a.k.a. KZ1) */
#define CV_STEREO_GC_OCCLUDED SHRT_MAX
typedef struct CvStereoGCState
{
int Ithreshold;
int interactionRadius;
float K, lambda, lambda1, lambda2;
int occlusionCost;
int minDisparity;
int numberOfDisparities;
int maxIters;
CvMat* left;
CvMat* right;
CvMat* dispLeft;
CvMat* dispRight;
CvMat* ptrLeft;
CvMat* ptrRight;
CvMat* vtxBuf;
CvMat* edgeBuf;
} CvStereoGCState;
CVAPI(CvStereoGCState*) cvCreateStereoGCState( int numberOfDisparities, int maxIters );
CVAPI(void) cvReleaseStereoGCState( CvStereoGCState** state );
CVAPI(void) cvFindStereoCorrespondenceGC( const CvArr* left, const CvArr* right,
CvArr* disparityLeft, CvArr* disparityRight,
CvStereoGCState* state,
int useDisparityGuess CV_DEFAULT(0) );
/* Reprojects the computed disparity image to the 3D space using the specified 4x4 matrix */
CVAPI(void) cvReprojectImageTo3D( const CvArr* disparityImage,
CvArr* _3dImage, const CvMat* Q,
......
......@@ -706,73 +706,6 @@ protected:
}
};
//----------------------------------- StereoGC test -----------------------------------------------------
class CV_StereoGCTest : public CV_StereoMatchingTest
{
public:
CV_StereoGCTest()
{
name = "stereogc";
fill(rmsEps.begin(), rmsEps.end(), 3.f);
fracEps[0] = 0.05f; // all
fracEps[1] = 0.05f; // noOccl
fracEps[2] = 0.25f; // occl
fracEps[3] = 0.05f; // textured
fracEps[4] = 0.10f; // textureless
fracEps[5] = 0.10f; // borderedDepthDiscont
}
protected:
struct RunParams
{
int ndisp;
int iterCount;
};
vector<RunParams> caseRunParams;
virtual int readRunParams( FileStorage& fs )
{
int code = CV_StereoMatchingTest::readRunParams(fs);
FileNode fn = fs.getFirstTopLevelNode();
assert(fn.isSeq());
for( int i = 0; i < (int)fn.size(); i+=4 )
{
string caseName = fn[i], datasetName = fn[i+1];
RunParams params;
string ndisp = fn[i+2]; params.ndisp = atoi(ndisp.c_str());
string iterCount = fn[i+3]; params.iterCount = atoi(iterCount.c_str());
caseNames.push_back( caseName );
caseDatasets.push_back( datasetName );
caseRunParams.push_back( params );
}
return code;
}
virtual int runStereoMatchingAlgorithm( const Mat& _leftImg, const Mat& _rightImg,
Mat& leftDisp, Mat& rightDisp, int caseIdx )
{
RunParams params = caseRunParams[caseIdx];
assert( _leftImg.type() == CV_8UC3 && _rightImg.type() == CV_8UC3 );
Mat leftImg, rightImg, tmp;
cvtColor( _leftImg, leftImg, CV_BGR2GRAY );
cvtColor( _rightImg, rightImg, CV_BGR2GRAY );
leftDisp.create( leftImg.size(), CV_16SC1 );
rightDisp.create( rightImg.size(), CV_16SC1 );
CvMat _limg = leftImg, _rimg = rightImg, _ldisp = leftDisp, _rdisp = rightDisp;
CvStereoGCState *state = cvCreateStereoGCState( params.ndisp, params.iterCount );
cvFindStereoCorrespondenceGC( &_limg, &_rimg, &_ldisp, &_rdisp, state );
cvReleaseStereoGCState( &state );
leftDisp = - leftDisp;
return 0;
}
};
//----------------------------------- StereoSGBM test -----------------------------------------------------
class CV_StereoSGBMTest : public CV_StereoMatchingTest
......@@ -829,5 +762,4 @@ protected:
TEST(Calib3d_StereoBM, regression) { CV_StereoBMTest test; test.safe_run(); }
TEST(Calib3d_StereoGC, regression) { CV_StereoGCTest test; test.safe_run(); }
TEST(Calib3d_StereoSGBM, regression) { CV_StereoSGBMTest test; test.safe_run(); }
......@@ -442,6 +442,7 @@ void cv::Mesh3D::clearOctree(){ octree = Octree(); }
float cv::Mesh3D::estimateResolution(float tryRatio)
{
#if 0
const int neighbors = 3;
const int minReasonable = 10;
......@@ -475,8 +476,13 @@ float cv::Mesh3D::estimateResolution(float tryRatio)
sort(dist, less<double>());
return resolution = (float)dist[ dist.size() / 2 ];
#else
CV_Error(CV_StsNotImplemented, "");
return 1.f;
#endif
}
void cv::Mesh3D::computeNormals(float normalRadius, int minNeighbors)
{
buildOctree();
......
......@@ -155,109 +155,6 @@ void NearestNeighborTest::run( int /*start_from*/ ) {
ts->set_failed_test_info( code );
}
//--------------------------------------------------------------------------------
class CV_LSHTest : public NearestNeighborTest
{
public:
CV_LSHTest() {}
protected:
virtual void createModel( const Mat& data );
virtual int findNeighbors( Mat& points, Mat& neighbors );
virtual void releaseModel();
struct CvLSH* lsh;
CvMat desc;
};
void CV_LSHTest::createModel( const Mat& data )
{
desc = data;
lsh = cvCreateMemoryLSH( data.cols, data.rows, 70, 20, CV_32FC1 );
cvLSHAdd( lsh, &desc );
}
int CV_LSHTest::findNeighbors( Mat& points, Mat& neighbors )
{
const int emax = 20;
Mat dist( points.rows, neighbors.cols, CV_64FC1);
CvMat _dist = dist, _points = points, _neighbors = neighbors;
cvLSHQuery( lsh, &_points, &_neighbors, &_dist, neighbors.cols, emax );
return cvtest::TS::OK;
}
void CV_LSHTest::releaseModel()
{
cvReleaseLSH( &lsh );
}
//--------------------------------------------------------------------------------
class CV_FeatureTreeTest_C : public NearestNeighborTest
{
public:
CV_FeatureTreeTest_C() {}
protected:
virtual int findNeighbors( Mat& points, Mat& neighbors );
virtual void releaseModel();
CvFeatureTree* tr;
CvMat desc;
};
int CV_FeatureTreeTest_C::findNeighbors( Mat& points, Mat& neighbors )
{
const int emax = 20;
Mat dist( points.rows, neighbors.cols, CV_64FC1);
CvMat _dist = dist, _points = points, _neighbors = neighbors;
cvFindFeatures( tr, &_points, &_neighbors, &_dist, neighbors.cols, emax );
return cvtest::TS::OK;
}
void CV_FeatureTreeTest_C::releaseModel()
{
cvReleaseFeatureTree( tr );
}
//--------------------------------------
class CV_SpillTreeTest_C : public CV_FeatureTreeTest_C
{
public:
CV_SpillTreeTest_C() {}
protected:
virtual void createModel( const Mat& data );
};
void CV_SpillTreeTest_C::createModel( const Mat& data )
{
desc = data;
tr = cvCreateSpillTree( &desc );
}
//--------------------------------------
class CV_KDTreeTest_C : public CV_FeatureTreeTest_C
{
public:
CV_KDTreeTest_C() {}
protected:
virtual void createModel( const Mat& data );
virtual int checkFindBoxed();
};
void CV_KDTreeTest_C::createModel( const Mat& data )
{
desc = data;
tr = cvCreateKDTree( &desc );
}
int CV_KDTreeTest_C::checkFindBoxed()
{
Mat min(1, dims, CV_32FC1 ), max(1, dims, CV_32FC1 ), indices( 1, 1, CV_32SC1 );
float l = minValue, r = maxValue;
min.setTo(Scalar(l)), max.setTo(Scalar(r));
CvMat _min = min, _max = max, _indices = indices;
// TODO check indices
if( cvFindFeaturesBoxed( tr, &_min, &_max, &_indices ) != featuresCount )
return cvtest::TS::FAIL_BAD_ACCURACY;
return cvtest::TS::OK;
}
//--------------------------------------------------------------------------------
class CV_KDTreeTest_CPP : public NearestNeighborTest
{
......@@ -506,9 +403,6 @@ void CV_FlannSavedIndexTest::createModel(const cv::Mat &data)
remove( filename.c_str() );
}
TEST(Features2d_LSH, regression) { CV_LSHTest test; test.safe_run(); }
TEST(Features2d_SpillTree, regression) { CV_SpillTreeTest_C test; test.safe_run(); }
TEST(Features2d_KDTree_C, regression) { CV_KDTreeTest_C test; test.safe_run(); }
TEST(Features2d_KDTree_CPP, regression) { CV_KDTreeTest_CPP test; test.safe_run(); }
TEST(Features2d_FLANN_Linear, regression) { CV_FlannLinearIndexTest test; test.safe_run(); }
TEST(Features2d_FLANN_KMeans, regression) { CV_FlannKMeansIndexTest test; test.safe_run(); }
......
......@@ -1142,27 +1142,6 @@ protected:
}
// 2009-01-12, Xavier Delacour <xavier.delacour@gmail.com>
struct lsh_hash {
int h1, h2;
};
struct CvLSHOperations
{
virtual ~CvLSHOperations() {}
virtual int vector_add(const void* data) = 0;
virtual void vector_remove(int i) = 0;
virtual const void* vector_lookup(int i) = 0;
virtual void vector_reserve(int n) = 0;
virtual unsigned int vector_count() = 0;
virtual void hash_insert(lsh_hash h, int l, int i) = 0;
virtual void hash_remove(lsh_hash h, int l, int i) = 0;
virtual int hash_lookup(lsh_hash h, int l, int* ret_i, int ret_i_max) = 0;
};
#endif /* __cplusplus */
#endif
......
......@@ -121,15 +121,6 @@ CVAPI(CvMat**) cvCreatePyramid( const CvArr* img, int extra_layers, double rate,
CVAPI(void) cvReleasePyramid( CvMat*** pyramid, int extra_layers );
/* Splits color or grayscale image into multiple connected components
of nearly the same color/brightness using modification of Burt algorithm.
comp with contain a pointer to sequence (CvSeq)
of connected components (CvConnectedComp) */
CVAPI(void) cvPyrSegmentation( IplImage* src, IplImage* dst,
CvMemStorage* storage, CvSeq** comp,
int level, double threshold1,
double threshold2 );
/* Filters image using meanshift algorithm */
CVAPI(void) cvPyrMeanShiftFiltering( const CvArr* src, CvArr* dst,
double sp, double sr, int max_level CV_DEFAULT(1),
......@@ -351,99 +342,6 @@ CVAPI(void) cvStartReadChainPoints( CvChain* chain, CvChainPtReader* reader );
/* Retrieves the next chain point */
CVAPI(CvPoint) cvReadChainPoint( CvChainPtReader* reader );
/****************************************************************************************\
* Planar subdivisions *
\****************************************************************************************/
/* Initializes Delaunay triangulation */
CVAPI(void) cvInitSubdivDelaunay2D( CvSubdiv2D* subdiv, CvRect rect );
/* Creates new subdivision */
CVAPI(CvSubdiv2D*) cvCreateSubdiv2D( int subdiv_type, int header_size,
int vtx_size, int quadedge_size,
CvMemStorage* storage );
/************************* high-level subdivision functions ***************************/
/* Simplified Delaunay diagram creation */
CV_INLINE CvSubdiv2D* cvCreateSubdivDelaunay2D( CvRect rect, CvMemStorage* storage )
{
CvSubdiv2D* subdiv = cvCreateSubdiv2D( CV_SEQ_KIND_SUBDIV2D, sizeof(*subdiv),
sizeof(CvSubdiv2DPoint), sizeof(CvQuadEdge2D), storage );
cvInitSubdivDelaunay2D( subdiv, rect );
return subdiv;
}
/* Inserts new point to the Delaunay triangulation */
CVAPI(CvSubdiv2DPoint*) cvSubdivDelaunay2DInsert( CvSubdiv2D* subdiv, CvPoint2D32f pt);
/* Locates a point within the Delaunay triangulation (finds the edge
the point is left to or belongs to, or the triangulation point the given
point coinsides with */
CVAPI(CvSubdiv2DPointLocation) cvSubdiv2DLocate(
CvSubdiv2D* subdiv, CvPoint2D32f pt,
CvSubdiv2DEdge* edge,
CvSubdiv2DPoint** vertex CV_DEFAULT(NULL) );
/* Calculates Voronoi tesselation (i.e. coordinates of Voronoi points) */
CVAPI(void) cvCalcSubdivVoronoi2D( CvSubdiv2D* subdiv );
/* Removes all Voronoi points from the tesselation */
CVAPI(void) cvClearSubdivVoronoi2D( CvSubdiv2D* subdiv );
/* Finds the nearest to the given point vertex in subdivision. */
CVAPI(CvSubdiv2DPoint*) cvFindNearestPoint2D( CvSubdiv2D* subdiv, CvPoint2D32f pt );
/************ Basic quad-edge navigation and operations ************/
CV_INLINE CvSubdiv2DEdge cvSubdiv2DNextEdge( CvSubdiv2DEdge edge )
{
return CV_SUBDIV2D_NEXT_EDGE(edge);
}
CV_INLINE CvSubdiv2DEdge cvSubdiv2DRotateEdge( CvSubdiv2DEdge edge, int rotate )
{
return (edge & ~3) + ((edge + rotate) & 3);
}
CV_INLINE CvSubdiv2DEdge cvSubdiv2DSymEdge( CvSubdiv2DEdge edge )
{
return edge ^ 2;
}
CV_INLINE CvSubdiv2DEdge cvSubdiv2DGetEdge( CvSubdiv2DEdge edge, CvNextEdgeType type )
{
CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3);
edge = e->next[(edge + (int)type) & 3];
return (edge & ~3) + ((edge + ((int)type >> 4)) & 3);
}
CV_INLINE CvSubdiv2DPoint* cvSubdiv2DEdgeOrg( CvSubdiv2DEdge edge )
{
CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3);
return (CvSubdiv2DPoint*)e->pt[edge & 3];
}
CV_INLINE CvSubdiv2DPoint* cvSubdiv2DEdgeDst( CvSubdiv2DEdge edge )
{
CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3);
return (CvSubdiv2DPoint*)e->pt[(edge + 2) & 3];
}
CV_INLINE double cvTriangleArea( CvPoint2D32f a, CvPoint2D32f b, CvPoint2D32f c )
{
return ((double)b.x - a.x) * ((double)c.y - a.y) - ((double)b.y - a.y) * ((double)c.x - a.x);
}
/****************************************************************************************\
* Contour Processing and Shape Analysis *
......@@ -718,61 +616,6 @@ CVAPI(CvSeq*) cvHoughCircles( CvArr* image, void* circle_storage,
CVAPI(void) cvFitLine( const CvArr* points, int dist_type, double param,
double reps, double aeps, float* line );
/* Constructs kd-tree from set of feature descriptors */
CVAPI(struct CvFeatureTree*) cvCreateKDTree(CvMat* desc);
/* Constructs spill-tree from set of feature descriptors */
CVAPI(struct CvFeatureTree*) cvCreateSpillTree( const CvMat* raw_data,
const int naive CV_DEFAULT(50),
const double rho CV_DEFAULT(.7),
const double tau CV_DEFAULT(.1) );
/* Release feature tree */
CVAPI(void) cvReleaseFeatureTree(struct CvFeatureTree* tr);
/* Searches feature tree for k nearest neighbors of given reference points,
searching (in case of kd-tree/bbf) at most emax leaves. */
CVAPI(void) cvFindFeatures(struct CvFeatureTree* tr, const CvMat* query_points,
CvMat* indices, CvMat* dist, int k, int emax CV_DEFAULT(20));
/* Search feature tree for all points that are inlier to given rect region.
Only implemented for kd trees */
CVAPI(int) cvFindFeaturesBoxed(struct CvFeatureTree* tr,
CvMat* bounds_min, CvMat* bounds_max,
CvMat* out_indices);
/* Construct a Locality Sensitive Hash (LSH) table, for indexing d-dimensional vectors of
given type. Vectors will be hashed L times with k-dimensional p-stable (p=2) functions. */
CVAPI(struct CvLSH*) cvCreateLSH(struct CvLSHOperations* ops, int d,
int L CV_DEFAULT(10), int k CV_DEFAULT(10),
int type CV_DEFAULT(CV_64FC1), double r CV_DEFAULT(4),
int64 seed CV_DEFAULT(-1));
/* Construct in-memory LSH table, with n bins. */
CVAPI(struct CvLSH*) cvCreateMemoryLSH(int d, int n, int L CV_DEFAULT(10), int k CV_DEFAULT(10),
int type CV_DEFAULT(CV_64FC1), double r CV_DEFAULT(4),
int64 seed CV_DEFAULT(-1));
/* Free the given LSH structure. */
CVAPI(void) cvReleaseLSH(struct CvLSH** lsh);
/* Return the number of vectors in the LSH. */
CVAPI(unsigned int) LSHSize(struct CvLSH* lsh);
/* Add vectors to the LSH structure, optionally returning indices. */
CVAPI(void) cvLSHAdd(struct CvLSH* lsh, const CvMat* data, CvMat* indices CV_DEFAULT(0));
/* Remove vectors from LSH, as addressed by given indices. */
CVAPI(void) cvLSHRemove(struct CvLSH* lsh, const CvMat* indices);
/* Query the LSH n times for at most k nearest points; data is n x d,
indices and dist are n x k. At most emax stored points will be accessed. */
CVAPI(void) cvLSHQuery(struct CvLSH* lsh, const CvMat* query_points,
CvMat* indices, CvMat* dist, int k, int emax);
#ifdef __cplusplus
}
#endif
......
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// Intel License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of Intel Corporation may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#ifndef _CV_IMG_PROC_H_
#define _CV_IMG_PROC_H_
#endif /*_CV_INTERNAL_H_*/
......@@ -108,22 +108,6 @@ icvIntersectLines( double x1, double dx1, double y1, double dy1,
}
void
icvCreateCenterNormalLine( CvSubdiv2DEdge edge, double *_a, double *_b, double *_c )
{
CvPoint2D32f org = cvSubdiv2DEdgeOrg( edge )->pt;
CvPoint2D32f dst = cvSubdiv2DEdgeDst( edge )->pt;
double a = dst.x - org.x;
double b = dst.y - org.y;
double c = -(a * (dst.x + org.x) + b * (dst.y + org.y));
*_a = a + a;
*_b = b + b;
*_c = c;
}
void
icvIntersectLines3( double *a0, double *b0, double *c0,
double *a1, double *b1, double *c1, CvPoint2D32f * point )
......
This diff is collapsed.
......@@ -6,3 +6,5 @@ legacy. Deprecated stuff
.. toctree::
:maxdepth: 2
motion_analysis
Motion Analysis
===============
.. highlight:: cpp
CalcOpticalFlowBM
-----------------
Calculates the optical flow for two images by using the block matching method.
.. ocv:cfunction:: void cvCalcOpticalFlowBM( const CvArr* prev, const CvArr* curr, CvSize blockSize, CvSize shiftSize, CvSize maxRange, int usePrevious, CvArr* velx, CvArr* vely )
.. ocv:pyoldfunction:: cv.CalcOpticalFlowBM(prev, curr, blockSize, shiftSize, maxRange, usePrevious, velx, vely)-> None
:param prev: First image, 8-bit, single-channel
:param curr: Second image, 8-bit, single-channel
:param blockSize: Size of basic blocks that are compared
:param shiftSize: Block coordinate increments
:param maxRange: Size of the scanned neighborhood in pixels around the block
:param usePrevious: Flag that specifies whether to use the input velocity as initial approximations or not.
:param velx: Horizontal component of the optical flow of
.. math::
\left \lfloor \frac{\texttt{prev->width} - \texttt{blockSize.width}}{\texttt{shiftSize.width}} \right \rfloor \times \left \lfloor \frac{\texttt{prev->height} - \texttt{blockSize.height}}{\texttt{shiftSize.height}} \right \rfloor
size, 32-bit floating-point, single-channel
:param vely: Vertical component of the optical flow of the same size ``velx`` , 32-bit floating-point, single-channel
The function calculates the optical flow for overlapped blocks ``blockSize.width x blockSize.height`` pixels each, thus the velocity fields are smaller than the original images. For every block in ``prev``
the functions tries to find a similar block in ``curr`` in some neighborhood of the original block or shifted by ``(velx(x0,y0), vely(x0,y0))`` block as has been calculated by previous function call (if ``usePrevious=1``)
CalcOpticalFlowHS
-----------------
Calculates the optical flow for two images using Horn-Schunck algorithm.
.. ocv:cfunction:: void cvCalcOpticalFlowHS(const CvArr* prev, const CvArr* curr, int usePrevious, CvArr* velx, CvArr* vely, double lambda, CvTermCriteria criteria)
.. ocv:pyoldfunction:: cv.CalcOpticalFlowHS(prev, curr, usePrevious, velx, vely, lambda, criteria)-> None
:param prev: First image, 8-bit, single-channel
:param curr: Second image, 8-bit, single-channel
:param usePrevious: Flag that specifies whether to use the input velocity as initial approximations or not.
:param velx: Horizontal component of the optical flow of the same size as input images, 32-bit floating-point, single-channel
:param vely: Vertical component of the optical flow of the same size as input images, 32-bit floating-point, single-channel
:param lambda: Smoothness weight. The larger it is, the smoother optical flow map you get.
:param criteria: Criteria of termination of velocity computing
The function computes the flow for every pixel of the first input image using the Horn and Schunck algorithm [Horn81]_. The function is obsolete. To track sparse features, use :ocv:func:`calcOpticalFlowPyrLK`. To track all the pixels, use :ocv:func:`calcOpticalFlowFarneback`.
CalcOpticalFlowLK
-----------------
Calculates the optical flow for two images using Lucas-Kanade algorithm.
.. ocv:cfunction:: void cvCalcOpticalFlowLK( const CvArr* prev, const CvArr* curr, CvSize winSize, CvArr* velx, CvArr* vely )
.. ocv:pyoldfunction:: cv.CalcOpticalFlowLK(prev, curr, winSize, velx, vely)-> None
:param prev: First image, 8-bit, single-channel
:param curr: Second image, 8-bit, single-channel
:param winSize: Size of the averaging window used for grouping pixels
:param velx: Horizontal component of the optical flow of the same size as input images, 32-bit floating-point, single-channel
:param vely: Vertical component of the optical flow of the same size as input images, 32-bit floating-point, single-channel
The function computes the flow for every pixel of the first input image using the Lucas and Kanade algorithm [Lucas81]_. The function is obsolete. To track sparse features, use :ocv:func:`calcOpticalFlowPyrLK`. To track all the pixels, use :ocv:func:`calcOpticalFlowFarneback`.
This diff is collapsed.
This diff is collapsed.
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "test_precomp.hpp"
#include <algorithm>
#include <vector>
#include <iostream>
using namespace cv;
using namespace cv::flann;
//--------------------------------------------------------------------------------
class NearestNeighborTest : public cvtest::BaseTest
{
public:
NearestNeighborTest() {}
protected:
static const int minValue = 0;
static const int maxValue = 1;
static const int dims = 30;
static const int featuresCount = 2000;
static const int K = 1; // * should also test 2nd nn etc.?
virtual void run( int start_from );
virtual void createModel( const Mat& data ) = 0;
virtual int findNeighbors( Mat& points, Mat& neighbors ) = 0;
virtual int checkGetPoins( const Mat& data );
virtual int checkFindBoxed();
virtual int checkFind( const Mat& data );
virtual void releaseModel() = 0;
};
int NearestNeighborTest::checkGetPoins( const Mat& )
{
return cvtest::TS::OK;
}
int NearestNeighborTest::checkFindBoxed()
{
return cvtest::TS::OK;
}
int NearestNeighborTest::checkFind( const Mat& data )
{
int code = cvtest::TS::OK;
int pointsCount = 1000;
float noise = 0.2f;
RNG rng;
Mat points( pointsCount, dims, CV_32FC1 );
Mat results( pointsCount, K, CV_32SC1 );
std::vector<int> fmap( pointsCount );
for( int pi = 0; pi < pointsCount; pi++ )
{
int fi = rng.next() % featuresCount;
fmap[pi] = fi;
for( int d = 0; d < dims; d++ )
points.at<float>(pi, d) = data.at<float>(fi, d) + rng.uniform(0.0f, 1.0f) * noise;
}
code = findNeighbors( points, results );
if( code == cvtest::TS::OK )
{
int correctMatches = 0;
for( int pi = 0; pi < pointsCount; pi++ )
{
if( fmap[pi] == results.at<int>(pi, 0) )
correctMatches++;
}
double correctPerc = correctMatches / (double)pointsCount;
if (correctPerc < .75)
{
ts->printf( cvtest::TS::LOG, "correct_perc = %d\n", correctPerc );
code = cvtest::TS::FAIL_BAD_ACCURACY;
}
}
return code;
}
void NearestNeighborTest::run( int /*start_from*/ ) {
int code = cvtest::TS::OK, tempCode;
Mat desc( featuresCount, dims, CV_32FC1 );
randu( desc, Scalar(minValue), Scalar(maxValue) );
createModel( desc );
tempCode = checkGetPoins( desc );
if( tempCode != cvtest::TS::OK )
{
ts->printf( cvtest::TS::LOG, "bad accuracy of GetPoints \n" );
code = tempCode;
}
tempCode = checkFindBoxed();
if( tempCode != cvtest::TS::OK )
{
ts->printf( cvtest::TS::LOG, "bad accuracy of FindBoxed \n" );
code = tempCode;
}
tempCode = checkFind( desc );
if( tempCode != cvtest::TS::OK )
{
ts->printf( cvtest::TS::LOG, "bad accuracy of Find \n" );
code = tempCode;
}
releaseModel();
ts->set_failed_test_info( code );
}
//--------------------------------------------------------------------------------
class CV_LSHTest : public NearestNeighborTest
{
public:
CV_LSHTest() {}
protected:
virtual void createModel( const Mat& data );
virtual int findNeighbors( Mat& points, Mat& neighbors );
virtual void releaseModel();
struct CvLSH* lsh;
CvMat desc;
};
void CV_LSHTest::createModel( const Mat& data )
{
desc = data;
lsh = cvCreateMemoryLSH( data.cols, data.rows, 70, 20, CV_32FC1 );
cvLSHAdd( lsh, &desc );
}
int CV_LSHTest::findNeighbors( Mat& points, Mat& neighbors )
{
const int emax = 20;
Mat dist( points.rows, neighbors.cols, CV_64FC1);
CvMat _dist = dist, _points = points, _neighbors = neighbors;
cvLSHQuery( lsh, &_points, &_neighbors, &_dist, neighbors.cols, emax );
return cvtest::TS::OK;
}
void CV_LSHTest::releaseModel()
{
cvReleaseLSH( &lsh );
}
//--------------------------------------------------------------------------------
class CV_FeatureTreeTest_C : public NearestNeighborTest
{
public:
CV_FeatureTreeTest_C() {}
protected:
virtual int findNeighbors( Mat& points, Mat& neighbors );
virtual void releaseModel();
CvFeatureTree* tr;
CvMat desc;
};
int CV_FeatureTreeTest_C::findNeighbors( Mat& points, Mat& neighbors )
{
const int emax = 20;
Mat dist( points.rows, neighbors.cols, CV_64FC1);
CvMat _dist = dist, _points = points, _neighbors = neighbors;
cvFindFeatures( tr, &_points, &_neighbors, &_dist, neighbors.cols, emax );
return cvtest::TS::OK;
}
void CV_FeatureTreeTest_C::releaseModel()
{
cvReleaseFeatureTree( tr );
}
//--------------------------------------
class CV_SpillTreeTest_C : public CV_FeatureTreeTest_C
{
public:
CV_SpillTreeTest_C() {}
protected:
virtual void createModel( const Mat& data );
};
void CV_SpillTreeTest_C::createModel( const Mat& data )
{
desc = data;
tr = cvCreateSpillTree( &desc );
}
//--------------------------------------
class CV_KDTreeTest_C : public CV_FeatureTreeTest_C
{
public:
CV_KDTreeTest_C() {}
protected:
virtual void createModel( const Mat& data );
virtual int checkFindBoxed();
};
void CV_KDTreeTest_C::createModel( const Mat& data )
{
desc = data;
tr = cvCreateKDTree( &desc );
}
int CV_KDTreeTest_C::checkFindBoxed()
{
Mat min(1, dims, CV_32FC1 ), max(1, dims, CV_32FC1 ), indices( 1, 1, CV_32SC1 );
float l = minValue, r = maxValue;
min.setTo(Scalar(l)), max.setTo(Scalar(r));
CvMat _min = min, _max = max, _indices = indices;
// TODO check indices
if( cvFindFeaturesBoxed( tr, &_min, &_max, &_indices ) != featuresCount )
return cvtest::TS::FAIL_BAD_ACCURACY;
return cvtest::TS::OK;
}
TEST(Features2d_LSH, regression) { CV_LSHTest test; test.safe_run(); }
TEST(Features2d_SpillTree, regression) { CV_SpillTreeTest_C test; test.safe_run(); }
TEST(Features2d_KDTree_C, regression) { CV_KDTreeTest_C test; test.safe_run(); }
......@@ -41,6 +41,7 @@
//M*/
#include "test_precomp.hpp"
#include "opencv2/video/tracking.hpp"
#include <string>
#include <iostream>
......
......@@ -6,6 +6,7 @@
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/highgui/highgui_c.h"
#include "opencv2/legacy/legacy.hpp"
#include <iostream>
#endif
This diff is collapsed.
This diff is collapsed.
......@@ -60,21 +60,6 @@ extern "C" {
/************************************ optical flow ***************************************/
/* Calculates optical flow for 2 images using classical Lucas & Kanade algorithm */
CVAPI(void) cvCalcOpticalFlowLK( const CvArr* prev, const CvArr* curr,
CvSize win_size, CvArr* velx, CvArr* vely );
/* Calculates optical flow for 2 images using block matching algorithm */
CVAPI(void) cvCalcOpticalFlowBM( const CvArr* prev, const CvArr* curr,
CvSize block_size, CvSize shift_size,
CvSize max_range, int use_previous,
CvArr* velx, CvArr* vely );
/* Calculates Optical flow for 2 images using Horn & Schunck algorithm */
CVAPI(void) cvCalcOpticalFlowHS( const CvArr* prev, const CvArr* curr,
int use_previous, CvArr* velx, CvArr* vely,
double lambda, CvTermCriteria criteria );
#define CV_LKFLOW_PYR_A_READY 1
#define CV_LKFLOW_PYR_B_READY 2
#define CV_LKFLOW_INITIAL_GUESSES 4
......
This diff is collapsed.
This diff is collapsed.
......@@ -24,6 +24,7 @@
#include "opencv2/video/background_segm.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/legacy/legacy.hpp"
#include <stdio.h>
#include <stdlib.h>
......
#include "opencv2/video/background_segm.hpp"
#include "opencv2/legacy/blobtrack.hpp"
#include "opencv2/legacy/legacy.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <opencv2/imgproc/imgproc_c.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment