fix tests
This commit is contained in:
parent
8d9c9c2690
commit
cb329400df
modules
gpu
objdetect/include/opencv2/objdetect
@ -194,52 +194,6 @@ RUN_GPU(SCascadeTestRoi, detectEachRoi)
|
|||||||
|
|
||||||
NO_CPU(SCascadeTestRoi, detectEachRoi)
|
NO_CPU(SCascadeTestRoi, detectEachRoi)
|
||||||
|
|
||||||
SC_PERF_TEST_P(SCascadeTest, detectOnIntegral,
|
|
||||||
testing::Combine(
|
|
||||||
testing::Values(std::string("cv/cascadeandhog/cascades/inria_caltech-17.01.2013.xml"),
|
|
||||||
std::string("cv/cascadeandhog/cascades/sc_cvpr_2012_to_opencv_new_format.xml")),
|
|
||||||
testing::Values(std::string("cv/cascadeandhog/integrals.xml"))))
|
|
||||||
|
|
||||||
static std::string itoa(long i)
|
|
||||||
{
|
|
||||||
static char s[65];
|
|
||||||
sprintf(s, "%ld", i);
|
|
||||||
return std::string(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
RUN_GPU(SCascadeTest, detectOnIntegral)
|
|
||||||
{
|
|
||||||
cv::Mat cpu = readImage ("cv/cascadeandhog/images/image_00000000_0.png");
|
|
||||||
ASSERT_FALSE(cpu.empty());
|
|
||||||
|
|
||||||
cv::ICFPreprocessor preprocessor;
|
|
||||||
cv::Mat test_res(cpu.rows / 4 * 10 + 1, cpu.cols / 4 + 1, CV_8UC1);
|
|
||||||
preprocessor.apply(cpu,test_res);
|
|
||||||
|
|
||||||
cv::gpu::SCascade cascade;
|
|
||||||
|
|
||||||
cv::FileStorage fs(perf::TestBase::getDataPath(GET_PARAM(0)), cv::FileStorage::READ);
|
|
||||||
ASSERT_TRUE(fs.isOpened());
|
|
||||||
|
|
||||||
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
|
|
||||||
|
|
||||||
cv::gpu::GpuMat objectBoxes(1, 10000 * sizeof(cv::gpu::SCascade::Detection), CV_8UC1), rois(cv::Size(640, 480), CV_8UC1);
|
|
||||||
rois.setTo(1);
|
|
||||||
|
|
||||||
cv::gpu::GpuMat hogluv(test_res);
|
|
||||||
|
|
||||||
cascade.detect(hogluv, rois, objectBoxes);
|
|
||||||
|
|
||||||
TEST_CYCLE()
|
|
||||||
{
|
|
||||||
cascade.detect(hogluv, rois, objectBoxes);
|
|
||||||
}
|
|
||||||
|
|
||||||
SANITY_CHECK(sortDetections(objectBoxes));
|
|
||||||
}
|
|
||||||
|
|
||||||
NO_CPU(SCascadeTest, detectOnIntegral)
|
|
||||||
|
|
||||||
SC_PERF_TEST_P(SCascadeTest, detectStream,
|
SC_PERF_TEST_P(SCascadeTest, detectStream,
|
||||||
testing::Combine(
|
testing::Combine(
|
||||||
testing::Values(std::string("cv/cascadeandhog/cascades/inria_caltech-17.01.2013.xml"),
|
testing::Values(std::string("cv/cascadeandhog/cascades/inria_caltech-17.01.2013.xml"),
|
||||||
@ -271,10 +225,7 @@ RUN_GPU(SCascadeTest, detectStream)
|
|||||||
cascade.detect(colored, rois, objectBoxes, s);
|
cascade.detect(colored, rois, objectBoxes, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_CUDA
|
s.waitForCompletion();
|
||||||
cudaDeviceSynchronize();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SANITY_CHECK(sortDetections(objectBoxes));
|
SANITY_CHECK(sortDetections(objectBoxes));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -547,7 +547,7 @@ void CascadeInvoker<Policy>::operator()(const PtrStepSzb& roi, const PtrStepSzi&
|
|||||||
soft_cascade<Policy, false><<<grid, Policy::block(), 0, stream>>>(inv, det, max_det, ctr, 0);
|
soft_cascade<Policy, false><<<grid, Policy::block(), 0, stream>>>(inv, det, max_det, ctr, 0);
|
||||||
cudaSafeCall( cudaGetLastError());
|
cudaSafeCall( cudaGetLastError());
|
||||||
|
|
||||||
grid = dim3(fw, fh / Policy::STA_Y, 38 - downscales);
|
grid = dim3(fw, fh / Policy::STA_Y, min(38, scales) - downscales);
|
||||||
soft_cascade<Policy, true><<<grid, Policy::block(), 0, stream>>>(inv, det, max_det, ctr, downscales);
|
soft_cascade<Policy, true><<<grid, Policy::block(), 0, stream>>>(inv, det, max_det, ctr, downscales);
|
||||||
|
|
||||||
if (!stream)
|
if (!stream)
|
||||||
|
@ -133,10 +133,6 @@ struct cv::gpu::SCascade::Fields
|
|||||||
|
|
||||||
std::string fformat = (string)root[SC_FEATURE_FORMAT];
|
std::string fformat = (string)root[SC_FEATURE_FORMAT];
|
||||||
bool useBoxes = (fformat == "BOX");
|
bool useBoxes = (fformat == "BOX");
|
||||||
|
|
||||||
if(useBoxes)
|
|
||||||
std::cout << "use boxes!!!";
|
|
||||||
|
|
||||||
ushort shrinkage = cv::saturate_cast<ushort>((int)root[SC_SHRINKAGE]);
|
ushort shrinkage = cv::saturate_cast<ushort>((int)root[SC_SHRINKAGE]);
|
||||||
|
|
||||||
FileNode fn = root[SC_OCTAVES];
|
FileNode fn = root[SC_OCTAVES];
|
||||||
@ -154,13 +150,8 @@ struct cv::gpu::SCascade::Fields
|
|||||||
{
|
{
|
||||||
FileNode fns = *it;
|
FileNode fns = *it;
|
||||||
float scale = powf(2.f,saturate_cast<float>((int)fns[SC_OCT_SCALE]));
|
float scale = powf(2.f,saturate_cast<float>((int)fns[SC_OCT_SCALE]));
|
||||||
std::cout << "octave scale " << scale << std::endl;
|
|
||||||
|
|
||||||
bool isUPOctave = scale >= 1;
|
bool isUPOctave = scale >= 1;
|
||||||
|
|
||||||
if (isUPOctave)
|
|
||||||
std::cout << "isUPOctave" << std::endl;
|
|
||||||
|
|
||||||
ushort nweaks = saturate_cast<ushort>((int)fns[SC_OCT_WEAKS]);
|
ushort nweaks = saturate_cast<ushort>((int)fns[SC_OCT_WEAKS]);
|
||||||
|
|
||||||
ushort2 size;
|
ushort2 size;
|
||||||
@ -225,11 +216,9 @@ struct cv::gpu::SCascade::Fields
|
|||||||
{
|
{
|
||||||
inIt +=2;
|
inIt +=2;
|
||||||
int featureIdx = (int)(*(inIt++));
|
int featureIdx = (int)(*(inIt++));
|
||||||
// std::cout << " featureIdx " << featureIdx << " " << feature_rects[featureIdx] << std::endl;
|
|
||||||
|
|
||||||
float orig_threshold = (float)(*(inIt++));
|
float orig_threshold = (float)(*(inIt++));
|
||||||
unsigned int th = saturate_cast<unsigned int>((int)orig_threshold);
|
unsigned int th = saturate_cast<unsigned int>((int)orig_threshold);
|
||||||
// std::cout << "orig_threshold " << orig_threshold << " converted " << th << std::endl;
|
|
||||||
cv::Rect& r = feature_rects[featureIdx];
|
cv::Rect& r = feature_rects[featureIdx];
|
||||||
uchar4 rect;
|
uchar4 rect;
|
||||||
rect.x = saturate_cast<uchar>(r.x);
|
rect.x = saturate_cast<uchar>(r.x);
|
||||||
@ -248,7 +237,6 @@ struct cv::gpu::SCascade::Fields
|
|||||||
vleaves.push_back((float)(*inIt));
|
vleaves.push_back((float)(*inIt));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::cout << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cv::Mat hoctaves(1, (int) (voctaves.size() * sizeof(Octave)), CV_8UC1, (uchar*)&(voctaves[0]));
|
cv::Mat hoctaves(1, (int) (voctaves.size() * sizeof(Octave)), CV_8UC1, (uchar*)&(voctaves[0]));
|
||||||
@ -424,7 +412,7 @@ public:
|
|||||||
// 160x120x10
|
// 160x120x10
|
||||||
GpuMat shrunk;
|
GpuMat shrunk;
|
||||||
|
|
||||||
// temporial mat for integrall
|
// temporal mat for integral
|
||||||
GpuMat integralBuffer;
|
GpuMat integralBuffer;
|
||||||
|
|
||||||
// 161x121x10
|
// 161x121x10
|
||||||
@ -591,7 +579,7 @@ private:
|
|||||||
|
|
||||||
cv::gpu::cartToPolar(dfdx, dfdy, mag, ang, true, s);
|
cv::gpu::cartToPolar(dfdx, dfdy, mag, ang, true, s);
|
||||||
|
|
||||||
// normolize magnitude to uchar interval and angles to 6 bins
|
// normalize magnitude to uchar interval and angles to 6 bins
|
||||||
GpuMat nmag(fplane, cv::Rect(0, 4 * fh, fw, fh));
|
GpuMat nmag(fplane, cv::Rect(0, 4 * fh, fw, fh));
|
||||||
GpuMat nang(fplane, cv::Rect(0, 5 * fh, fw, fh));
|
GpuMat nang(fplane, cv::Rect(0, 5 * fh, fw, fh));
|
||||||
|
|
||||||
|
@ -219,15 +219,30 @@ INSTANTIATE_TEST_CASE_P(GPU_SoftCascade, SCascadeTestRoi, testing::Combine(
|
|||||||
testing::Range(0, 5)));
|
testing::Range(0, 5)));
|
||||||
|
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
PARAM_TEST_CASE(SCascadeTestAll, cv::gpu::DeviceInfo, std::string)
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
struct Fixture
|
||||||
|
{
|
||||||
|
std::string path;
|
||||||
|
int expected;
|
||||||
|
|
||||||
|
Fixture(){}
|
||||||
|
Fixture(std::string p, int e): path(p), expected(e) {}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
PARAM_TEST_CASE(SCascadeTestAll, cv::gpu::DeviceInfo, Fixture)
|
||||||
{
|
{
|
||||||
|
|
||||||
std::string xml;
|
std::string xml;
|
||||||
|
int expected;
|
||||||
|
|
||||||
virtual void SetUp()
|
virtual void SetUp()
|
||||||
{
|
{
|
||||||
cv::gpu::setDevice(GET_PARAM(0).deviceID());
|
cv::gpu::setDevice(GET_PARAM(0).deviceID());
|
||||||
xml = path(GET_PARAM(1));
|
xml = path(GET_PARAM(1).path);
|
||||||
|
expected = GET_PARAM(1).expected;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -265,34 +280,7 @@ GPU_TEST_P(SCascadeTestAll, detect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SHOW(coloredCpu);
|
SHOW(coloredCpu);
|
||||||
// ASSERT_EQ(count, 2448);
|
ASSERT_EQ(*count, expected);
|
||||||
}
|
|
||||||
|
|
||||||
GPU_TEST_P(SCascadeTestAll, detectOnIntegral)
|
|
||||||
{
|
|
||||||
cv::gpu::SCascade cascade;
|
|
||||||
|
|
||||||
cv::FileStorage fs(xml, cv::FileStorage::READ);
|
|
||||||
ASSERT_TRUE(fs.isOpened());
|
|
||||||
|
|
||||||
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
|
|
||||||
|
|
||||||
cv::Mat coloredCpu = cv::imread(path("images/image_00000000_0.png"));
|
|
||||||
cv::ICFPreprocessor preprocessor;
|
|
||||||
cv::Mat integrals(coloredCpu.rows / 4 * 10 + 1, coloredCpu.cols / 4 + 1, CV_8UC1);
|
|
||||||
preprocessor.apply(coloredCpu, integrals);
|
|
||||||
GpuMat hogluv(integrals);
|
|
||||||
|
|
||||||
GpuMat objectBoxes(1, 100000, CV_8UC1), rois(cv::Size(640, 480), CV_8UC1);
|
|
||||||
rois.setTo(1);
|
|
||||||
|
|
||||||
objectBoxes.setTo(0);
|
|
||||||
cascade.detect(hogluv, rois, objectBoxes);
|
|
||||||
|
|
||||||
// typedef cv::gpu::SCascade::Detection Detection;
|
|
||||||
// cv::Mat detections(objectBoxes);
|
|
||||||
// int a = *(detections.ptr<int>(0));
|
|
||||||
// ASSERT_EQ(a, 1024);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GPU_TEST_P(SCascadeTestAll, detectStream)
|
GPU_TEST_P(SCascadeTestAll, detectStream)
|
||||||
@ -308,9 +296,7 @@ GPU_TEST_P(SCascadeTestAll, detectStream)
|
|||||||
ASSERT_FALSE(coloredCpu.empty());
|
ASSERT_FALSE(coloredCpu.empty());
|
||||||
|
|
||||||
GpuMat colored(coloredCpu), objectBoxes(1, 100000, CV_8UC1), rois(colored.size(), CV_8UC1);
|
GpuMat colored(coloredCpu), objectBoxes(1, 100000, CV_8UC1), rois(colored.size(), CV_8UC1);
|
||||||
rois.setTo(0);
|
rois.setTo(cv::Scalar::all(1));
|
||||||
GpuMat sub(rois, cv::Rect(rois.cols / 4, rois.rows / 4,rois.cols / 2, rois.rows / 2));
|
|
||||||
sub.setTo(cv::Scalar::all(1));
|
|
||||||
|
|
||||||
cv::gpu::Stream s;
|
cv::gpu::Stream s;
|
||||||
|
|
||||||
@ -318,14 +304,14 @@ GPU_TEST_P(SCascadeTestAll, detectStream)
|
|||||||
cascade.detect(colored, rois, objectBoxes, s);
|
cascade.detect(colored, rois, objectBoxes, s);
|
||||||
s.waitForCompletion();
|
s.waitForCompletion();
|
||||||
|
|
||||||
// typedef cv::gpu::SCascade::Detection Detection;
|
typedef cv::gpu::SCascade::Detection Detection;
|
||||||
// cv::Mat detections(objectBoxes);
|
cv::Mat detections(objectBoxes);
|
||||||
// int a = *(detections.ptr<int>(0));
|
int a = *(detections.ptr<int>(0));
|
||||||
// ASSERT_EQ(a, 2448);
|
ASSERT_EQ(a, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(GPU_SoftCascade, SCascadeTestAll, testing::Combine( ALL_DEVICES,
|
INSTANTIATE_TEST_CASE_P(GPU_SoftCascade, SCascadeTestAll, testing::Combine( ALL_DEVICES,
|
||||||
testing::Values(std::string("cascades/inria_caltech-17.01.2013.xml"),
|
testing::Values(Fixture("cascades/inria_caltech-17.01.2013.xml", 7),
|
||||||
std::string("cascades/sc_cvpr_2012_to_opencv_new_format.xml"))));
|
Fixture("cascades/sc_cvpr_2012_to_opencv_new_format.xml", 1291))));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -488,16 +488,6 @@ protected:
|
|||||||
Ptr<MaskGenerator> maskGenerator;
|
Ptr<MaskGenerator> maskGenerator;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class CV_EXPORTS_W ICFPreprocessor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CV_WRAP ICFPreprocessor();
|
|
||||||
CV_WRAP void apply(cv::InputArray _frame, cv::OutputArray _integrals) const;
|
|
||||||
protected:
|
|
||||||
enum {BINS = 10};
|
|
||||||
};
|
|
||||||
|
|
||||||
// Implementation of soft (stageless) cascaded detector.
|
// Implementation of soft (stageless) cascaded detector.
|
||||||
class CV_EXPORTS_W SCascade : public Algorithm
|
class CV_EXPORTS_W SCascade : public Algorithm
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user