Commits

iorodeo committed 35af2e8

Fixed some small issues with the video writers.

Comments (0)

Files changed (5)

src/gui/camera_window.cpp

         flipVert_ = false;
         flipHorz_ = false;
         imageRotation_ = IMAGE_ROTATION_0;
-        videoFileFormat_ = VIDEOFILE_FORMAT_AVI;
+        videoFileFormat_ = VIDEOFILE_FORMAT_FMF;
 
         imageDisplayFreq_ = DEFAULT_IMAGE_DISPLAY_FREQ;
         cameraPtr_ = std::make_shared<Lockable<Camera>>(guid);

src/gui/video_writer_avi.cpp

 
 namespace bias
 { 
-    // ----------------------------------------------------------
-    // Temporary ... need to estimate this before starting video
-    const double DEFAULT_AVI_FPS = 30.0; 
-    // ----------------------------------------------------------
-
+    const int VideoWriter_avi::DEFAULT_FOURCC = CV_FOURCC('D','I','V','X');
+    const double VideoWriter_avi::DEFAULT_FPS = 30.0;
     const unsigned int VideoWriter_avi::DEFAULT_FRAME_SKIP = 5;
 
     VideoWriter_avi::VideoWriter_avi() : VideoWriter() 
     {
+        fourcc_ = DEFAULT_FOURCC;
+        fps_ = DEFAULT_FPS;
         isFirst_ = true;
         setFrameSkip(DEFAULT_FRAME_SKIP);
     }
 
     VideoWriter_avi::VideoWriter_avi(QString fileName) : VideoWriter(fileName)
     {
+        fourcc_ = DEFAULT_FOURCC;
+        fps_ = DEFAULT_FPS;
         isFirst_ = true;
         setFrameSkip(DEFAULT_FRAME_SKIP);
     }
 
     void VideoWriter_avi::initialize(StampedImage stampedImg)
     {
-        QString incrFileName = getUniqueFileName();
+        std::string incrFileName = getUniqueFileName().toStdString();
+        
+        setSize(stampedImg.image.size());
 
         try
         {
-            videoWriter_.open(
-                    incrFileName.toStdString(), 
-                    CV_FOURCC('D','I','V', 'X'), 
-                    DEFAULT_AVI_FPS, 
-                    stampedImg.image.size(), 
-                    false 
-                    );
+            videoWriter_.open(incrFileName,fourcc_,fps_,size_,false);
         }
         catch (cv::Exception &e)
         {
             errorMsg += "no exception thrown, but file not opened??";
             throw RuntimeError(errorId, errorMsg); 
         }
-        setSize(stampedImg.image.size());
     }
 
 } // namespace bias

src/gui/video_writer_avi.hpp

             virtual ~VideoWriter_avi();
             virtual void addFrame(StampedImage stampedImg);
 
+            static const int DEFAULT_FOURCC;
+            static const double DEFAULT_FPS;
             static const unsigned int DEFAULT_FRAME_SKIP;
 
         protected:
 
+            int fourcc_;
+            double fps_;
             bool isFirst_;
             cv::VideoWriter videoWriter_;
             void initialize(StampedImage stampedImage);

src/gui/video_writer_bmp.cpp

             {
                 cv::imwrite(fullPathName.toStdString(), stampedImg.image);
             }
-            catch (std::runtime_error &err)
+            catch (cv::Exception &exc)
             {
                 unsigned int errorId = ERROR_VIDEO_WRITER_ADD_FRAME;
                 std::string errorMsg("adding frame failed - "); 
-                errorMsg += err.what();
+                errorMsg += exc.what();
                 throw RuntimeError(errorId, errorMsg);
             }
         }

src/gui/video_writer_fmf.cpp

         uint32_t fmfVersion = uint32_t(FMF_VERSION);
         uint32_t width = uint32_t(size_.width);
         uint32_t height = uint32_t(size_.height);
-        uint64_t bytesPerChunk = uint64_t(width)*uint64_t(height) + uint64_t(8);
+        uint64_t bytesPerChunk = uint64_t(width)*uint64_t(height) + sizeof(double);
 
         // Add fmf header to file
         try 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.