1. iorodeo
  2. bias

Commits

iorodeo  committed 35af2e8

Fixed some small issues with the video writers.

  • Participants
  • Parent commits 3ae4d27
  • Branches default

Comments (0)

Files changed (5)

File src/gui/camera_window.cpp

View file
  • Ignore whitespace
         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);

File src/gui/video_writer_avi.cpp

View file
  • Ignore whitespace
 
 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

File src/gui/video_writer_avi.hpp

View file
  • Ignore whitespace
             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);

File src/gui/video_writer_bmp.cpp

View file
  • Ignore whitespace
             {
                 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);
             }
         }

File src/gui/video_writer_fmf.cpp

View file
  • Ignore whitespace
         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