{
cv::Size winSize;
int type;
- //vector<cv::ocl::Info> info;
virtual void SetUp()
{
winSize = GET_PARAM(0);
type = GET_PARAM(1);
- //cv::ocl::getDevice(info);
}
};
}
+bool match_rect(cv::Rect r1, cv::Rect r2, int threshold)
+{
+ return ((abs(r1.x - r2.x) < threshold) && (abs(r1.y - r2.y) < threshold) &&
+ (abs(r1.width - r2.width) < threshold) && (abs(r1.height - r2.height) < threshold));
+}
+
TEST_P(HOG, Detect)
{
// Load image
}
// OpenCL detection
- std::vector<cv::Point> d_v_locations;
- ocl_hog.detect(d_img, d_v_locations, 0);
- cv::Mat d_locations(d_v_locations);
+ std::vector<cv::Rect> d_found;
+ ocl_hog.detectMultiScale(d_img, d_found, 0, cv::Size(8,8), cv::Size(0,0), 1.05, 2);
// CPU detection
- std::vector<cv::Point> v_locations;
+ std::vector<cv::Rect> found;
switch (type)
{
case CV_8UC1:
- hog.detect(img, v_locations, 0);
+ hog.detectMultiScale(img, found, 0, cv::Size(8,8), cv::Size(0,0), 1.05, 2);
break;
case CV_8UC4:
default:
- hog.detect(img_rgb, v_locations, 0);
+ hog.detectMultiScale(img_rgb, found, 0, cv::Size(8,8), cv::Size(0,0), 1.05, 2);
break;
}
- cv::Mat locations(v_locations);
+
+ // Ground-truth rectangular people window
+ cv::Rect win1_64x128(231, 190, 72, 144);
+ cv::Rect win2_64x128(621, 156, 97, 194);
+ cv::Rect win1_48x96(238, 198, 63, 126);
+ cv::Rect win2_48x96(619, 161, 92, 185);
+ cv::Rect win3_48x96(488, 136, 56, 112);
+
+ // Compare whether ground-truth windows are detected and compare the number of windows detected.
+ std::vector<int> d_comp(4);
+ std::vector<int> comp(4);
+ for(int i = 0; i < (int)d_comp.size(); i++)
+ {
+ d_comp[i] = 0;
+ comp[i] = 0;
+ }
+
+ int threshold = 10;
+ int val = 32;
+ d_comp[0] = d_found.size();
+ comp[0] = found.size();
+ if (winSize == cv::Size(48, 96))
+ {
+ for(int i = 0; i < (int)d_found.size(); i++)
+ {
+ if (match_rect(d_found[i], win1_48x96, threshold))
+ d_comp[1] = val;
+ if (match_rect(d_found[i], win2_48x96, threshold))
+ d_comp[2] = val;
+ if (match_rect(d_found[i], win3_48x96, threshold))
+ d_comp[3] = val;
+ }
+ for(int i = 0; i < (int)found.size(); i++)
+ {
+ if (match_rect(found[i], win1_48x96, threshold))
+ comp[1] = val;
+ if (match_rect(found[i], win2_48x96, threshold))
+ comp[2] = val;
+ if (match_rect(found[i], win3_48x96, threshold))
+ comp[3] = val;
+ }
+ }
+ else if (winSize == cv::Size(64, 128))
+ {
+ for(int i = 0; i < (int)d_found.size(); i++)
+ {
+ if (match_rect(d_found[i], win1_64x128, threshold))
+ d_comp[1] = val;
+ if (match_rect(d_found[i], win2_64x128, threshold))
+ d_comp[2] = val;
+ }
+ for(int i = 0; i < (int)found.size(); i++)
+ {
+ if (match_rect(found[i], win1_64x128, threshold))
+ comp[1] = val;
+ if (match_rect(found[i], win2_64x128, threshold))
+ comp[2] = val;
+ }
+ }
char s[100]={0};
- EXPECT_MAT_NEAR(d_locations, locations, 0, s);
+ EXPECT_MAT_NEAR(cv::Mat(d_comp), cv::Mat(comp), 3, s);
}
-INSTANTIATE_TEST_CASE_P(OCL_ObjDetect, HOG, testing::Combine(
+INSTANTIATE_TEST_CASE_P(GPU_ImgProc, HOG, testing::Combine(
testing::Values(cv::Size(64, 128), cv::Size(48, 96)),
- testing::Values(MatType(CV_8UC1), MatType(CV_8UC3),MatType(CV_8UC4))));
+ testing::Values(MatType(CV_8UC1), MatType(CV_8UC4))));
#endif //HAVE_OPENCL