Skip to content
20 changes: 19 additions & 1 deletion include/detection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
#include <memory>
#include <string>

#include "opencv2/core/core.hpp"
#include <opencv2/core/core.hpp>
#include <opencv2/objdetect.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>

using namespace std;
using namespace cv;


class Detector {
public:
Expand All @@ -12,3 +19,14 @@ class Detector {
virtual void Detect(const cv::Mat& frame, std::vector<cv::Rect>& objects,
std::vector<double>& scores) = 0;
};

class CascadeDetector : public Detector {
public:
virtual bool Init(const std::string& model_file_path);
virtual void Detect(const cv::Mat& frame, std::vector<cv::Rect>& objects,
std::vector<double>& scores);

protected:
cv::CascadeClassifier detector;
};

13 changes: 13 additions & 0 deletions include/image_processing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <memory>
#include <string>
#include <opencv/cv.hpp>

#include "opencv2/core/core.hpp"

Expand All @@ -15,4 +16,16 @@ class ImageProcessor {
const int kernelSize) = 0;
virtual cv::Mat Pixelize(const cv::Mat &src, const cv::Rect &roi,
const int kDivs) = 0;
};

class ImageProcessorImpl : public ImageProcessor {
public:
cv::Mat CvtColor(const cv::Mat &src, const cv::Rect &roi) override;

cv::Mat Filter(const cv::Mat &src, const cv::Rect &roi, const int kSize) override;

cv::Mat
DetectEdges(const cv::Mat &src, const cv::Rect &roi, const int filterSize, const int lowThreshold, const int ratio,
const int kernelSize) override;
cv::Mat Pixelize(const cv::Mat &src, const cv::Rect &roi, const int kDivs) override;
};
203 changes: 203 additions & 0 deletions logo_cascade/intel_HAAR.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
<?xml version="1.0"?>
<opencv_storage>
<cascade>
<stageType>BOOST</stageType>
<featureType>HAAR</featureType>
<height>32</height>
<width>32</width>
<stageParams>
<boostType>GAB</boostType>
<minHitRate>9.9500000476837158e-01</minHitRate>
<maxFalseAlarm>1.0000000149011612e-01</maxFalseAlarm>
<weightTrimRate>9.4999999999999996e-01</weightTrimRate>
<maxDepth>1</maxDepth>
<maxWeakCount>100</maxWeakCount></stageParams>
<featureParams>
<maxCatCount>0</maxCatCount>
<featSize>1</featSize>
<mode>BASIC</mode></featureParams>
<stageNum>5</stageNum>
<stages>
<!-- stage 0 -->
<_>
<maxWeakCount>1</maxWeakCount>
<stageThreshold>9.9700450897216797e-01</stageThreshold>
<weakClassifiers>
<_>
<internalNodes>
0 -1 9 2.6727295480668545e-03</internalNodes>
<leafValues>
-1. 9.9700450897216797e-01</leafValues></_></weakClassifiers></_>
<!-- stage 1 -->
<_>
<maxWeakCount>2</maxWeakCount>
<stageThreshold>1.6233325004577637e-02</stageThreshold>
<weakClassifiers>
<_>
<internalNodes>
0 -1 8 -2.8224483132362366e-02</internalNodes>
<leafValues>
9.7911489009857178e-01 -9.5910018682479858e-01</leafValues></_>
<_>
<internalNodes>
0 -1 5 1.6519669443368912e-03</internalNodes>
<leafValues>
-9.4611197710037231e-01 9.7533351182937622e-01</leafValues></_></weakClassifiers></_>
<!-- stage 2 -->
<_>
<maxWeakCount>2</maxWeakCount>
<stageThreshold>-2.3966401815414429e-01</stageThreshold>
<weakClassifiers>
<_>
<internalNodes>
0 -1 2 -1.8159887194633484e-01</internalNodes>
<leafValues>
8.1481480598449707e-01 -9.9596774578094482e-01</leafValues></_>
<_>
<internalNodes>
0 -1 0 2.7227598428726196e-01</internalNodes>
<leafValues>
-9.9537020921707153e-01 7.5630372762680054e-01</leafValues></_></weakClassifiers></_>
<!-- stage 3 -->
<_>
<maxWeakCount>4</maxWeakCount>
<stageThreshold>-9.0893095731735229e-01</stageThreshold>
<weakClassifiers>
<_>
<internalNodes>
0 -1 7 5.1844924688339233e-02</internalNodes>
<leafValues>
-9.2384767532348633e-01 2.1568627655506134e-01</leafValues></_>
<_>
<internalNodes>
0 -1 1 4.7272067517042160e-02</internalNodes>
<leafValues>
-8.6901932954788208e-01 5.2460169792175293e-01</leafValues></_>
<_>
<internalNodes>
0 -1 4 -5.4597020149230957e-02</internalNodes>
<leafValues>
4.5749512314796448e-01 -9.4674235582351685e-01</leafValues></_>
<_>
<internalNodes>
0 -1 3 9.5191076397895813e-02</internalNodes>
<leafValues>
-9.6718007326126099e-01 4.7605302929878235e-01</leafValues></_></weakClassifiers></_>
<!-- stage 4 -->
<_>
<maxWeakCount>4</maxWeakCount>
<stageThreshold>-9.4207423925399780e-01</stageThreshold>
<weakClassifiers>
<_>
<internalNodes>
0 -1 10 -2.4780812673270702e-03</internalNodes>
<leafValues>
1.2500000000000000e-01 -9.4238680601119995e-01</leafValues></_>
<_>
<internalNodes>
0 -1 11 2.1410051733255386e-02</internalNodes>
<leafValues>
-9.3719536066055298e-01 3.8065698742866516e-01</leafValues></_>
<_>
<internalNodes>
0 -1 6 -1.3540741056203842e-03</internalNodes>
<leafValues>
5.3382533788681030e-01 -9.2854446172714233e-01</leafValues></_>
<_>
<internalNodes>
0 -1 12 -1.2107914313673973e-02</internalNodes>
<leafValues>
4.0368261933326721e-01 -9.4481426477432251e-01</leafValues></_></weakClassifiers></_></stages>
<features>
<_>
<rects>
<_>
1 0 30 18 -1.</_>
<_>
1 9 30 9 2.</_></rects>
<tilted>0</tilted></_>
<_>
<rects>
<_>
3 0 2 30 -1.</_>
<_>
3 10 2 10 3.</_></rects>
<tilted>0</tilted></_>
<_>
<rects>
<_>
4 16 21 16 -1.</_>
<_>
4 24 21 8 2.</_></rects>
<tilted>0</tilted></_>
<_>
<rects>
<_>
10 1 12 14 -1.</_>
<_>
10 8 12 7 2.</_></rects>
<tilted>0</tilted></_>
<_>
<rects>
<_>
11 18 7 12 -1.</_>
<_>
11 24 7 6 2.</_></rects>
<tilted>0</tilted></_>
<_>
<rects>
<_>
12 15 2 2 -1.</_>
<_>
13 15 1 2 2.</_></rects>
<tilted>0</tilted></_>
<_>
<rects>
<_>
13 16 2 1 -1.</_>
<_>
14 16 1 1 2.</_></rects>
<tilted>0</tilted></_>
<_>
<rects>
<_>
14 1 6 10 -1.</_>
<_>
14 6 6 5 2.</_></rects>
<tilted>0</tilted></_>
<_>
<rects>
<_>
14 10 6 12 -1.</_>
<_>
14 14 6 4 3.</_></rects>
<tilted>0</tilted></_>
<_>
<rects>
<_>
15 14 2 3 -1.</_>
<_>
16 14 1 3 2.</_></rects>
<tilted>0</tilted></_>
<_>
<rects>
<_>
15 17 2 3 -1.</_>
<_>
15 18 2 1 3.</_></rects>
<tilted>0</tilted></_>
<_>
<rects>
<_>
23 9 9 16 -1.</_>
<_>
26 9 3 16 3.</_></rects>
<tilted>0</tilted></_>
<_>
<rects>
<_>
26 1 6 21 -1.</_>
<_>
29 1 3 21 2.</_></rects>
<tilted>0</tilted></_></features></cascade>
</opencv_storage>
118 changes: 118 additions & 0 deletions logo_cascade/intel_LBP.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<?xml version="1.0"?>
<opencv_storage>
<cascade>
<stageType>BOOST</stageType>
<featureType>LBP</featureType>
<height>32</height>
<width>32</width>
<stageParams>
<boostType>GAB</boostType>
<minHitRate>9.9500000476837158e-01</minHitRate>
<maxFalseAlarm>1.0000000149011612e-01</maxFalseAlarm>
<weightTrimRate>9.4999999999999996e-01</weightTrimRate>
<maxDepth>1</maxDepth>
<maxWeakCount>100</maxWeakCount></stageParams>
<featureParams>
<maxCatCount>256</maxCatCount>
<featSize>1</featSize></featureParams>
<stageNum>5</stageNum>
<stages>
<!-- stage 0 -->
<_>
<maxWeakCount>1</maxWeakCount>
<stageThreshold>9.2307692766189575e-01</stageThreshold>
<weakClassifiers>
<_>
<internalNodes>
0 -1 2 -243210785 -787906557 -2147483628 -251559935
-2004832114 -1744175104 -2139094902 -1710022005</internalNodes>
<leafValues>
-1. 9.2307692766189575e-01</leafValues></_></weakClassifiers></_>
<!-- stage 1 -->
<_>
<maxWeakCount>1</maxWeakCount>
<stageThreshold>8.5185188055038452e-01</stageThreshold>
<weakClassifiers>
<_>
<internalNodes>
0 -1 5 -711997505 -685438579 -1589539441 -14554131
-525422401 -1316317151 -775886449 -2561</internalNodes>
<leafValues>
-1. 8.5185188055038452e-01</leafValues></_></weakClassifiers></_>
<!-- stage 2 -->
<_>
<maxWeakCount>2</maxWeakCount>
<stageThreshold>-1.9843308627605438e-01</stageThreshold>
<weakClassifiers>
<_>
<internalNodes>
0 -1 3 -95423497 -546619001 336412677 -742678013 704878731
-879050368 -721237617 -7360593</internalNodes>
<leafValues>
-9.8792755603790283e-01 7.7358490228652954e-01</leafValues></_>
<_>
<internalNodes>
0 -1 1 -715796001 2035925121 809877593 -782286833
-1868516725 -1738399606 -486027045 -1053973</internalNodes>
<leafValues>
-9.7201800346374512e-01 8.7086659669876099e-01</leafValues></_></weakClassifiers></_>
<!-- stage 3 -->
<_>
<maxWeakCount>2</maxWeakCount>
<stageThreshold>-2.9111653566360474e-01</stageThreshold>
<weakClassifiers>
<_>
<internalNodes>
0 -1 7 -687219745 -108445629 402928799 2009842059
-2061381443 -88481708 1237551339 -1056853</internalNodes>
<leafValues>
-9.9594318866729736e-01 7.1929824352264404e-01</leafValues></_>
<_>
<internalNodes>
0 -1 0 -41550371 -249867389 1152347 -680009681 -255277921
-1437676915 -1056708165 -37750337</internalNodes>
<leafValues>
-9.8999285697937012e-01 7.0482665300369263e-01</leafValues></_></weakClassifiers></_>
<!-- stage 4 -->
<_>
<maxWeakCount>2</maxWeakCount>
<stageThreshold>-3.8104116916656494e-01</stageThreshold>
<weakClassifiers>
<_>
<internalNodes>
0 -1 6 -537920513 -1001164153 860206851 831950969 -519970677
-207503230 -931091729 -1049861</internalNodes>
<leafValues>
-9.9590164422988892e-01 5.8064514398574829e-01</leafValues></_>
<_>
<internalNodes>
0 -1 4 -237505057 1430488223 -725499767 -184036437
-628901445 -107380601 -97681173 -72363589</internalNodes>
<leafValues>
-9.6168631315231323e-01 8.2039451599121094e-01</leafValues></_></weakClassifiers></_></stages>
<features>
<_>
<rect>
7 1 8 10</rect></_>
<_>
<rect>
9 3 5 8</rect></_>
<_>
<rect>
11 12 5 3</rect></_>
<_>
<rect>
12 14 1 1</rect></_>
<_>
<rect>
12 15 1 1</rect></_>
<_>
<rect>
15 14 1 1</rect></_>
<_>
<rect>
15 15 1 2</rect></_>
<_>
<rect>
15 16 1 2</rect></_></features></cascade>
</opencv_storage>
Loading