Advertisement
j0h

Untitled

j0h
Apr 26th, 2018
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.27 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h> //system commands
  3. #include <stdio.h>
  4. #include <ctime>    //time
  5. #include <string>   //Strings for file names
  6. #include <unistd.h> //sleep
  7. #include <cmath>    //math
  8.  
  9. using namespace std;
  10. using namespace cv;
  11.  
  12. /** Function Headers */
  13. int getframes(string inFile);
  14.  
  15.  
  16. /**@function main */
  17.     int main(int argc, char** argv) {
  18.     string inFile = "";
  19.     if (argc == 1){
  20.         inFile = "aabb.gif";
  21.         cout << "number of Farmes: "  << getframes(inFile)<< endl;
  22.         }
  23.     if( argc == 2 ) {
  24.       inFile = argv[1];
  25.       cout << getframes(inFile) << endl;
  26.       }
  27.       if(argc >= 3){
  28.       cout << "Usage: ./program InputFile \n \n This program converts gifs to png, that can be converted to gps srf files. \n";
  29.       return 1;
  30.     }
  31.    
  32.     return 0;
  33.     }
  34.    
  35. int getframes(string inFile){
  36.     system("rm /dev/shm/neu");       //stores system command output until I can put it in a varible.
  37.    
  38.     system(("identify -format \"%n\n\" " +inFile+ "| head -1 > /dev/shm/neu").c_str());
  39.    
  40.   FILE* file = fopen ("/dev/shm/neu", "r");
  41.   int i = 0;
  42.  
  43.   fscanf (file, "%d", &i);    
  44.   while (!feof (file)){  
  45.      fscanf (file, "%d", &i);  
  46.     }
  47.   //cout << "Number of frames in the file are: " << i <<endl;
  48.  fclose (file);        
  49. return i;
  50.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement