From 50c2f87addfe908697ba2cb03d52fe082b04f42f Mon Sep 17 00:00:00 2001 From: Evgeny Talanin Date: Wed, 30 Jan 2013 21:39:26 +0400 Subject: [PATCH] Fix and test for #2607 --- modules/objdetect/src/hog.cpp | 2 +- modules/objdetect/test/test_cascadeandhog.cpp | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/modules/objdetect/src/hog.cpp b/modules/objdetect/src/hog.cpp index 9388c5b..f1a32c4 100644 --- a/modules/objdetect/src/hog.cpp +++ b/modules/objdetect/src/hog.cpp @@ -138,7 +138,7 @@ void HOGDescriptor::write(FileStorage& fs, const String& objName) const << "gammaCorrection" << gammaCorrection << "nlevels" << nlevels; if( !svmDetector.empty() ) - fs << "SVMDetector" << "[:" << svmDetector << "]"; + fs << "SVMDetector" << svmDetector; fs << "}"; } diff --git a/modules/objdetect/test/test_cascadeandhog.cpp b/modules/objdetect/test/test_cascadeandhog.cpp index e41314a..3f31a7e 100644 --- a/modules/objdetect/test/test_cascadeandhog.cpp +++ b/modules/objdetect/test/test_cascadeandhog.cpp @@ -461,5 +461,30 @@ int CV_HOGDetectorTest::detectMultiScale( int di, const Mat& img, return cvtest::TS::OK; } +//----------------------------------------------- HOGDetectorReadWriteTest ----------------------------------- +TEST(Objdetect_HOGDetectorReadWrite, regression) +{ + // Inspired by bug #2607 + Mat img; + img = imread(cvtest::TS::ptr()->get_data_path() + "/cascadeandhog/images/karen-and-rob.png"); + ASSERT_FALSE(img.empty()); + + HOGDescriptor hog; + hog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector()); + + string tempfilename = cv::tempfile(".xml"); + FileStorage fs(tempfilename, FileStorage::WRITE); + hog.write(fs, "myHOG"); + + fs.open(tempfilename, FileStorage::READ); + remove(tempfilename.c_str()); + + FileNode n = fs["opencv_storage"]["myHOG"]; + + ASSERT_NO_THROW(hog.read(n)); +} + + + TEST(Objdetect_CascadeDetector, regression) { CV_CascadeDetectorTest test; test.safe_run(); } TEST(Objdetect_HOGDetector, regression) { CV_HOGDetectorTest test; test.safe_run(); } -- 2.7.4