5454#include " metadata_input.h"
5555#include " metadata_reader.h"
5656#include " target.h"
57+ #include " camera.h"
5758
5859using namespace std ;
5960using namespace boost ;
@@ -87,6 +88,72 @@ MetadataInput *logReader = new MetadataInput();
8788double aveFrameTime = 1000 ;
8889int frameCount = 0 ;
8990
91+ double fisheyeMatrix[] = {
92+ 2.4052826789763981e+03 , 0 , 2000 ,
93+ 0 , 2.4052826789763981e+03 , 1500 ,
94+ 0 , 0 , 1
95+ };
96+
97+ double fisheyeDistortion[] = {
98+ -0.392 , 0.146 , 0 , 0 , -0.023
99+ };
100+
101+ double newFisheyeMatrix[] = {
102+ 2000 , 0 , 2000 ,
103+ 0 , 2000 , 1500 ,
104+ 0 , 0 , 1
105+ };
106+
107+ double rectMatrix[] = {
108+ 2410 , 0 , 960 ,
109+ 0 , 2410 , 540 ,
110+ 0 , 0 , 1
111+ };
112+
113+ double rectDistortion[] = {
114+ 0 , 0 , 0 , 0 , 0
115+ };
116+
117+ Camera goProFisheye (
118+ Size (4000 , 3000 ),
119+ Size2d(120 , 90 ),
120+ Mat(
121+ Size (3 , 3 ),
122+ CV_64F,
123+ fisheyeMatrix
124+ ),
125+ Mat(
126+ Size (5 , 1 ),
127+ CV_64F,
128+ fisheyeDistortion
129+ ),
130+ Mat(
131+ Size (3 , 3 ),
132+ CV_64F,
133+ newFisheyeMatrix
134+ )
135+ );
136+
137+ Camera goProRect (
138+ Size (1920 , 1080 ),
139+ Size2d(90 , 67.5 ),
140+ Mat(
141+ Size (3 , 3 ),
142+ CV_64F,
143+ rectMatrix
144+ ),
145+ Mat(
146+ Size (5 , 1 ),
147+ CV_64F,
148+ rectDistortion
149+ ),
150+ Mat(
151+ Size (3 , 3 ),
152+ CV_64F,
153+ rectMatrix
154+ )
155+ );
156+
90157struct State {
91158 bool hasImageSource;
92159 bool hasMetadataSource;
@@ -149,7 +216,6 @@ void output() {
149216 }
150217 boost::this_thread::sleep (boost::posix_time::milliseconds (30 ));
151218 }
152- ioService.stop ();
153219}
154220
155221void init () {
@@ -171,7 +237,7 @@ int main(int argc, char** argv) {
171237 processors = boost::thread::hardware_concurrency ();
172238
173239 while (!cin.eof ()) handle_input ();
174-
240+ ioService. stop ();
175241 threadpool.join_all ();
176242 delete logReader;
177243 return 0 ;
@@ -246,7 +312,7 @@ vector<Command> commands = {
246312 if (logReader->num_sources () == 0 ) {
247313 BOOST_LOG_TRIVIAL (error) << " Cannot add image source until a metadata source has been specified" ;
248314 } else {
249- importer.add_source (new PictureImport (args[0 ], logReader), stol (args[1 ]));
315+ importer.add_source (new PictureImport (args[0 ], logReader, goProFisheye ), stol (args[1 ]));
250316 newState.hasImageSource = true ;
251317 }
252318 }),
@@ -255,7 +321,7 @@ vector<Command> commands = {
255321 if (logReader->num_sources () == 0 ) {
256322 BOOST_LOG_TRIVIAL (error) << " Cannot add image source until a metadata source has been specified" ;
257323 } else {
258- importer.add_source (new DeckLinkImport (logReader), stol (args[0 ]));
324+ importer.add_source (new DeckLinkImport (logReader, goProRect ), stol (args[0 ]));
259325 newState.hasImageSource = true ;
260326 }
261327 }),
@@ -272,7 +338,9 @@ vector<Command> commands = {
272338void handle_state_change (State &newState) {
273339 if (!currentState.readingImages && newState.readingImages ) {
274340 if (newState.hasImageSource && newState.hasMetadataSource ) {
341+ currentState.readingImages = true ;
275342 queue_work (assign_workers);
343+ queue_work (output);
276344 } else {
277345 BOOST_LOG_TRIVIAL (error) << " Trying to read images without both image and metadata source is not supported" ;
278346 }
@@ -340,25 +408,29 @@ int handle_args(int argc, char** argv) {
340408
341409 if (vm.count (" telemetry" )) {
342410 logReader->add_source (new MetadataReader (*logReader, vm[" telemetry" ].as <string>()));
343- currentState.hasMetadataSource = true ;
411+ newState.hasMetadataSource = true ;
412+ cout << " Adding Telemetry source..." << endl;
344413 }
345414
346415 if (vm.count (" addr" ) && vm.count (" port" )) {
347416 logReader->add_source (new MetadataReader (*logReader, vm[" addr" ].as <string>(), vm[" port" ].as <string>()));
348417 newState.hasMetadataSource = true ;
418+ cout << " Adding Telemetry source..." << endl;
349419 }
350420
351421#ifdef HAS_DECKLINK
352422 if (vm.count (" decklink" )) {
353- importer.add_source (new DeckLinkImport (logReader), 500 );
423+ importer.add_source (new DeckLinkImport (logReader, goProRect ), 500 );
354424 newState.hasImageSource = true ;
425+ cout << " Adding video source..." << endl;
355426 }
356427#endif // HAS_DECKLINK
357428
358429 if (vm.count (" images" )) {
359430 string path = vm[" images" ].as <string>();
360- importer.add_source (new PictureImport (path, logReader), 0 );
431+ importer.add_source (new PictureImport (path, logReader, goProFisheye ), 0 );
361432 newState.hasImageSource = true ;
433+ cout << " Adding picture source..." << endl;
362434 }
363435
364436 if (vm.count (" output" )) {
0 commit comments