clip the found objects in HOG as well (http://code.opencv.org/issues/3825); added test to check CascadeClassifier on small images (http://code.opencv.org/issues/3710)
This commit is contained in:
parent
8c3c6b31fc
commit
882c0321f4
@ -1587,9 +1587,8 @@ bool CascadeClassifier::read(const FileNode &root)
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clipObjects(Size sz, std::vector<Rect>& objects,
|
void clipObjects(Size sz, std::vector<Rect>& objects,
|
||||||
std::vector<int>* a,
|
std::vector<int>* a, std::vector<double>* b)
|
||||||
std::vector<double>* b)
|
|
||||||
{
|
{
|
||||||
size_t i, j = 0, n = objects.size();
|
size_t i, j = 0, n = objects.size();
|
||||||
Rect win0 = Rect(0, 0, sz.width, sz.height);
|
Rect win0 = Rect(0, 0, sz.width, sz.height);
|
||||||
|
@ -5,6 +5,9 @@
|
|||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
|
|
||||||
|
void clipObjects(Size sz, std::vector<Rect>& objects,
|
||||||
|
std::vector<int>* a, std::vector<double>* b);
|
||||||
|
|
||||||
class FeatureEvaluator
|
class FeatureEvaluator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
//M*/
|
//M*/
|
||||||
|
|
||||||
#include "precomp.hpp"
|
#include "precomp.hpp"
|
||||||
|
#include "cascadedetect.hpp"
|
||||||
#include "opencv2/core/core_c.h"
|
#include "opencv2/core/core_c.h"
|
||||||
#include "opencl_kernels_objdetect.hpp"
|
#include "opencl_kernels_objdetect.hpp"
|
||||||
|
|
||||||
@ -1822,7 +1823,9 @@ static bool ocl_detectMultiScale(InputArray _img, std::vector<Rect> &found_locat
|
|||||||
all_candidates.push_back(Rect(Point2d(locations[j]) * scale, scaled_win_size));
|
all_candidates.push_back(Rect(Point2d(locations[j]) * scale, scaled_win_size));
|
||||||
}
|
}
|
||||||
found_locations.assign(all_candidates.begin(), all_candidates.end());
|
found_locations.assign(all_candidates.begin(), all_candidates.end());
|
||||||
cv::groupRectangles(found_locations, (int)group_threshold, 0.2);
|
groupRectangles(found_locations, (int)group_threshold, 0.2);
|
||||||
|
clipObjects(imgSize, found_locations, 0, 0);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif //HAVE_OPENCL
|
#endif //HAVE_OPENCL
|
||||||
@ -1878,6 +1881,7 @@ void HOGDescriptor::detectMultiScale(
|
|||||||
groupRectangles_meanshift(foundLocations, foundWeights, foundScales, finalThreshold, winSize);
|
groupRectangles_meanshift(foundLocations, foundWeights, foundScales, finalThreshold, winSize);
|
||||||
else
|
else
|
||||||
groupRectangles(foundLocations, foundWeights, (int)finalThreshold, 0.2);
|
groupRectangles(foundLocations, foundWeights, (int)finalThreshold, 0.2);
|
||||||
|
clipObjects(imgSize, foundLocations, 0, &foundWeights);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HOGDescriptor::detectMultiScale(InputArray img, std::vector<Rect>& foundLocations,
|
void HOGDescriptor::detectMultiScale(InputArray img, std::vector<Rect>& foundLocations,
|
||||||
|
@ -1360,4 +1360,32 @@ TEST(Objdetect_HOGDetector_Strict, accuracy)
|
|||||||
std::vector<float> descriptors;
|
std::vector<float> descriptors;
|
||||||
reference_hog.compute(image, descriptors);
|
reference_hog.compute(image, descriptors);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(Objdetect_CascadeDetector, small_img)
|
||||||
|
{
|
||||||
|
String root = cvtest::TS::ptr()->get_data_path() + "cascadeandhog/cascades/";
|
||||||
|
String cascades[] =
|
||||||
|
{
|
||||||
|
root + "haarcascade_frontalface_alt.xml",
|
||||||
|
root + "lbpcascade_frontalface.xml",
|
||||||
|
String()
|
||||||
|
};
|
||||||
|
|
||||||
|
vector<Rect> objects;
|
||||||
|
RNG rng((uint64)-1);
|
||||||
|
|
||||||
|
for( int i = 0; !cascades[i].empty(); i++ )
|
||||||
|
{
|
||||||
|
printf("%d. %s\n", i, cascades[i].c_str());
|
||||||
|
CascadeClassifier cascade(cascades[i]);
|
||||||
|
for( int j = 0; j < 100; j++ )
|
||||||
|
{
|
||||||
|
int width = rng.uniform(1, 100);
|
||||||
|
int height = rng.uniform(1, 100);
|
||||||
|
Mat img(height, width, CV_8U);
|
||||||
|
randu(img, 0, 256);
|
||||||
|
cascade.detectMultiScale(img, objects);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user