1. iorodeo
  2. bias

Commits

iorodeo  committed c581116

Added preview of background mediam image (to pluging preview window) for
debugging ufmf logger.

  • Participants
  • Parent commits e68addd
  • Branches default

Comments (0)

Files changed (7)

File src/gui/background_data_ufmf.cpp

View file
                 // Compute the median bin value
                 if ((cntTotal%2!=0) || ((cntHalf-(cntCurrent-binValue)) > 1))
                 {
-                    median = float(bin);
+                    median = float(bin-1);
                 }
                 else
                 {
-                    median = (float(bin)-0.5);
+                    median = (float(bin-1)-0.5);
                 }
 
+                // Median clamp - in case of values outside of range (shouldn't happen)
+                // --------------------------------------------------------------------
+                //median = (median < 0)   ?   0 : median;
+                //median = (median > 255) ? 255 : median;
+                //---------------------------------------------------------------------
+
                 // Adjust to get the median pixal value
                 median = medianScale*median + medianShift;
                 medianMat.at<uchar>(row,col) = uchar(median);
                 // Compute the median bin value
                 if ((cntTotal%2!=0) || ((cntHalf-(cntCurrent-binValue)) > 1))
                 {
-                    median = float(bin);
+                    median = float(bin-1);
                 }
                 else
                 {
-                    median = (float(bin)-0.5);
+                    median = (float(bin-1)-0.5);
                 }
 
                 // Adjust to get the median pixal value

File src/gui/background_histogram_ufmf.cpp

View file
     // ------------------------------------------------
     const unsigned int DEFAULT_NUM_BINS = 256;
     const unsigned int DEFAULT_BIN_SIZE = 1;
-    const unsigned int DEFAULT_MIN_UPDATE_COUNT = 50;
+    const unsigned int DEFAULT_MIN_UPDATE_COUNT = 100;
     // -------------------------------------------------
 
 

File src/gui/camera_window.cpp

View file
         imageDispatcherPtr_ -> releaseLock();
         // -------------------------------------------------------------------
 
+        // Debug  - display background median image from ufmf logger
+        // -------------------------------------------------------------------
+        if (videoFileFormat_ == VIDEOFILE_FORMAT_UFMF)
+        {
+            imageLoggerPtr_ -> acquireLock();
+            cv::Mat medianMat = imageLoggerPtr_ -> getBackgroundMedianImage();
+            QImage medianImg = matToQImage(medianMat);
+            imageLoggerPtr_ -> releaseLock();
+            if (!img.isNull())
+            {
+                pluginPixmapOriginal_ = QPixmap::fromImage(medianImg);
+            }
+        }
+        // -------------------------------------------------------------------
+
         // Set pixmaps and update image labels - note need to add pluginPixmap
         if (!img.isNull()) 
         {
         flipVert_ = false;
         flipHorz_ = false;
         imageRotation_ = IMAGE_ROTATION_0;
-        videoFileFormat_ = VIDEOFILE_FORMAT_FMF;
+        videoFileFormat_ = VIDEOFILE_FORMAT_UFMF;
 
         imageDisplayFreq_ = DEFAULT_IMAGE_DISPLAY_FREQ;
         cameraPtr_ = std::make_shared<Lockable<Camera>>(guid);

File src/gui/image_logger.cpp

View file
 #include <iostream>
 #include <opencv2/core/core.hpp>
 
+// Debug -----------------------
+#include "video_writer_ufmf.hpp"
+// -----------------------------
+
 namespace bias
 {
     const unsigned int MAX_LOG_QUEUE_SIZE = 1000;
         stopped_ = true;
     }
 
+    // Debug ----------------------------------------------------------------------------
+    cv::Mat ImageLogger::getBackgroundMedianImage()
+    {
+        // Very unsafe !!!!!
+        VideoWriter_ufmf *videoWriter_ufmf_Ptr = (VideoWriter_ufmf*) videoWriterPtr_.get();
+        return videoWriter_ufmf_Ptr -> getMedianImage();
+
+    }
+    // ----------------------------------------------------------------------------------
+
     void ImageLogger::run()
     {
         bool done = false;

File src/gui/image_logger.hpp

View file
 #include "camera_fwd.hpp"
 #include "lockable.hpp"
 
+// Debugging -------------------
+#include <opencv2/core/core.hpp>
+// -----------------------------
+
 class QString;
 
 
 
             void stop();
 
+            // Debugging ----------------------
+            cv::Mat getBackgroundMedianImage();
+            // --------------------------------
+
         signals:
             void imageLoggingError(unsigned int errorId, QString errorMsg);
 

File src/gui/video_writer_ufmf.cpp

View file
         frameCount_++;
     }
 
+    // Debug ----------------------------------------------------------------------------
+    cv::Mat VideoWriter_ufmf::getMedianImage()
+    {
+        return medianImage_;
+    }
+    // -----------------------------------------------------------------------------------
+
 
     void VideoWriter_ufmf::checkImageFormat(StampedImage stampedImg)
     {

File src/gui/video_writer_ufmf.hpp

View file
             virtual ~VideoWriter_ufmf();
             virtual void addFrame(StampedImage stampedImg);
 
+            // Debug ----------------
+            cv::Mat getMedianImage();
+            // ----------------------
+
             static const unsigned int MAX_THREAD_COUNT;
             static const unsigned int DEFAULT_FRAME_SKIP;
             static const QString DUMMY_FILENAME;
 
+
         protected:
 
             bool isFirst_;