예제 #1
0
TEST(SoftCascadeDetector, readCascade)
{
    std::string xml = cvtest::TS::ptr()->get_data_path() + "cascadeandhog/cascades/inria_caltech-17.01.2013.xml";
     Detector cascade;
    cv::FileStorage fs(xml, cv::FileStorage::READ);
    ASSERT_TRUE(fs.isOpened());
    ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
}
예제 #2
0
TEST(SoftCascadeDetector, detectSeparate)
{
    std::string xml =  cvtest::TS::ptr()->get_data_path() + "cascadeandhog/cascades/inria_caltech-17.01.2013.xml";
    Detector cascade;
    cv::FileStorage fs(xml, cv::FileStorage::READ);
    ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));

    cv::Mat colored = cv::imread(cvtest::TS::ptr()->get_data_path() + "cascadeandhog/images/image_00000000_0.png");
    ASSERT_FALSE(colored.empty());

    cv::Mat rects, confs;

    cascade.detect(colored, cv::noArray(), rects, confs);
    ASSERT_EQ(719, confs.cols);
}
예제 #3
0
TEST(SoftCascadeDetector, detectEmptyRoi)
{
    std::string xml =  cvtest::TS::ptr()->get_data_path() + "cascadeandhog/cascades/inria_caltech-17.01.2013.xml";
    Detector cascade;
    cv::FileStorage fs(xml, cv::FileStorage::READ);
    ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));

    cv::Mat colored = cv::imread(cvtest::TS::ptr()->get_data_path() + "cascadeandhog/images/image_00000000_0.png");
    ASSERT_FALSE(colored.empty());

    std::vector<Detection> objects;
    cascade.detect(colored, cv::Mat::zeros(colored.size(), CV_8UC1), objects);

    ASSERT_EQ(0, (int)objects.size());
}
예제 #4
0
TEST(SoftCascadeDetector, detectRoi)
{
    std::string xml =  cvtest::TS::ptr()->get_data_path() + "cascadeandhog/cascades/inria_caltech-17.01.2013.xml";
    Detector cascade;
    cv::FileStorage fs(xml, cv::FileStorage::READ);
    ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));

    cv::Mat colored = cv::imread(cvtest::TS::ptr()->get_data_path() + "cascadeandhog/images/image_00000000_0.png");
    ASSERT_FALSE(colored.empty());

    std::vector<Detection> objects;
    std::vector<cv::Rect> rois;
    rois.push_back(cv::Rect(0, 0, 640, 480));

    cascade.detect(colored, rois, objects);
    ASSERT_EQ(719, (int)objects.size());
}
예제 #5
0
{
    rects.clear();
    for (int i = 0; i < (int)objectBoxes.size(); ++i)
        rects.push_back(objectBoxes[i].bb);
}

}

PERF_TEST_P(detect, SoftCascadeDetector,
    testing::Combine(testing::Values(std::string("cv/cascadeandhog/cascades/inria_caltech-17.01.2013.xml")),
    testing::Values(std::string("cv/cascadeandhog/images/image_00000000_0.png"))))
{
    cv::Mat colored = cv::imread(getDataPath(get<1>(GetParam())));
    ASSERT_FALSE(colored.empty());

    Detector cascade;
    cv::FileStorage fs(getDataPath(get<0>(GetParam())), cv::FileStorage::READ);
    ASSERT_TRUE(fs.isOpened());
    ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));

    std::vector<Detection> objectBoxes;
    TEST_CYCLE()
    {
        cascade.detect(colored, cv::noArray(), objectBoxes);
    }

    std::vector<Rect> rects;
    extractRacts(objectBoxes, rects);
    std::sort(rects.begin(), rects.end(), perf::comparators::RectLess());
    SANITY_CHECK(rects);
}