File: samplewriteconfigfile.cpp

package info (click to toggle)
opencv 4.5.1%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 268,248 kB
  • sloc: cpp: 969,170; xml: 682,525; python: 36,732; lisp: 30,170; java: 25,155; ansic: 7,927; javascript: 5,643; objc: 2,041; sh: 935; cs: 601; perl: 494; makefile: 145
file content (63 lines) | stat: -rw-r--r-- 3,214 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "opencv2/core.hpp"
#include <iostream>
#include <string>

using namespace cv;
using namespace std;
int main(int argc,const char ** argv){
  CommandLineParser parser(argc, argv,
        "{ help h usage ?             |      | give the following arguments in following format }"
        "{ filename f                 |.     | (required) path to file which you want to create as config file [example - /data/config.xml] }"
        "{ cascade_depth cd           |  10  | (required) This stores the depth of cascade of regressors used for training.}"
        "{ tree_depth td              |  4   | (required) This stores the depth of trees created as weak learners during gradient boosting.}"
        "{ num_trees_per_cascade_level|  500 | (required) This stores number of trees required per cascade level.}"
        "{ learning_rate              |  0.1 | (required) This stores the learning rate for gradient boosting.}"
        "{ oversampling_amount        |  20  | (required) This stores the oversampling amount for the samples.}"
        "{ num_test_coordinates       |  400 | (required) This stores number of test coordinates required for making the split.}"
        "{ lambda                     |  0.1 | (required) This stores the value used for calculating the probabilty.}"
        "{ num_test_splits            |  20  | (required) This stores the number of test splits to be generated before making the best split.}"
        );
    // Read in the input arguments
    if (parser.has("help")){
        parser.printMessage();
        cerr << "TIP: Use absolute paths to avoid any problems with the software!" << endl;
        return 0;
    }
    //These variables have been initialised as defined in the research paper "One millisecond face alignment" CVPR 2014
    int cascade_depth = 15;
    int tree_depth = 4;
    int num_trees_per_cascade_level = 500;
    float learning_rate = float(0.1);
    int oversampling_amount = 20;
    int num_test_coordinates = 400;
    float lambda = float(0.1);
    int num_test_splits = 20;

    cascade_depth = parser.get<int>("cascade_depth");
    tree_depth = parser.get<int>("tree_depth");
    num_trees_per_cascade_level = parser.get<int>("num_trees_per_cascade_level");
    learning_rate = parser.get<float>("learning_rate");
    oversampling_amount = parser.get<int>("oversampling_amount");
    num_test_coordinates = parser.get<int>("num_test_coordinates");
    lambda = parser.get<float>("lambda");
    num_test_splits = parser.get<int>("num_test_splits");
    string filename(parser.get<string>("filename"));
    FileStorage fs(filename, FileStorage::WRITE);
    if (!fs.isOpened())
    {
        cerr << "Failed to open " << filename << endl;
        parser.printMessage();
        return -1;
    }
    fs << "cascade_depth" << cascade_depth;
    fs << "tree_depth"<< tree_depth;
    fs << "num_trees_per_cascade_level" << num_trees_per_cascade_level;
    fs << "learning_rate" << learning_rate;
    fs << "oversampling_amount" << oversampling_amount;
    fs << "num_test_coordinates" << num_test_coordinates;
    fs << "lambda" << lambda ;
    fs << "num_test_splits"<< num_test_splits;
    fs.release();
    cout << "Write Done." << endl;
    return 0;
}