From 248f39e13e5d2cf422f055c597b67d03cfb32f16 Mon Sep 17 00:00:00 2001 From: Marina Kolpakova Date: Wed, 4 Jul 2012 12:11:07 +0000 Subject: [PATCH] added performance test for LBP classifier. --- modules/gpu/perf/perf_objdetect.cpp | 27 ++++++++++++++++++++++ modules/gpu/perf_cpu/perf_objdetect.cpp | 22 ++++++++++++++++++ modules/gpu/src/cascadeclassifier.cpp | 4 +++- modules/gpu/test/nvidia/TestRectStdDev.cpp | 10 ++++---- modules/gpu/test/test_warp_affine.cpp | 2 -- modules/gpu/test/test_warp_perspective.cpp | 2 -- 6 files changed, 57 insertions(+), 10 deletions(-) diff --git a/modules/gpu/perf/perf_objdetect.cpp b/modules/gpu/perf/perf_objdetect.cpp index 0e0c934412..5fd2297bdc 100644 --- a/modules/gpu/perf/perf_objdetect.cpp +++ b/modules/gpu/perf/perf_objdetect.cpp @@ -57,4 +57,31 @@ GPU_PERF_TEST_1(HaarClassifier, cv::gpu::DeviceInfo) INSTANTIATE_TEST_CASE_P(ObjDetect, HaarClassifier, ALL_DEVICES); +//===================== LBP cascade ==========================// +GPU_PERF_TEST_1(LBPClassifier, cv::gpu::DeviceInfo) +{ + cv::gpu::DeviceInfo devInfo = GetParam(); + cv::gpu::setDevice(devInfo.deviceID()); + + cv::Mat img_host = readImage("gpu/haarcascade/group_1_640x480_VGA.pgm", cv::IMREAD_GRAYSCALE); + ASSERT_FALSE(img_host.empty()); + + cv::gpu::CascadeClassifier_GPU_LBP cascade; + + ASSERT_TRUE(cascade.load(perf::TestBase::getDataPath("gpu/lbpcascade/lbpcascade_frontalface.xml"))); + + cv::gpu::GpuMat img(img_host); + cv::gpu::GpuMat gpu_rects, buffer; + + // cascade.detectMultiScale(img, objects_buffer); + cascade.detectMultiScale(img, buffer, gpu_rects); + + TEST_CYCLE() + { + cascade.detectMultiScale(img, buffer, gpu_rects); + } +} + +INSTANTIATE_TEST_CASE_P(ObjDetect, LBPClassifier, ALL_DEVICES); + #endif diff --git a/modules/gpu/perf_cpu/perf_objdetect.cpp b/modules/gpu/perf_cpu/perf_objdetect.cpp index 05bed40bff..d9ae2b7c8f 100644 --- a/modules/gpu/perf_cpu/perf_objdetect.cpp +++ b/modules/gpu/perf_cpu/perf_objdetect.cpp @@ -49,4 +49,26 @@ GPU_PERF_TEST_1(HaarClassifier, cv::gpu::DeviceInfo) INSTANTIATE_TEST_CASE_P(ObjDetect, HaarClassifier, ALL_DEVICES); +//===================== LBP cascade ==========================// +GPU_PERF_TEST_1(LBPClassifier, cv::gpu::DeviceInfo) +{ + cv::Mat img = readImage("gpu/haarcascade/group_1_640x480_VGA.pgm", cv::IMREAD_GRAYSCALE); + ASSERT_FALSE(img.empty()); + + cv::CascadeClassifier cascade; + + ASSERT_TRUE(cascade.load(perf::TestBase::getDataPath("gpu/lbpcascade/lbpcascade_frontalface.xml"))); + + std::vector rects; + + cascade.detectMultiScale(img, rects); + + TEST_CYCLE() + { + cascade.detectMultiScale(img, rects); + } +} + +INSTANTIATE_TEST_CASE_P(ObjDetect, LBPClassifier, ALL_DEVICES); + #endif diff --git a/modules/gpu/src/cascadeclassifier.cpp b/modules/gpu/src/cascadeclassifier.cpp index 8932667e86..d2f4120c12 100644 --- a/modules/gpu/src/cascadeclassifier.cpp +++ b/modules/gpu/src/cascadeclassifier.cpp @@ -350,7 +350,9 @@ int cv::gpu::CascadeClassifier_GPU_LBP::detectMultiScale(const GpuMat& image, Gp if (groupThreshold <= 0 || objects.empty()) return 0; - return cv::gpu::device::lbp::connectedConmonents(candidates, groupThreshold, grouping_eps, dclassified); + cv::gpu::device::lbp::connectedConmonents(candidates, groupThreshold, grouping_eps, dclassified); + cudaSafeCall( cudaDeviceSynchronize() ); + return *classified; } // ============ old fashioned haar cascade ==============================================// diff --git a/modules/gpu/test/nvidia/TestRectStdDev.cpp b/modules/gpu/test/nvidia/TestRectStdDev.cpp index f75433d8ed..420979d881 100644 --- a/modules/gpu/test/nvidia/TestRectStdDev.cpp +++ b/modules/gpu/test/nvidia/TestRectStdDev.cpp @@ -1,11 +1,11 @@ /* * Copyright 1993-2010 NVIDIA Corporation. All rights reserved. * - * NVIDIA Corporation and its licensors retain all intellectual - * property and proprietary rights in and to this software and - * related documentation and any modifications thereto. - * Any use, reproduction, disclosure, or distribution of this - * software and related documentation without an express license + * NVIDIA Corporation and its licensors retain all intellectual + * property and proprietary rights in and to this software and + * related documentation and any modifications thereto. + * Any use, reproduction, disclosure, or distribution of this + * software and related documentation without an express license * agreement from NVIDIA Corporation is strictly prohibited. */ diff --git a/modules/gpu/test/test_warp_affine.cpp b/modules/gpu/test/test_warp_affine.cpp index 8c92988281..262937fbeb 100644 --- a/modules/gpu/test/test_warp_affine.cpp +++ b/modules/gpu/test/test_warp_affine.cpp @@ -185,8 +185,6 @@ PARAM_TEST_CASE(WarpAffine, cv::gpu::DeviceInfo, cv::Size, MatType, Inverse, Int int borderType; bool useRoi; - cv::Mat M; - virtual void SetUp() { devInfo = GET_PARAM(0); diff --git a/modules/gpu/test/test_warp_perspective.cpp b/modules/gpu/test/test_warp_perspective.cpp index 5724c61433..f143170150 100644 --- a/modules/gpu/test/test_warp_perspective.cpp +++ b/modules/gpu/test/test_warp_perspective.cpp @@ -185,8 +185,6 @@ PARAM_TEST_CASE(WarpPerspective, cv::gpu::DeviceInfo, cv::Size, MatType, Inverse int borderType; bool useRoi; - cv::Mat M; - virtual void SetUp() { devInfo = GET_PARAM(0);