EgoVideoStabilizer  1.0.0
execute_commands.h
Go to the documentation of this file.
1 //
4 // SemanticFastForward_EPIC@ECCVW is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // SemanticFastForward_JVCI is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with SemanticFastForward_EPIC@ECCVW. If not, see <http://www.gnu.org/licenses/>.
16 //
18 
26 #ifndef PROGRAM_H
27 #define PROGRAM_H
28 
29 #include <sstream>
30 #include <stdio.h>
31 
32 #define EXECUTE_INFO \
33  std::cout << std::endl \
34  << " ------------------------------------------------------------------ " << std::endl \
35  << " Video Stabilization." << std::endl \
36  << " --> Running Armadillo version: " << arma::arma_version::as_string() << std::endl \
37  << " --> Running OpenCV version: " << CV_VERSION << std::endl \
38  << " --> Project webpage (database, source code and results): " << std::endl \
39  << " \" www.verlab.dcc.ufmg.br/semantic_hyperlapse_project \" " << std::endl \
40  << " --> If you are using it to academic purposes, please cite: " << std::endl \
41  << " \" Autores. Titulo. Conferencia. Ano \" " << std::endl \
42  << " --> If you need help feel free to contact us: " << std::endl \
43  << " \" michel.silva66@gmail.com \" and \" washington.ramos@outlook.com \" " << std::endl \
44  << " --> Institution: " << std::endl \
45  << " VerLab @ Universidade Federal de Minas Gerais (UFMG), Brazil. " << std::endl \
46  << " ------------------------------------------------------------------ " << std::endl \
47  << std::endl;
48 
49 #define EXECUTE_EXPERIMENT_ID \
50  std::cout << std::endl \
51  << " Running exepriment: " << argv[1] << " | Experiment ID: " << experiment_settings.id << std::endl \
52  << std::endl; \
53 
54 #define EXECUTE_VIEW \
55  if ( VIEW ) { \
56  imshow( "Homography", result ); \
57  cv::waitKey(VIEW_DELAY); \
58  }
59 
60 #define EXECUTE_IMAGE_STUFFS( string_length , frame ) \
61  if ( FRAME_NUMBER_RESULT ) \
62  cv::putText(result, SSTR(std::setfill('0') << std::setw(string_length) << frame), cv::Point(150,150), cv::FONT_HERSHEY_TRIPLEX, 2.5, cv::Scalar(0,0,255)); \
63  if ( experiment_settings.save_video_in_disk ){ \
64  result = result( crop_area ); \
65  save_video << result; \
66  saved_frames++; \
67  } else { \
68  cv::rectangle( result , view_area , cv::Scalar(255,0,0) , 2 ) ; \
69  cv::rectangle( result , crop_area , cv::Scalar(0,255,0) , 2 ) ; \
70  cv::rectangle( result , drop_area , cv::Scalar(0,0,255) , 2 ) ; \
71  }
72 
73 #define EXECUTE_IMAGE_RECONSTRUCTION \
74  /*if ( ! imageReconstruction(result, selected_frames[i], experiment_settings, crop_area, reconstructed_frame) )*/ \
75  if ( ! imageReconstructionMask(current_frame , homography_matrix, selected_frames[i], experiment_settings, crop_area, reconstructed_frame) ) \
76  if ( DEBUG_FRAME_STATUS ) \
77  std::cout << " [!] Failled in reconstruct the image. " << std::endl; \
78  result = reconstructed_frame.clone(); \
79  num_of_reconstructed_frames++;
80 
81 #define EXECUTE_IMAGE_CONDITIONAL_ACTIONS \
82 if ( getAreaRatio( current_frame , homography_matrix , crop_area ) > MAXIMUM_AREA_ALLOWED ) { \
83  if ( getAreaRatio( current_frame , homography_matrix , drop_area ) > MAXIMUM_AREA_ALLOWED ) { \
84  log_file << " Frame : " << SSTR ( std::setfill('0') << std::setw(log_number_length) << i ) << " | [D] Dropped, a new one will be selected in the original video." << std::endl; \
85  if ( DEBUG_FRAME_STATUS ) \
86  std::cout << " i : " << SSTR ( std::setfill('0') << std::setw(log_number_length) << i ) << " | [D] Dropped, a new one will be selected in the original video." << std::endl; \
87  num_of_dropped_frames++; \
88  } else { \
89  log_file << " Frame : " << SSTR ( std::setfill('0') << std::setw(log_number_length) << i ) << " | [R] Reconstructed using the original video." << std::endl; \
90  if ( DEBUG_FRAME_STATUS ) \
91  std::cout << " i : " << SSTR ( std::setfill('0') << std::setw(log_number_length) << i ) << " | [R] Reconstructed using the original video." << std::endl; \
92  EXECUTE_IMAGE_RECONSTRUCTION \
93  } \
94 } else { \
95  log_file << " Frame : " << SSTR ( std::setfill('0') << std::setw(log_number_length) << i ) << " | [K] Kept." << std::endl; \
96  if ( DEBUG_FRAME_STATUS ) \
97  std::cout << " i : " << SSTR ( std::setfill('0') << std::setw(log_number_length) << i ) << " | [K] Kept." << std::endl; \
98  num_of_good_frames++; \
99 }
100 
101 #define SSTR( x ) static_cast< std::ostringstream & >( \
102  ( std::ostringstream() << std::dec << x ) ).str()
103 
104 #endif // PROGRAM_H
105