1. iorodeo
  2. bias

Commits

iorodeo  committed d53bab2

Finished modifying flysorter so that it can create training data in batch mode
from directories of cropped images.

  • Participants
  • Parent commits 2fc825c
  • Branches default

Comments (0)

Files changed (3)

File src/demo/fly_sorter/fly_sorter_window.cpp

View file
             }
             else
             {
-
                 // Batch trainging mode
 
                 if (isCaptureModeFile())
                         return rtnStatus;
                     }
                     batchVideoFileIndex_ = 0;
-                    setupBatchDataWrite();
                 }
                 else 
                 {
                         return rtnStatus;
                     }
                     batchVideoDirIndex_ = 0;
-                    setupBatchDataWrite();  // Check that is is the correct thing to do
-                    
-                    // DEVEL
-                    //  -------------------------------------------
-                    rtnStatus.success = false;
-                    rtnStatus.message = QString("Devel stop");
-                    return rtnStatus;
-                    // --------------------------------------------
                 }
-
+                setupBatchDataWrite();
             }
         }
         else
         ImageGrabberParam imageGrabberParam = param_.imageGrabber;
         if (createTrainingData() && isTrainingDataModeBatch())
         {
-            imageGrabberParam.captureInputFile = batchVideoFileList_[batchVideoFileIndex_];
+            if (isCaptureModeFile())
+            {
+                imageGrabberParam.captureInputFile = batchVideoFileList_[batchVideoFileIndex_];
+            }
+            else
+            {
+                imageGrabberParam.captureInputDir = batchVideoDirList_[batchVideoDirIndex_];
+            }
         }
         imageGrabberPtr_ = new ImageGrabber(imageGrabberParam); 
 
 
         if (createTrainingData() && isTrainingDataModeBatch() && !stopRunningFlag_)
         {
-            batchVideoFileIndex_++;
-            if (batchVideoFileIndex_ < batchVideoFileList_.size())
+            bool batchComplete = false;
+
+            if (isCaptureModeFile())
             {
+                batchVideoFileIndex_++;
+                if (batchVideoFileIndex_ >= batchVideoFileList_.size())
+                {
+                    batchComplete = true;
+                }
+            }
+            else
+            {
+                batchVideoDirIndex_++;
+                if (batchVideoDirIndex_ >= batchVideoDirList_.size())
+                {
+                    batchComplete = true;
+                }
+            }
+
+            if (!batchComplete)
+            { 
                 setupBatchDataWrite();
                 running_ = false;
                 startImageCapture();
     }
     else
     {
-        videoPrefix = name;
+        videoPrefix = QDir(name).dirName(); 
     }
 
     QDir dataDir = QDir(baseDir.absolutePath() + "/" + videoPrefix);

File src/demo/fly_sorter/hog_position_fitter.cpp

View file
             posData.success = true;
             fitterData.positionDataList.push_back(posData); 
 
+            std::cout << "write training data: " << writeTrainingData_ << std::endl;
             if (writeTrainingData_)
             {
                 createTrainingData(frameCount, posData, rotBoundingImageLUV);
         cv::Mat img
         )
 {
+    std::cout << "createTrainingData" << std::endl;
+
     // Create base file name
     std::stringstream baseNameStream;
     baseNameStream << trainingFileNamePrefix_;
     baseNameStream << "_id_"    << posData.segmentData.blobData.id;
     std::string baseName = baseNameStream.str();
 
+    std::cout << "baseName: " << baseName << std::endl;
+
     // Write unflipped pixel feature vector
     std::stringstream fileNameStream;
     fileNameStream << baseName << "_flipxy_00.txt";

File src/demo/fly_sorter/image_grabber.cpp

View file
 
 void ImageGrabber::runCaptureFromDir()
 {
-    float sleepDt = 0.5*1.0e3/param_.frameRate;
+    float sleepDt = 1.0e3/param_.frameRate;
     unsigned long fileCount = 0;
 
     // Check that capture directory exists
     QDir captureInputDir = QDir(param_.captureInputDir);
-    std::cout << "captureInputDir: " << captureInputDir.absolutePath().toStdString() << std::endl;
+    //std::cout << "captureInputDir: " << captureInputDir.absolutePath().toStdString() << std::endl;
     if (!captureInputDir.exists())
     {
         QString dirStr = captureInputDir.absolutePath();
         int frameNumber = frameNumberIt.next();
         QFileInfo fileInfo = frameNumberToFileInfoMap[frameNumber];
         QString fileName = fileInfo.absoluteFilePath();
-        std::cout  << "count: " << fileCount << ", fileName " << fileName.toStdString(); 
+        //std::cout  << "count: " << fileCount << ", fileName " << fileName.toStdString(); 
 
         // Filter out undesired values
         if (!frameNumberFilterMap.contains(frameNumber))
         bool filterValue = frameNumberFilterMap[frameNumber];
         if (!filterValue)
         {
-            std::cout << " - skipped (filtered)" << std::endl;
+            //std::cout << " - skipped (filtered)" << std::endl;
             continue;
         }
 
         // Make sure file exists
         if (!fileInfo.exists())
         {
-            std::cout <<" - skipped (doesn't exist)" << std::endl;
+            //std::cout <<" - skipped (doesn't exist)" << std::endl;
             continue;
         }
-        std::cout << std::endl;
+        //std::cout << std::endl;
 
 
         // Read image from file