1
0
mirror of https://github.com/opencv/opencv_contrib.git synced 2025-10-20 21:40:49 +08:00

Added training part of the Global Patch Collider

This commit is contained in:
Vladislav Samsonov
2016-07-25 02:28:23 +03:00
parent 3dbbad123a
commit 7f93d951d3
4 changed files with 537 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
#include "opencv2/optflow.hpp"
#include <iostream>
const int nTrees = 5;
int main( int argc, const char **argv )
{
int nSequences = argc - 1;
if ( nSequences <= 0 || nSequences % 3 != 0 )
{
std::cerr << "Usage: " << argv[0] << " ImageFrom1 ImageTo1 GroundTruth1 ... ImageFromN ImageToN GroundTruthN" << std::endl;
return 1;
}
nSequences /= 3;
std::vector<cv::String> img1, img2, gt;
for ( int i = 0; i < nSequences; ++i )
{
img1.push_back( argv[1 + i * 3] );
img2.push_back( argv[1 + i * 3 + 1] );
gt.push_back( argv[1 + i * 3 + 2] );
}
cv::Ptr<cv::optflow::GPCTrainingSamples> ts = cv::optflow::GPCTrainingSamples::create( img1, img2, gt );
std::cout << "Got " << ts->size() << " samples." << std::endl;
cv::Ptr< cv::optflow::GPCForest<nTrees> > forest = cv::optflow::GPCForest<nTrees>::create();
forest->train( *ts );
forest->save( "forest.dump" );
return 0;
}