forked from careylab/LocoMouse_cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
108 lines (78 loc) · 2.39 KB
/
main.cpp
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* LocoMouse C++ Version
Written by Joao Fayad (joaofayad@gmail.com)
*/
//OpenCV includes:
//#include <opencv2/core.hpp>
//#include <opencv2/imgproc.hpp>
//#include <opencv2/highgui.hpp>
#include <opencv2/core.hpp>
//Other C++ includes:
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <functional>
#include <map>
#include <exception>
#include <memory>
//LocoMouse includes:
#include "MyMat.hpp"
#include "Candidates.hpp"
#include "match2nd.h"
//FIXME: New classes merge with other classes
#include "LocoMouse_class.hpp"
#include "LocoMouse_Methods.hpp"
int main(int argc, char* argv[]) {
double t = (double) getTickCount();
int return_val = EXIT_SUCCESS;
try {
//Parsing the inputs:
LocoMouse_ParseInputs inputs = LocoMouse_ParseInputs(argc, argv);
//Initialize LocoMouse problem
std::unique_ptr<LocoMouse> L = LocoMouse_Initialize(inputs);
//Compute Bounding Box location accross video:
L->getBoundingBox();
L->initializeFeatureLoop();
//Compute per-frame candidate locations:
for (unsigned int i_frames = 0; i_frames < L->N_frames(); ++i_frames) {
//Read new image:
std::cout << "Before" << std::endl;
L->readFrame();
std::cout << "After" << std::endl;
//Crop image bounding boxes for both views:
L->cropBoundingBox();
// --- Detecting the Tail:
L->detectTail();
// --- Detecting Paw + Snout candidates for bottom view:
L->detectBottomCandidates();
// --- Computing Unary costs based on Location Prior:
L->computeUnaryCostsBottom();
// --- Computing Pairwise costs (Displacement between frames):
L->computePairwiseCostsBottom();
// --- Detecting Paw + Snout candidates for side view:
L->detectSideCandidates();
// --- Matching
L->matchBottomSideCandidates();
L->storePreviousImage();
}
//--- Paws + Snout tracks:
L->computeBottomTracks();
//Estimate corresponding Z coordinates:
L->computeSideTracks();
//--- Export results:
L->exportResults();
}
catch (std::invalid_argument e) {
std::cout << "Invalid inputs: " << e.what() << std::endl;
return_val = EXIT_FAILURE;
}
catch (std::runtime_error e) {
std::cout << "Runtime Error: " << e.what() << std::endl;
return_val = EXIT_FAILURE;
}
t = ((double)getTickCount() - t) / getTickFrequency();
std::cout << "Total Elapsed time: " << t << "s" << std::endl;
return return_val;
}