Skip to content

Instantly share code, notes, and snippets.

@MareArts
Last active October 2, 2017 18:43
Show Gist options
  • Save MareArts/e26e24b9c4e2774222e59ba6f360bb1e to your computer and use it in GitHub Desktop.
Save MareArts/e26e24b9c4e2774222e59ba6f360bb1e to your computer and use it in GitHub Desktop.
ICF(Integral Channel Features) + WaldBoost example (opencv, ICFDetector uses example) - step3 (detection part)
void main()
{
cv::xobjdetect::ICFDetector icf_detector;
// model loading
cv::FileStorage cvfs("icf_model.txt", cv::FileStorage::READ);
icf_detector.read(cvfs["icf"]);
// test image
std::string img_file = "pp.jpg";
cv::Mat img = cv::imread(img_file);
// image detect
std::vector < cv::Rect > objs;
std::vector < float > values;
icf_detector.detect(img, objs, 1.2, cv::Size(128, 128), cv::Size(256, 256), 8.0, 20, values);
char TestStr[100];
// rect draw
for (int i = 0; i < objs.size(); ++i)
{
rectangle(img, objs[i], Scalar(255, 0, 0));
sprintf_s(TestStr, "%0.2lf", values[i]);
//check score
printf("[%d] = %lf\n", i, values[i]);
putText(img, TestStr, Point(objs[i].x, objs[i].y), CV_FONT_NORMAL, 1, Scalar(255, 255, 255), 1); //OutImg is Mat class;
}
namedWindow("test", 0);
imshow("test", img);
waitKey(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment