Commit 329f49e9 authored by Vladislav Samsonov's avatar Vladislav Samsonov

Passing of the prior file to the evaluation tool

parent f9ef5d45
......@@ -66,7 +66,7 @@ namespace optflow
* Solution will be regularized according to this prior.
* You need to generate appropriate prior file with "learn_prior.py" script beforehand.
*/
class PCAPrior
class CV_EXPORTS_W PCAPrior
{
private:
Mat L1;
......@@ -84,10 +84,10 @@ public:
void fillConstraints( float *A1, float *A2, float *b1, float *b2 ) const;
};
class OpticalFlowPCAFlow : public DenseOpticalFlow
class CV_EXPORTS_W OpticalFlowPCAFlow : public DenseOpticalFlow
{
protected:
const PCAPrior *prior;
const Ptr<const PCAPrior> prior;
const Size basisSize;
const float sparseRate; // (0 .. 0.1)
const float retainedCornersFraction; // [0 .. 1]
......@@ -95,7 +95,7 @@ protected:
const float dampingFactor;
public:
OpticalFlowPCAFlow( const PCAPrior *_prior = 0, const Size _basisSize = Size( 18, 14 ),
OpticalFlowPCAFlow( Ptr<const PCAPrior> _prior = Ptr<const PCAPrior>(), const Size _basisSize = Size( 18, 14 ),
float _sparseRate = 0.02, float _retainedCornersFraction = 0.7,
float _occlusionsThreshold = 0.0003, float _dampingFactor = 0.00002 );
......
......@@ -17,7 +17,8 @@ const String keys = "{help h usage ? | | print this message }"
"{m measure |endpoint| error measure - [endpoint or angular] }"
"{r region |all | region to compute stats about [all, discontinuities, untextured] }"
"{d display | | display additional info images (pauses program execution) }"
"{g gpu | | use OpenCL}";
"{g gpu | | use OpenCL}"
"{prior | | path to a prior file for PCAFlow}";
inline bool isFlowCorrect( const Point2f u )
{
......@@ -258,8 +259,15 @@ int main( int argc, char** argv )
algorithm = createOptFlow_DeepFlow();
else if ( method == "sparsetodenseflow" )
algorithm = createOptFlow_SparseToDense();
else if ( method == "pcaflow" )
algorithm = createOptFlow_PCAFlow();
else if ( method == "pcaflow" ) {
if ( parser.has("prior") ) {
String prior = parser.get<String>("prior");
printf("Using prior file: %s\n", prior.c_str());
algorithm = makePtr<OpticalFlowPCAFlow>(makePtr<PCAPrior>(prior.c_str()));
}
else
algorithm = createOptFlow_PCAFlow();
}
else if ( method == "DISflow" )
algorithm = createOptFlow_DIS();
else
......
......@@ -48,7 +48,7 @@ namespace cv
namespace optflow
{
OpticalFlowPCAFlow::OpticalFlowPCAFlow( const PCAPrior *_prior, const Size _basisSize, float _sparseRate,
OpticalFlowPCAFlow::OpticalFlowPCAFlow( Ptr<const PCAPrior> _prior, const Size _basisSize, float _sparseRate,
float _retainedCornersFraction, float _occlusionsThreshold,
float _dampingFactor )
: prior( _prior ), basisSize( _basisSize ), sparseRate( _sparseRate ),
......@@ -451,7 +451,7 @@ void OpticalFlowPCAFlow::calc( InputArray I0, InputArray I1, InputOutputArray fl
Mat flow = flowOut.getMat();
Mat w1, w2;
if ( prior )
if ( prior.get() )
{
Mat A1, A2, b1, b2;
getSystem( A1, A2, b1, b2, features, predictedFeatures, size );
......
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