mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-19 11:21:39 +08:00
Passing of the prior file to the evaluation tool
This commit is contained in:
@@ -66,7 +66,7 @@ namespace optflow
|
|||||||
* Solution will be regularized according to this prior.
|
* Solution will be regularized according to this prior.
|
||||||
* You need to generate appropriate prior file with "learn_prior.py" script beforehand.
|
* You need to generate appropriate prior file with "learn_prior.py" script beforehand.
|
||||||
*/
|
*/
|
||||||
class PCAPrior
|
class CV_EXPORTS_W PCAPrior
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
Mat L1;
|
Mat L1;
|
||||||
@@ -84,10 +84,10 @@ public:
|
|||||||
void fillConstraints( float *A1, float *A2, float *b1, float *b2 ) const;
|
void fillConstraints( float *A1, float *A2, float *b1, float *b2 ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpticalFlowPCAFlow : public DenseOpticalFlow
|
class CV_EXPORTS_W OpticalFlowPCAFlow : public DenseOpticalFlow
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
const PCAPrior *prior;
|
const Ptr<const PCAPrior> prior;
|
||||||
const Size basisSize;
|
const Size basisSize;
|
||||||
const float sparseRate; // (0 .. 0.1)
|
const float sparseRate; // (0 .. 0.1)
|
||||||
const float retainedCornersFraction; // [0 .. 1]
|
const float retainedCornersFraction; // [0 .. 1]
|
||||||
@@ -95,7 +95,7 @@ protected:
|
|||||||
const float dampingFactor;
|
const float dampingFactor;
|
||||||
|
|
||||||
public:
|
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 _sparseRate = 0.02, float _retainedCornersFraction = 0.7,
|
||||||
float _occlusionsThreshold = 0.0003, float _dampingFactor = 0.00002 );
|
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] }"
|
"{m measure |endpoint| error measure - [endpoint or angular] }"
|
||||||
"{r region |all | region to compute stats about [all, discontinuities, untextured] }"
|
"{r region |all | region to compute stats about [all, discontinuities, untextured] }"
|
||||||
"{d display | | display additional info images (pauses program execution) }"
|
"{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 )
|
inline bool isFlowCorrect( const Point2f u )
|
||||||
{
|
{
|
||||||
@@ -258,8 +259,15 @@ int main( int argc, char** argv )
|
|||||||
algorithm = createOptFlow_DeepFlow();
|
algorithm = createOptFlow_DeepFlow();
|
||||||
else if ( method == "sparsetodenseflow" )
|
else if ( method == "sparsetodenseflow" )
|
||||||
algorithm = createOptFlow_SparseToDense();
|
algorithm = createOptFlow_SparseToDense();
|
||||||
else if ( method == "pcaflow" )
|
else if ( method == "pcaflow" ) {
|
||||||
algorithm = createOptFlow_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" )
|
else if ( method == "DISflow" )
|
||||||
algorithm = createOptFlow_DIS();
|
algorithm = createOptFlow_DIS();
|
||||||
else
|
else
|
||||||
|
@@ -48,7 +48,7 @@ namespace cv
|
|||||||
namespace optflow
|
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 _retainedCornersFraction, float _occlusionsThreshold,
|
||||||
float _dampingFactor )
|
float _dampingFactor )
|
||||||
: prior( _prior ), basisSize( _basisSize ), sparseRate( _sparseRate ),
|
: prior( _prior ), basisSize( _basisSize ), sparseRate( _sparseRate ),
|
||||||
@@ -451,7 +451,7 @@ void OpticalFlowPCAFlow::calc( InputArray I0, InputArray I1, InputOutputArray fl
|
|||||||
Mat flow = flowOut.getMat();
|
Mat flow = flowOut.getMat();
|
||||||
|
|
||||||
Mat w1, w2;
|
Mat w1, w2;
|
||||||
if ( prior )
|
if ( prior.get() )
|
||||||
{
|
{
|
||||||
Mat A1, A2, b1, b2;
|
Mat A1, A2, b1, b2;
|
||||||
getSystem( A1, A2, b1, b2, features, predictedFeatures, size );
|
getSystem( A1, A2, b1, b2, features, predictedFeatures, size );
|
||||||
|
Reference in New Issue
Block a user