5 int main(
int argc,
char *argv[])
10 filename = filename.substr(filename.find_last_of(
'\\') + 1);
11 std::cout <<
"SampleMarkerlessCreator" << std::endl;
12 std::cout <<
"=======================" << std::endl;
13 std::cout << std::endl;
14 std::cout <<
"Description:" << std::endl;
15 std::cout <<
" This is an example of how to use the 'FernImageDetector' class" << std::endl;
16 std::cout <<
" to train a Fern classifier for markerless image-based tracking." << std::endl;
17 std::cout <<
" The image should contain many unique features and be in the range" << std::endl;
18 std::cout <<
" of 200x200 to 500x500 pixels. A '.dat' file will be saved in the" << std::endl;
19 std::cout <<
" same directory as the image and can be used with the" << std::endl;
20 std::cout <<
" SampleMarkerlessDetector sample." << std::endl;
21 std::cout << std::endl;
22 std::cout <<
"Usage:" << std::endl;
23 std::cout <<
" " << filename <<
" filename" << std::endl;
24 std::cout << std::endl;
25 std::cout <<
" filename filename of image to train" << std::endl;
26 std::cout << std::endl;
29 std::cout <<
"Filename not specified." << std::endl;
33 std::cout <<
"Training classifier." << std::endl;
35 std::string imageFilename(argv[1]);
36 fernDetector.
train(imageFilename);
38 std::cout <<
"Writing classifier." << std::endl;
39 std::string classifierFilename = imageFilename +
".dat";
40 if (!fernDetector.
write(classifierFilename)) {
41 std::cout <<
"Writing classifier failed." << std::endl;
47 catch (
const std::exception &e) {
48 std::cout <<
"Exception: " << e.what() << endl;
51 std::cout <<
"Exception: unknown" << std::endl;
This file implements a Fern-based image detector.
FernImageDetector fernDetector(true)
Image detector based on a Fern classifier.
int main(int argc, char *argv[])
bool write(const std::string &filename, const bool binary=true)
void train(const std::string &filename)