Commits

iorodeo committed 31bac60

Modified http output - added outofbounds, old, types.

Comments (0)

Files changed (9)

src/demo/fly_sorter/fly_sorter_window.cpp

 
 void FlySorterWindow::updateDisplayOnTimer()
 {
+    //GenderDataList genderDataList = genderSorterData_.genderDataList;
+    //GenderDataList::iterator it;
+    //for (it=genderDataList.begin(); it!=genderDataList.end(); it++)
+    //{
+    //    GenderData genderData = *it;
+    //    if ((genderData.gender == MALE) || (genderData.gender == FEMALE))
+    //    {
+    //        int x = int(genderData.positionData.meanXAbs);
+    //        int y = int(genderData.positionData.meanYAbs);
+    //        std::string letter = GenderSorter::GenderToLetter(genderData.gender);
+    //        cv::putText(
+    //                blobFinderData_.blobDataImage, 
+    //                letter, 
+    //                cv::Point(x,y),
+    //                cv::FONT_HERSHEY_SIMPLEX,
+    //                2.0,
+    //                cv::Scalar(0,0,255),
+    //                1,
+    //                CV_AA
+    //                );
+    //    }
+    //}
+
     QImage previewImage = matToQImage(blobFinderData_.blobDataImage);
     if (!previewImage.isNull()) 
     {
     int numOkBlobs = getNumberOkItems(blobFinderData_.blobDataList);
     dataMap.insert("ndetections", numOkBlobs);
     
+    MotionDirection direction = param_.identityTracker.motionDirection;
     GenderDataList genderDataList = genderSorterData_.genderDataList;
     GenderDataList::iterator it;
     QVariantList detectionList;
     for (it=genderDataList.begin(); it!=genderDataList.end(); it++)
     {
         GenderData genderData = *it;
-
-        bool isOnBorder = genderData.positionData.segmentData.blobData.isOnBorder();
-        bool success = genderData.positionData.success;
-
-        if (isOnBorder ) 
-        {
-            // Throw away data on the border.
-            continue;
-        }
-
-        QVariantMap detectionMap;
-
-        QString genderString = QString::fromStdString( 
-                GenderSorter::GenderToString(genderData.gender)
-                );
-
+        BlobData blobData = genderData.positionData.segmentData.blobData;
         QVariant id = QVariant::fromValue<long>(
                 genderData.positionData.segmentData.blobData.id
                 );
+        QVariantMap detectionMap;
 
-        detectionMap.insert("fly_type", genderString); 
-        detectionMap.insert("fly_id", id);
-        detectionMap.insert("x", genderData.positionData.meanXAbs);
-        detectionMap.insert("y", genderData.positionData.meanYAbs);
+        if (
+                (blobData.onBorderX && (direction == MOTION_DIRECTION_Y)) ||
+                (blobData.onBorderY && (direction == MOTION_DIRECTION_X))
+           )
+        { 
+            detectionMap.insert("fly_type", "outofbounds"); 
+            detectionMap.insert("fly_id", id);
+            int x = blobData.boundingRect.x + blobData.boundingRect.width/2;
+            int y = blobData.boundingRect.y + blobData.boundingRect.height/2;
+            detectionMap.insert("x", genderData.positionData.meanXAbs);
+            detectionMap.insert("y", genderData.positionData.meanYAbs);
+        } 
+        else 
+        {
+            if (blobData.old)
+            {
+                detectionMap.insert("fly_type", "old"); 
+            }
+            else
+            {
+                QString genderString = QString::fromStdString( 
+                        GenderSorter::GenderToString(genderData.gender)
+                        );
+                detectionMap.insert("fly_type", genderString); 
+            }
+            detectionMap.insert("fly_id", id);
+            detectionMap.insert("x", genderData.positionData.meanXAbs);
+            detectionMap.insert("y", genderData.positionData.meanYAbs);
+        }
         detectionList.push_back(detectionMap);
     }
     dataMap.insert("detections", detectionList);

src/demo/fly_sorter/gender_sorter.cpp

             FastBinaryPredictor genderPred = FastBinaryPredictor(param_.genderClassifier);
             genderData.predictorData = genderPred.predict(genderData.positionData.pixelFeatureVector);
             genderData.havePredictorData = true;
+            std::cout << "fit: " << genderData.predictorData.fit << std::endl;
             if (genderData.predictorData.fit >= param_.minConfidence)
             {
                 genderData.gender = FEMALE;
     }
     return genderString;
 }
+
+
+std::string GenderSorter::GenderToLetter(Gender gender)
+{
+    std::string letterString;
+    switch (gender)
+    {
+        case FEMALE:
+            letterString = std::string("F");
+            break;
+
+        case MALE:
+            letterString = std::string("M");
+            break;
+
+        default:
+            letterString = std::string("U");
+            break;
+
+    }
+    return letterString;
+}

src/demo/fly_sorter/gender_sorter.hpp

         GenderSorterData sort(HogPositionFitterData hogData);
         void setParam(GenderSorterParam param);
         static std::string GenderToString(Gender gender);
+        static std::string GenderToLetter(Gender gender);
 
     private:
         GenderSorterParam param_;

src/demo/fly_sorter/identity_tracker.cpp

         if (indPrevMin != -1)
         {
             (indexToCurrMap[indCurr] -> id) = (indexToPrevMap[indPrevMin] -> id);
+            (indexToCurrMap[indCurr] -> old) = true;
             usedVector[indPrevMin] = true;
 
             // DEBUG

src/demo/fly_sorter/image_grabber.cpp

     // Read frame from input file at frameRate.
     unsigned long frameCount = 0;
     //float sleepDt = 1.0e3/param_.frameRate;
-    //float sleepDt = 0.25*1.0e3/param_.frameRate;
-    float sleepDt = 0.2*1.0e3/param_.frameRate;
+    float sleepDt = 0.5*1.0e3/param_.frameRate;
+    //float sleepDt = 0.2*1.0e3/param_.frameRate;
     
 
     //std::cout << "begin play back" << std::endl;

src/demo/fly_sorter/parameters.cpp

 ClassifierParam GenderSorterParam::createDefaultGenderClassifierParam()
 {
     ClassifierParam classifierParam;
-    classifierParam.offset = -1.604457;
+    classifierParam.offset = -4.330167;
     std::vector<StumpData> stumpVector;
-    stumpVector.push_back(StumpData(238, 0.084434, 1.674599));
-    stumpVector.push_back(StumpData(24,  0.278435, -1.232384));
-    stumpVector.push_back(StumpData(238, 0.062391, 1.288068));
-    stumpVector.push_back(StumpData(750, 0.001465, -1.190372));
-    stumpVector.push_back(StumpData(238, 0.116674, 1.324515));
-    stumpVector.push_back(StumpData(394, 0.029850, -1.000583));
-    stumpVector.push_back(StumpData(93,  0.239109, 0.899523));
-    stumpVector.push_back(StumpData(744, 0.018012, -0.885773));
-    stumpVector.push_back(StumpData(229, 0.026950, -0.870549));
-    stumpVector.push_back(StumpData(239, 0.001517, 0.764537));
-    stumpVector.push_back(StumpData(749, 0.013050, -1.114222));
-    stumpVector.push_back(StumpData(238, 0.028924, 1.011049));
-    stumpVector.push_back(StumpData(749, 0.126848, -0.915492));
-    stumpVector.push_back(StumpData(238, 0.121497, 1.169906));
-    stumpVector.push_back(StumpData(833, 0.019828, -0.811894));
-    stumpVector.push_back(StumpData(194, 0.053240, 0.994033));
-    stumpVector.push_back(StumpData(185, 0.049640, -0.732560));
-    stumpVector.push_back(StumpData(224, 0.017239, 0.853175));
-    stumpVector.push_back(StumpData(530, 0.006605, 0.644783));
-    stumpVector.push_back(StumpData(849, 0.305672, -0.818103));
-    stumpVector.push_back(StumpData(164, 0.039244, -0.808899));
-    stumpVector.push_back(StumpData(62,  0.527040, -1.090032));
-    stumpVector.push_back(StumpData(538, 0.037647, 0.878776));
-    stumpVector.push_back(StumpData(744, 0.012403, -1.020699));
-    stumpVector.push_back(StumpData(938, 0.422793, 0.910620));
-    stumpVector.push_back(StumpData(748, 0.555650, 0.899145));
-    stumpVector.push_back(StumpData(929, 0.436754, -0.734846));
-    stumpVector.push_back(StumpData(417, 0.077721, 0.843679));
-    stumpVector.push_back(StumpData(510, 0.000547, -0.730515));
-    stumpVector.push_back(StumpData(239, 0.006395, 0.893858));
-    stumpVector.push_back(StumpData(506, 0.073350, 0.755999));
-    stumpVector.push_back(StumpData(184, 0.067602, -0.797213));
-    stumpVector.push_back(StumpData(64,  0.324437, -0.746603));
-    stumpVector.push_back(StumpData(68,  0.499986, 0.692089));
-    stumpVector.push_back(StumpData(126, 0.070462, 0.817883));
-    stumpVector.push_back(StumpData(748, 0.487694, 0.686983));
-    stumpVector.push_back(StumpData(62,  0.527040, -1.055904));
-    stumpVector.push_back(StumpData(744, 0.019774, -0.790157));
-    stumpVector.push_back(StumpData(113, 0.729929, -0.892345));
-    stumpVector.push_back(StumpData(238, 0.038652, 0.754194));
-    stumpVector.push_back(StumpData(185, 0.073443, -0.752404));
-    stumpVector.push_back(StumpData(65,  0.519061, -0.950757));
-    stumpVector.push_back(StumpData(238, 0.116044, 1.012158));
-    stumpVector.push_back(StumpData(394, 0.022576, -0.895473));
-    stumpVector.push_back(StumpData(54,  0.241851, -0.762248));
-    stumpVector.push_back(StumpData(935, 0.380384, 0.768588));
-    stumpVector.push_back(StumpData(510, 0.006829, -1.021979));
-    stumpVector.push_back(StumpData(238, 0.062840, 0.702809));
-    stumpVector.push_back(StumpData(237, 0.166578, -0.920166));
-    stumpVector.push_back(StumpData(150, 0.000204, -0.620677));
-    stumpVector.push_back(StumpData(792, 0.081822, 0.686082));
-    stumpVector.push_back(StumpData(393, 0.490157, 0.879772));
-    stumpVector.push_back(StumpData(501, 0.064878, -0.910076));
-    stumpVector.push_back(StumpData(419, 0.022526, -0.973311));
-    stumpVector.push_back(StumpData(239, 0.013651, 1.028860));
-    stumpVector.push_back(StumpData(209, 0.004232, -0.901006));
-    stumpVector.push_back(StumpData(238, 0.028924, 0.843551));
-    stumpVector.push_back(StumpData(210, 0.000176, -0.659727));
-    stumpVector.push_back(StumpData(106, 0.007611, 0.642773));
-    stumpVector.push_back(StumpData(749, 0.143113, -0.833789));
-    stumpVector.push_back(StumpData(239, 0.001517, 0.678634));
-    stumpVector.push_back(StumpData(506, 0.079232, 0.710684));
-    stumpVector.push_back(StumpData(938, 0.417708, 0.823056));
-    stumpVector.push_back(StumpData(496, 0.131829, 0.790748));
-    stumpVector.push_back(StumpData(197, 0.054917, -0.722815));
-    stumpVector.push_back(StumpData(238, 0.068751, 0.643655));
-    stumpVector.push_back(StumpData(113, 0.747618, -0.783980));
-    stumpVector.push_back(StumpData(480, 0.000589, -0.763001));
-    stumpVector.push_back(StumpData(127, 0.176899, 0.986837));
-    stumpVector.push_back(StumpData(227, 0.022686, -0.662733));
-    stumpVector.push_back(StumpData(538, 0.109119, 0.668535));
-    stumpVector.push_back(StumpData(848, 0.000522, -0.642701));
-    stumpVector.push_back(StumpData(62,  0.526630, -1.079848));
-    stumpVector.push_back(StumpData(184, 0.067184, -0.737352));
-    stumpVector.push_back(StumpData(94,  0.019178, -0.649458));
-    stumpVector.push_back(StumpData(744, 0.013311, -0.873964));
-    stumpVector.push_back(StumpData(154, 0.039989, -1.056767));
-    stumpVector.push_back(StumpData(834, 0.500646, -0.885769));
-    stumpVector.push_back(StumpData(394, 0.022576, -0.836019));
-    stumpVector.push_back(StumpData(538, 0.046264, 0.709547));
-    stumpVector.push_back(StumpData(240, 0.000357, 0.811416));
-    stumpVector.push_back(StumpData(210, 0.004297, -1.040518));
-    stumpVector.push_back(StumpData(229, 0.025967, -0.631054));
-    stumpVector.push_back(StumpData(238, 0.121497, 1.097822));
-    stumpVector.push_back(StumpData(54,  0.241201, -0.725406));
-    stumpVector.push_back(StumpData(714, 0.028121, -0.593168));
-    stumpVector.push_back(StumpData(774, 0.028121, -0.694201));
-    stumpVector.push_back(StumpData(748, 0.553173, 0.830704));
-    stumpVector.push_back(StumpData(183, 0.613997, 0.616241));
-    stumpVector.push_back(StumpData(225, 0.004288, 1.025345));
-    stumpVector.push_back(StumpData(164, 0.033674, -0.662720));
-    stumpVector.push_back(StumpData(201, 0.023513, -1.010363));
-    stumpVector.push_back(StumpData(723, 0.833923, 1.117179));
-    stumpVector.push_back(StumpData(239, 0.005765, 0.717575));
-    stumpVector.push_back(StumpData(493, 0.089478, 0.631682));
-    stumpVector.push_back(StumpData(394, 0.030234, -0.616291));
-    stumpVector.push_back(StumpData(185, 0.048949, -0.608983));
-    stumpVector.push_back(StumpData(929, 0.450759, -0.739179));
-    stumpVector.push_back(StumpData(238, 0.037773, 0.678025));
-    stumpVector.push_back(StumpData(62,  0.527091, -1.006367));
+    stumpVector.push_back(StumpData(748, 0.552426, 1.328007 ));
+    stumpVector.push_back(StumpData(749, 0.047331, -1.176707));
+    stumpVector.push_back(StumpData(743, 0.209210, -1.168777));
+    stumpVector.push_back(StumpData(745, 0.010089, -1.034803));
+    stumpVector.push_back(StumpData(747, 0.144843, 1.037088 ));
+    stumpVector.push_back(StumpData(118, 0.037167, 0.919600 ));
+    stumpVector.push_back(StumpData(238, 0.037307, 1.079700 ));
+    stumpVector.push_back(StumpData(749, 0.080281, -0.904561));
+    stumpVector.push_back(StumpData(745, 0.012593, -0.832781));
+    stumpVector.push_back(StumpData(723, 0.833534, 1.029874 ));
+    stumpVector.push_back(StumpData(775, 0.010362, -0.830556));
+    stumpVector.push_back(StumpData(749, 0.007793, -0.678468));
+    stumpVector.push_back(StumpData(118, 0.025455, 0.766135 ));
+    stumpVector.push_back(StumpData(238, 0.025455, 0.753638 ));
+    stumpVector.push_back(StumpData(89 , 0.513583, -0.780945));
+    stumpVector.push_back(StumpData(748, 0.573543, 0.884628 ));
+    stumpVector.push_back(StumpData(108, 0.029338, -0.737257));
+    stumpVector.push_back(StumpData(235, 0.049589, -0.905012));
+    stumpVector.push_back(StumpData(713, 0.715817, -0.559004));
+    stumpVector.push_back(StumpData(715, 0.010984, -0.768567));
+    stumpVector.push_back(StumpData(153, 0.604613, 0.640303 ));
+    stumpVector.push_back(StumpData(115, 0.049481, -0.901765));
+    stumpVector.push_back(StumpData(228, 0.029421, -0.615051));
+    stumpVector.push_back(StumpData(743, 0.234878, -0.550624));
+    stumpVector.push_back(StumpData(606, 0.152754, 0.626072 ));
+    stumpVector.push_back(StumpData(735, 0.024880, 0.738883 ));
+    stumpVector.push_back(StumpData(872, 0.137090, -0.974634));
+    stumpVector.push_back(StumpData(88 , 0.329897, 0.766801 ));
+    stumpVector.push_back(StumpData(748, 0.602612, 1.015492 ));
+    stumpVector.push_back(StumpData(695, 0.102143, -0.656196));
+    stumpVector.push_back(StumpData(749, 0.001308, -1.008044));
+    stumpVector.push_back(StumpData(118, 0.005885, 0.864977 ));
+    stumpVector.push_back(StumpData(165, 0.029264, -0.863017));
+    stumpVector.push_back(StumpData(238, 0.003953, 0.929472 ));
+    stumpVector.push_back(StumpData(745, 0.005962, -0.928824));
+    stumpVector.push_back(StumpData(749, 0.099934, -0.836794));
+    stumpVector.push_back(StumpData(38 , 0.494834, 0.767344 ));
+    stumpVector.push_back(StumpData(734, 0.036080, 0.520066 ));
+    stumpVector.push_back(StumpData(113, 0.804892, -0.609155));
+    stumpVector.push_back(StumpData(894, 0.518515, 0.532040 ));
+    stumpVector.push_back(StumpData(723, 0.813944, 0.577629 ));
+    stumpVector.push_back(StumpData(745, 0.019939, -0.555738));
+    stumpVector.push_back(StumpData(746, 0.077640, 1.060644 ));
+    stumpVector.push_back(StumpData(235, 0.040515, -0.743278));
+    stumpVector.push_back(StumpData(117, 0.101662, 0.634621 ));
+    stumpVector.push_back(StumpData(237, 0.100970, 0.543552 ));
+    stumpVector.push_back(StumpData(115, 0.040810, -0.779448));
+    stumpVector.push_back(StumpData(26 , 0.494835, 0.775433 ));
+    stumpVector.push_back(StumpData(470, 0.295316, -0.506533));
+    stumpVector.push_back(StumpData(749, 0.039653, -0.603211));
+    stumpVector.push_back(StumpData(748, 0.525455, 0.633338 ));
+    stumpVector.push_back(StumpData(725, 0.045187, -0.618860));
+    stumpVector.push_back(StumpData(896, 0.088737, -1.006523));
+    stumpVector.push_back(StumpData(233, 0.805018, -0.599618));
+    stumpVector.push_back(StumpData(889, 0.366577, -0.864050));
+    stumpVector.push_back(StumpData(778, 0.234797, 0.965736 ));
+    stumpVector.push_back(StumpData(718, 0.166292, 0.688325 ));
+    stumpVector.push_back(StumpData(709, 0.038022, -0.588270));
+    stumpVector.push_back(StumpData(746, 0.066947, 0.794975 ));
+    stumpVector.push_back(StumpData(606, 0.102551, 0.468246 ));
+    stumpVector.push_back(StumpData(740, 0.125365, -0.555096));
+    stumpVector.push_back(StumpData(740, 0.220670, 0.840560 ));
+    stumpVector.push_back(StumpData(618, 0.025901, 0.680421 ));
+    stumpVector.push_back(StumpData(745, 0.008854, -0.703597));
+    stumpVector.push_back(StumpData(747, 0.127821, 0.508122 ));
+    stumpVector.push_back(StumpData(748, 0.571340, 0.808615 ));
+    stumpVector.push_back(StumpData(871, 0.187573, -0.504692));
+    stumpVector.push_back(StumpData(118, 0.002822, 0.976552 ));
+    stumpVector.push_back(StumpData(711, 0.023810, 0.565375 ));
+    stumpVector.push_back(StumpData(238, 0.003953, 0.976466 ));
+    stumpVector.push_back(StumpData(838, 0.009045, 0.795523 ));
+    stumpVector.push_back(StumpData(822, 0.151939, -1.053570));
+    stumpVector.push_back(StumpData(238, 0.045661, 0.498195 ));
+    stumpVector.push_back(StumpData(118, 0.037167, 0.559082 ));
+    stumpVector.push_back(StumpData(848, 0.009045, 0.838301 ));
+    stumpVector.push_back(StumpData(635, 0.024937, -0.815767));
+    stumpVector.push_back(StumpData(739, 0.240009, -0.890572));
+    stumpVector.push_back(StumpData(626, 0.118402, 0.752017 ));
+    stumpVector.push_back(StumpData(154, 0.053881, 0.471172 ));
+    stumpVector.push_back(StumpData(747, 0.154624, 0.514382 ));
+    stumpVector.push_back(StumpData(748, 0.560162, 0.708078 ));
+    stumpVector.push_back(StumpData(623, 0.399805, 0.568538 ));
+    stumpVector.push_back(StumpData(618, 0.058626, 0.505751 ));
+    stumpVector.push_back(StumpData(723, 0.836120, 1.022143 ));
+    stumpVector.push_back(StumpData(775, 0.012316, -0.478431));
+    stumpVector.push_back(StumpData(771, 0.068553, 0.689973 ));
+    stumpVector.push_back(StumpData(85 , 0.307930, 0.582869 ));
+    stumpVector.push_back(StumpData(418, 0.003677, 0.901574 ));
+    stumpVector.push_back(StumpData(538, 0.026378, 0.577327 ));
+    stumpVector.push_back(StumpData(415, 0.040863, -0.568257));
+    stumpVector.push_back(StumpData(749, 0.072650, -0.703587));
+    stumpVector.push_back(StumpData(745, 0.012136, -0.577338));
+    stumpVector.push_back(StumpData(613, 0.876586, -1.008477));
+    stumpVector.push_back(StumpData(843, 0.001435, 0.496803 ));
+    stumpVector.push_back(StumpData(475, 0.010021, 0.586252 ));
+    stumpVector.push_back(StumpData(113, 0.749011, -0.489467));
+    stumpVector.push_back(StumpData(896, 0.088737, -0.928044));
+    stumpVector.push_back(StumpData(238, 0.045661, 0.496098 ));
+    stumpVector.push_back(StumpData(418, 0.059349, 0.535036 ));
+    stumpVector.push_back(StumpData(719, 0.005873, -0.685709));
     classifierParam.stumpVector = stumpVector;
     return classifierParam;
 }
 const float IdentityTrackerParam::DEFAULT_STD_WIDTH = 5.7680;
 const float IdentityTrackerParam::DEFAULT_STD_HEIGHT = 8.6521;
 const float IdentityTrackerParam::DEFAULT_MAX_COST = 32.7148;
+const MotionDirection IdentityTrackerParam::DEFAULT_MOTION_DIRECTION = MOTION_DIRECTION_Y;
 
 
 IdentityTrackerParam::IdentityTrackerParam()
     stdWidth = DEFAULT_STD_WIDTH;
     stdHeight = DEFAULT_STD_HEIGHT;
     maxCost = DEFAULT_MAX_COST;
+    motionDirection = DEFAULT_MOTION_DIRECTION;
 }
 
 

src/demo/fly_sorter/parameters.hpp

 };
 
 
+enum MotionDirection 
+{
+    MOTION_DIRECTION_X = 0,
+    MOTION_DIRECTION_Y = 1
+};
+
 class IdentityTrackerParam
 {
     public:
         float maxCost;
         static const float DEFAULT_MAX_COST;
 
+        MotionDirection motionDirection;
+        static const MotionDirection DEFAULT_MOTION_DIRECTION;
 
         IdentityTrackerParam();
         QVariantMap toMap();

src/utility/blob_data.cpp

     BlobData::BlobData()
     {
         id = ID_NOT_ASSIGNED;
-        area = 0;
+        old = false;
         onBorderX = false;
         onBorderY = false;
+        area = 0;
     }
 
 

src/utility/blob_data.hpp

     {
         public:
             long id;
-            double area;
+            bool old;
             bool onBorderX;
             bool onBorderY;
+            double area;
             Centroid centroid;
             Ellipse ellipse;
             cv::Rect boundingRect;