fix typo in cascade loading
This commit is contained in:
parent
a3af5ede80
commit
14a0dd8c98
@ -198,11 +198,11 @@ inline bool cv::gpu::SoftCascade::Filds::fill(const FileNode &root, const float
|
|||||||
FileNode fns = *it;
|
FileNode fns = *it;
|
||||||
float scale = (float)fns[SC_OCT_SCALE];
|
float scale = (float)fns[SC_OCT_SCALE];
|
||||||
scales.push_back(scale);
|
scales.push_back(scale);
|
||||||
ushort nstages = saturate_cast<ushort>((int)fn[SC_OCT_STAGES]);
|
ushort nstages = saturate_cast<ushort>((int)fns[SC_OCT_STAGES]);
|
||||||
ushort2 size;
|
ushort2 size;
|
||||||
size.x = cvRound(ORIG_OBJECT_WIDTH * scale);
|
size.x = cvRound(ORIG_OBJECT_WIDTH * scale);
|
||||||
size.y = cvRound(ORIG_OBJECT_HEIGHT * scale);
|
size.y = cvRound(ORIG_OBJECT_HEIGHT * scale);
|
||||||
shrinkage = saturate_cast<ushort>((int)fn[SC_OCT_SHRINKAGE]);
|
shrinkage = saturate_cast<ushort>((int)fns[SC_OCT_SHRINKAGE]);
|
||||||
|
|
||||||
icf::Octave octave(octIndex, nstages, shrinkage, size, scale);
|
icf::Octave octave(octIndex, nstages, shrinkage, size, scale);
|
||||||
CV_Assert(octave.stages > 0);
|
CV_Assert(octave.stages > 0);
|
||||||
@ -219,7 +219,7 @@ inline bool cv::gpu::SoftCascade::Filds::fill(const FileNode &root, const float
|
|||||||
for (; st != st_end; ++st )
|
for (; st != st_end; ++st )
|
||||||
{
|
{
|
||||||
fns = *st;
|
fns = *st;
|
||||||
vstages.push_back((float)fn[SC_STAGE_THRESHOLD]);
|
vstages.push_back((float)fns[SC_STAGE_THRESHOLD]);
|
||||||
|
|
||||||
fns = fns[SC_WEEK];
|
fns = fns[SC_WEEK];
|
||||||
FileNodeIterator ftr = fns.begin(), ft_end = fns.end();
|
FileNodeIterator ftr = fns.begin(), ft_end = fns.end();
|
||||||
@ -230,7 +230,8 @@ inline bool cv::gpu::SoftCascade::Filds::fill(const FileNode &root, const float
|
|||||||
for (; inIt != inIt_end;)
|
for (; inIt != inIt_end;)
|
||||||
{
|
{
|
||||||
int feature = (int)(*(inIt +=2)++) + feature_offset;
|
int feature = (int)(*(inIt +=2)++) + feature_offset;
|
||||||
vnodes.push_back(icf::Node(feature, (float)(*(inIt++))));
|
float th = (float)(*(inIt++));
|
||||||
|
vnodes.push_back(icf::Node(feature, th));
|
||||||
}
|
}
|
||||||
|
|
||||||
fns = (*ftr)[SC_LEAF];
|
fns = (*ftr)[SC_LEAF];
|
||||||
@ -277,7 +278,7 @@ inline bool cv::gpu::SoftCascade::Filds::fill(const FileNode &root, const float
|
|||||||
calcLevels(voctaves, FRAME_WIDTH, FRAME_HEIGHT, TOTAL_SCALES);
|
calcLevels(voctaves, FRAME_WIDTH, FRAME_HEIGHT, TOTAL_SCALES);
|
||||||
CV_Assert(!levels.empty());
|
CV_Assert(!levels.empty());
|
||||||
|
|
||||||
// init Cascade
|
//init Cascade
|
||||||
cascade = icf::Cascade(octaves, stages, nodes, leaves, features, levels);
|
cascade = icf::Cascade(octaves, stages, nodes, leaves, features, levels);
|
||||||
|
|
||||||
// allocate buffers
|
// allocate buffers
|
||||||
@ -317,7 +318,7 @@ namespace {
|
|||||||
float a = A[(int)(scaling >= 1)][(int)(channel > 6)];
|
float a = A[(int)(scaling >= 1)][(int)(channel > 6)];
|
||||||
float b = B[(int)(scaling >= 1)][(int)(channel > 6)];
|
float b = B[(int)(scaling >= 1)][(int)(channel > 6)];
|
||||||
|
|
||||||
printf("!!! scaling: %f %f %f -> %f\n", scaling, a, b, a * pow(scaling, b));
|
// printf("!!! scaling: %f %f %f -> %f\n", scaling, a, b, a * pow(scaling, b));
|
||||||
return a * pow(scaling, b);
|
return a * pow(scaling, b);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -352,19 +353,17 @@ inline void cv::gpu::SoftCascade::Filds::calcLevels(const std::vector<icf::Octav
|
|||||||
if (::fabs(scale - maxScale) < FLT_EPSILON) break;
|
if (::fabs(scale - maxScale) < FLT_EPSILON) break;
|
||||||
scale = ::std::min(maxScale, ::expf(::log(scale) + logFactor));
|
scale = ::std::min(maxScale, ::expf(::log(scale) + logFactor));
|
||||||
|
|
||||||
levels.upload(cv::Mat(1, vlevels.size() * sizeof(icf::Level), CV_8UC1, (uchar*)&(vlevels[0]) ));
|
// std::cout << "level " << sc
|
||||||
|
|
||||||
// std::cout << "level " << sc << " scale "
|
|
||||||
// << levels[sc].origScale
|
|
||||||
// << " octeve "
|
// << " octeve "
|
||||||
// << levels[sc].octave->scale
|
// << vlevels[sc].octave
|
||||||
// << " "
|
// << " relScale "
|
||||||
// << levels[sc].relScale
|
// << vlevels[sc].relScale
|
||||||
// << " " << levels[sc].shrScale
|
// << " " << vlevels[sc].shrScale
|
||||||
// << " [" << levels[sc].objSize.width
|
// << " [" << (int)vlevels[sc].objSize.x
|
||||||
// << " " << levels[sc].objSize.height << "] ["
|
// << " " << (int)vlevels[sc].objSize.y << "] ["
|
||||||
// << levels[sc].workRect.width << " " << levels[sc].workRect.height << "]" << std::endl;
|
// << (int)vlevels[sc].workRect.x << " " << (int)vlevels[sc].workRect.y << "]" << std::endl;
|
||||||
}
|
}
|
||||||
|
levels.upload(cv::Mat(1, vlevels.size() * sizeof(icf::Level), CV_8UC1, (uchar*)&(vlevels[0]) ));
|
||||||
}
|
}
|
||||||
|
|
||||||
cv::gpu::SoftCascade::SoftCascade() : filds(0) {}
|
cv::gpu::SoftCascade::SoftCascade() : filds(0) {}
|
||||||
|
@ -48,7 +48,7 @@ using cv::gpu::GpuMat;
|
|||||||
|
|
||||||
TEST(SoftCascade, readCascade)
|
TEST(SoftCascade, readCascade)
|
||||||
{
|
{
|
||||||
std::string xml = cvtest::TS::ptr()->get_data_path() + "cascadeandhog/icf-template.xml";
|
std::string xml = cvtest::TS::ptr()->get_data_path() + "../cv/cascadeandhog/icf-template.xml";
|
||||||
cv::gpu::SoftCascade cascade;
|
cv::gpu::SoftCascade cascade;
|
||||||
ASSERT_TRUE(cascade.load(xml));
|
ASSERT_TRUE(cascade.load(xml));
|
||||||
|
|
||||||
@ -56,11 +56,12 @@ TEST(SoftCascade, readCascade)
|
|||||||
|
|
||||||
TEST(SoftCascade, detect)
|
TEST(SoftCascade, detect)
|
||||||
{
|
{
|
||||||
std::string xml = cvtest::TS::ptr()->get_data_path() + "cascadeandhog/sc_cvpr_2012_to_opencv.xml";
|
std::string xml = cvtest::TS::ptr()->get_data_path() + "../cv/cascadeandhog/sc_cvpr_2012_to_opencv.xml";
|
||||||
cv::gpu::SoftCascade cascade;
|
cv::gpu::SoftCascade cascade;
|
||||||
ASSERT_TRUE(cascade.load(xml));
|
ASSERT_TRUE(cascade.load(xml));
|
||||||
|
|
||||||
cv::Mat coloredCpu = cv::imread(cvtest::TS::ptr()->get_data_path() + "cascadeandhog/bahnhof/image_00000000_0.png");
|
cv::Mat coloredCpu = cv::imread(cvtest::TS::ptr()->get_data_path()
|
||||||
|
+ "../cv/cascadeandhog/bahnhof/image_00000000_0.png");
|
||||||
ASSERT_FALSE(coloredCpu.empty());
|
ASSERT_FALSE(coloredCpu.empty());
|
||||||
GpuMat colored(coloredCpu), objectBoxes, rois;
|
GpuMat colored(coloredCpu), objectBoxes, rois;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user