Merge pull request #7688 from alalek:fix_orb_test
authorVadim Pisarevsky <vadim.pisarevsky@gmail.com>
Tue, 22 Nov 2016 11:35:07 +0000 (11:35 +0000)
committerVadim Pisarevsky <vadim.pisarevsky@gmail.com>
Tue, 22 Nov 2016 11:35:07 +0000 (11:35 +0000)
modules/imgproc/src/filter.cpp
modules/objdetect/test/test_cascadeandhog.cpp
modules/videoio/src/cap_aravis.cpp
samples/cpp/detect_blob.cpp
samples/cpp/detect_mser.cpp

index 68a168f..e379df2 100644 (file)
@@ -4640,6 +4640,11 @@ struct IppFilter : public hal::Filter2D
         int ddepth = CV_MAT_DEPTH(dtype);
         int sdepth = CV_MAT_DEPTH(stype);
 
+#if IPP_VERSION_X100 >= 201700 && IPP_VERSION_X100 < 201702 // IPP bug with 1x1 kernel
+        if(kernel_width == 1 && kernel_height == 1)
+            return false;
+#endif
+
         bool runIpp = true
                       && (borderTypeNI == BORDER_CONSTANT || borderTypeNI == BORDER_REPLICATE)
                       && (sdepth == ddepth)
@@ -4911,26 +4916,29 @@ Ptr<hal::Filter2D> Filter2D::create(uchar* kernel_data, size_t kernel_step, int
     }
 
 #ifdef HAVE_IPP
