3939// ************************************************************************
4040// @HEADER
4141
42- /* ! \file DICe_CineToTiff .cpp
43- \brief Utility for exporting cine files to tiff files
42+ /* ! \file DICe_VideoStat .cpp
43+ \brief Utility for exporting video files to tiff files
4444*/
4545
4646#include < DICe.h>
@@ -69,8 +69,8 @@ int main(int argc, char *argv[]) {
6969 if (argc>=2 ){
7070 std::string help = argv[1 ];
7171 if (help==" -h" ||argc>2 ){
72- std::cout << " DICe_CineStat (writes a file with the cine index range) " << std::endl;
73- std::cout << " Syntax: DICe_CineStat <cine_file_name >" << std::endl;
72+ std::cout << " DICe_VideoStat (writes a file with the valid video index range) " << std::endl;
73+ std::cout << " Syntax: DICe_VideoStat <video_file_name >" << std::endl;
7474 exit (0 );
7575 }
7676 }
@@ -81,14 +81,25 @@ int main(int argc, char *argv[]) {
8181 DEBUG_MSG (argv[i]);
8282 }
8383 std::string fileName = argv[1 ];
84- *outStream << " Cine file name: " << fileName << std::endl;
85- Teuchos::RCP<hypercine::HyperCine> hc = DICe::utils::Video_Singleton::instance ().hypercine (fileName,hypercine::HyperCine::TO_8_BIT);
86- *outStream << " \n Cine read successfully\n " << std::endl;
87-
88- const int_t num_images = hc->file_frame_count ();
89- const int_t first_frame = hc->file_first_frame_id ();
90- const int_t last_frame = first_frame + num_images - 1 ;
91- const int_t frame_rate = hc->frame_rate ();
84+ *outStream << " Video file name: " << fileName << std::endl;
85+
86+ int_t num_images, first_frame, last_frame, frame_rate;
87+
88+ if (DICe::utils::is_cine_file (fileName)){
89+ Teuchos::RCP<hypercine::HyperCine> hc = DICe::utils::Video_Singleton::instance ().hypercine (fileName,hypercine::HyperCine::TO_8_BIT);
90+ *outStream << " \n Cine read successfully\n " << std::endl;
91+ num_images = hc->file_frame_count ();
92+ first_frame = hc->file_first_frame_id ();
93+ last_frame = first_frame + num_images - 1 ;
94+ frame_rate = hc->frame_rate ();
95+ }else {
96+ Teuchos::RCP<cv::VideoCapture> vc = DICe::utils::Video_Singleton::instance ().video_capture (fileName);
97+ *outStream << " \n Video read successfully\n " << std::endl;
98+ num_images = vc->get (cv::CAP_PROP_FRAME_COUNT);
99+ first_frame = 0 ;
100+ last_frame = first_frame + num_images - 1 ;
101+ frame_rate = vc->get (cv::CAP_PROP_FPS);
102+ }
92103
93104 *outStream << " Num frames: " << num_images << std::endl;
94105 *outStream << " First frame: " << first_frame << std::endl;
@@ -97,7 +108,7 @@ int main(int argc, char *argv[]) {
97108
98109 // write stats to file
99110 create_directory (" .dice" );
100- std::FILE * filePtr = fopen (" .dice/.cine_stats .dat" ," w" );
111+ std::FILE * filePtr = fopen (" .dice/.video_stats .dat" ," w" );
101112 fprintf (filePtr," %i %i %i %i\n " ,num_images,first_frame,last_frame,frame_rate);
102113 fclose (filePtr);
103114
0 commit comments