-    if (kernel_type == CV_32FC1) {
-        IppFilter<CV_32F>* impl = new IppFilter<CV_32F>();
-        if (impl->init(kernel_data, kernel_step, kernel_type, kernel_width, kernel_height,
-                       max_width, max_height, stype, dtype,
-                       borderType, delta, anchor_x, anchor_y, isSubmatrix, isInplace))
-        {
-            return Ptr<hal::Filter2D>(impl);
+    CV_IPP_CHECK()
+    {
+        if (kernel_type == CV_32FC1) {
+            IppFilter<CV_32F>* impl = new IppFilter<CV_32F>();
+            if (impl->init(kernel_data, kernel_step, kernel_type, kernel_width, kernel_height,
+                           max_width, max_height, stype, dtype,
+                           borderType, delta, anchor_x, anchor_y, isSubmatrix, isInplace))
+            {
+                return Ptr<hal::Filter2D>(impl);
+            }
+            delete impl;
         }
-        delete impl;
-    }
 
-    if (kernel_type == CV_16SC1) {
-        IppFilter<CV_16S>* impl = new IppFilter<CV_16S>();
-        if (impl->init(kernel_data, kernel_step, kernel_type, kernel_width, kernel_height,
-                       max_width, max_height, stype, dtype,
-                       borderType, delta, anchor_x, anchor_y, isSubmatrix, isInplace))
-        {
-            return Ptr<hal::Filter2D>(impl);
+        if (kernel_type == CV_16SC1) {
+            IppFilter<CV_16S>* impl = new IppFilter<CV_16S>();
+            if (impl->init(kernel_data, kernel_step, kernel_type, kernel_width, kernel_height,
+                           max_width, max_height, stype, dtype,
+                           borderType, delta, anchor_x, anchor_y, isSubmatrix, isInplace))
+            {
+                return Ptr<hal::Filter2D>(impl);
+            }
+            delete impl;
         }
-        delete impl;
     }
 #endif
 
index 31afbe6..1c844da 100644 (file)
@@ -1086,7 +1086,7 @@ void HOGDescriptorTester::detect(const Mat& img,
         return;
     }
 
-    const double eps = 0.0;
+    const double eps = FLT_EPSILON * 100;
     double diff_norm = cvtest::norm(actual_weights, weights, NORM_L2);
     if (diff_norm > eps)
     {
@@ -1096,7 +1096,6 @@ void HOGDescriptorTester::detect(const Mat& img,
         failed = true;
         ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
         ts->set_gtest_status();
-        return;
     }
 }
 
@@ -1169,7 +1168,7 @@ void HOGDescriptorTester::compute(InputArray _img, vector<float>& descriptors,
     actual_hog->compute(img, actual_descriptors, winStride, padding, locations);
 
     double diff_norm = cvtest::norm(actual_descriptors, descriptors, NORM_L2);
-    const double eps = 0.0;
+    const double eps = FLT_EPSILON * 100;
     if (diff_norm > eps)
     {
         ts->printf(cvtest::TS::SUMMARY, "Norm of the difference: %lf\n", diff_norm);
@@ -1178,7 +1177,6 @@ void HOGDescriptorTester::compute(InputArray _img, vector<float>& descriptors,
         ts->printf(cvtest::TS::LOG, "Channels: %d\n", img.channels());
         ts->set_gtest_status();
         failed = true;
-        return;
     }
 }
 
@@ -1315,7 +1313,7 @@ void HOGDescriptorTester::computeGradient(const Mat& img, Mat& grad, Mat& qangle
     const char* args[] = { "Gradient's", "Qangles's" };
     actual_hog->computeGradient(img, actual_mats[0], actual_mats[1], paddingTL, paddingBR);
 
-    const double eps = 0.0;
+    const double eps = FLT_EPSILON * 100;
     for (i = 0; i < 2; ++i)
     {
        double diff_norm = cvtest::norm(reference_mats[i], actual_mats[i], NORM_L2);
@@ -1327,7 +1325,6 @@ void HOGDescriptorTester::computeGradient(const Mat& img, Mat& grad, Mat& qangle
            ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
            ts->set_gtest_status();
            failed = true;
-           return;
        }
     }
 }
index 3423ca6..c272bee 100644 (file)
@@ -188,11 +188,12 @@ CvCaptureCAM_Aravis::CvCaptureCAM_Aravis()
 
 void CvCaptureCAM_Aravis::close()
 {
-    if(camera)
+    if(camera) {
         stopCapture();
 
-    g_object_unref(camera);
-    camera = NULL;
+        g_object_unref(camera);
+        camera = NULL;
+    }
 }
 
 bool CvCaptureCAM_Aravis::getDeviceNameById(int id, std::string &device)
@@ -559,8 +560,10 @@ void CvCaptureCAM_Aravis::stopCapture()
 {
     arv_camera_stop_acquisition(camera);
 
-    g_object_unref(stream);
-    stream = NULL;
+    if(stream) {
+        g_object_unref(stream);
+        stream = NULL;
+    }
 }
 
 bool CvCaptureCAM_Aravis::startCapture()
index 9c96706..6abe03b 100644 (file)
@@ -21,14 +21,14 @@ static String Legende(SimpleBlobDetector::Params &pAct)
     String s = "";
     if (pAct.filterByArea)
     {
-        String inf = static_cast<ostringstream*>(&(ostringstream() << pAct.minArea))->str();
-        String sup = static_cast<ostringstream*>(&(ostringstream() << pAct.maxArea))->str();
+        String inf = static_cast<const ostringstream&>(ostringstream() << pAct.minArea).str();
+        String sup = static_cast<const ostringstream&>(ostringstream() << pAct.maxArea).str();
         s = " Area range [" + inf + " to  " + sup + "]";
     }
     if (pAct.filterByCircularity)
     {
-        String inf = static_cast<ostringstream*>(&(ostringstream() << pAct.minCircularity))->str();
-        String sup = static_cast<ostringstream*>(&(ostringstream() << pAct.maxCircularity))->str();
+        String inf = static_cast<const ostringstream&>(ostringstream() << pAct.minCircularity).str();
+        String sup = static_cast<const ostringstream&>(ostringstream() << pAct.maxCircularity).str();
         if (s.length() == 0)
             s = " Circularity range [" + inf + " to  " + sup + "]";
         else
@@ -36,7 +36,7 @@ static String Legende(SimpleBlobDetector::Params &pAct)
     }
     if (pAct.filterByColor)
     {
-        String inf = static_cast<ostringstream*>(&(ostringstream() << (int)pAct.blobColor))->str();
+        String inf = static_cast<const ostringstream&>(ostringstream() << (int)pAct.blobColor).str();
         if (s.length() == 0)
             s = " Blob color " + inf;
         else
@@ -44,8 +44,8 @@ static String Legende(SimpleBlobDetector::Params &pAct)
     }
     if (pAct.filterByConvexity)
     {
-        String inf = static_cast<ostringstream*>(&(ostringstream() << pAct.minConvexity))->str();
-        String sup = static_cast<ostringstream*>(&(ostringstream() << pAct.maxConvexity))->str();
+        String inf = static_cast<const ostringstream&>(ostringstream() << pAct.minConvexity).str();
+        String sup = static_cast<const ostringstream&>(ostringstream() << pAct.maxConvexity).str();
         if (s.length() == 0)
             s = " Convexity range[" + inf + " to  " + sup + "]";
         else
@@ -53,8 +53,8 @@ static String Legende(SimpleBlobDetector::Params &pAct)
     }
     if (pAct.filterByInertia)
     {
-        String inf = static_cast<ostringstream*>(&(ostringstream() << pAct.minInertiaRatio))->str();
-        String sup = static_cast<ostringstream*>(&(ostringstream() << pAct.maxInertiaRatio))->str();
+        String inf = static_cast<const ostringstream&>(ostringstream() << pAct.minInertiaRatio).str();
+        String sup = static_cast<const ostringstream&>(ostringstream() << pAct.maxInertiaRatio).str();
         if (s.length() == 0)
             s = " Inertia ratio range [" + inf + " to  " + sup + "]";
         else
index 7e3248d..ce29db3 100644 (file)
@@ -73,25 +73,25 @@ struct MSERParams
 static String Legende(MSERParams &pAct)
 {
     String s="";
-    String inf = static_cast<ostringstream*>(&(ostringstream() << pAct.minArea))->str();
-    String sup = static_cast<ostringstream*>(&(ostringstream() << pAct.maxArea))->str();
+    String inf = static_cast<const ostringstream&>(ostringstream() << pAct.minArea).str();
+    String sup = static_cast<const ostringstream&>(ostringstream() << pAct.maxArea).str();
     s = " Area[" + inf + "," + sup + "]";
 
-    inf = static_cast<ostringstream*>(&(ostringstream() << pAct.delta))->str();
+    inf = static_cast<const ostringstream&>(ostringstream() << pAct.delta).str();
     s += " del. [" + inf + "]";
-    inf = static_cast<ostringstream*>(&(ostringstream() << pAct.maxVariation))->str();
+    inf = static_cast<const ostringstream&>(ostringstream() << pAct.maxVariation).str();
     s += " var. [" + inf + "]";
-    inf = static_cast<ostringstream*>(&(ostringstream() << (int)pAct.minDiversity))->str();
+    inf = static_cast<const ostringstream&>(ostringstream() << (int)pAct.minDiversity).str();
     s += " div. [" + inf + "]";
-    inf = static_cast<ostringstream*>(&(ostringstream() << (int)pAct.pass2Only))->str();
+    inf = static_cast<const ostringstream&>(ostringstream() << (int)pAct.pass2Only).str();
     s += " pas. [" + inf + "]";
-    inf = static_cast<ostringstream*>(&(ostringstream() << (int)pAct.maxEvolution))->str();
+    inf = static_cast<const ostringstream&>(ostringstream() << (int)pAct.maxEvolution).str();
     s += "RGb-> evo. [" + inf + "]";
-    inf = static_cast<ostringstream*>(&(ostringstream() << (int)pAct.areaThreshold))->str();
+    inf = static_cast<const ostringstream&>(ostringstream() << (int)pAct.areaThreshold).str();
     s += " are. [" + inf + "]";
-    inf = static_cast<ostringstream*>(&(ostringstream() << (int)pAct.minMargin))->str();
+    inf = static_cast<const ostringstream&>(ostringstream() << (int)pAct.minMargin).str();
     s += " mar. [" + inf + "]";
-    inf = static_cast<ostringstream*>(&(ostringstream() << (int)pAct.edgeBlurSize))->str();
+    inf = static_cast<const ostringstream&>(ostringstream() << (int)pAct.edgeBlurSize).str();
     s += " siz. [" + inf + "]";
     return s;
 }