Object Detection  5.0
Image Processing Using Qt and Opencv
objectdetectionimpl.cpp
1 #include "objectdetectionimpl.h"
2 using namespace cv;
3 using namespace ImageProcessor;
4 
5 QVariant ObjectDetection::_ObjectDetectionImpl::getResults() const
6 {
7  return results;
8 }
9 
10 void ObjectDetection::_ObjectDetectionImpl::setResults(const QVariant &value)
11 {
12  results = value;
13 }
14 
15 std::vector<PluginSharedPointer> ObjectDetection::_ObjectDetectionImpl::getFilters() const
16 {
17  return _filters;
18 }
19 
20 void ObjectDetection::_ObjectDetectionImpl::setFilters(const std::vector<PluginSharedPointer> &value)
21 {
22  _filters = value;
23 }
24 
25 Mat ObjectDetection::_ObjectDetectionImpl::applyFilters(Mat dst) const
26 {
27  for(auto pro : _filters)
28  {
29  dst = pro->filter(dst);
30  }
31  return dst;
32 }
33 
34 ObjectDetection::_ObjectDetectionImpl::_ObjectDetectionImpl(ObjectDetection * const ptr):
35  _ptr{ptr}
36 {
37  setCirDetector(new DetectCircle);
38  setColDetector(new DetectColor);
39  setDiler(new Dilate);
40 }
41 
42 Dilate *ObjectDetection::_ObjectDetectionImpl::getDiler() const
43 {
44  return _diler;
45 }
46 
47 void ObjectDetection::_ObjectDetectionImpl::addFilter(PluginSharedPointer proc)
48 {
49  _filters.push_back(proc);
50 }
51 
52 void ObjectDetection::_ObjectDetectionImpl::setDiler(Dilate *diler)
53 {
54  _diler = diler;
55  _diler->setParent(_ptr);
56 }
57 
58 DetectColor *ObjectDetection::_ObjectDetectionImpl::getColDetector() const
59 {
60  return _colDetector;
61 }
62 
63 void ObjectDetection::_ObjectDetectionImpl::setColDetector(DetectColor *colDetector)
64 {
65  _colDetector = colDetector;
66  _colDetector->setParent(_ptr);
67 
68 }
69 
70 
71 
72 
73 QVariant ObjectDetection::_ObjectDetectionImpl::processImage()
74 {
75  return QVariant::fromValue(getCircles());
76 }
77 
78 DetectCircle *ObjectDetection::_ObjectDetectionImpl::getCirDetector() const
79 {
80  return _cirDetector;
81 }
82 
83 void ObjectDetection::_ObjectDetectionImpl::setCirDetector(DetectCircle *cirDetector)
84 {
85  _cirDetector = cirDetector;
86  _cirDetector->setParent(_ptr);
87 
88 }
89 
90 std::vector<Vec3f> ObjectDetection::_ObjectDetectionImpl::getCircles()
91 {
92  //TODO add image Cache
93  getColDetector()->setImg(_ptr->getImg());
94  getColDetector()->processImage();
95  auto dst = getColDetector()->getDst();
96 
97  applyFilters(dst);
98  getDiler()->setImg(dst);
99  getDiler()->processImage();
100  dst = getDiler()->getDst();
101  getCirDetector()->setImg(dst);
102  QVariant var = getCirDetector()->processImage();
103  setResults(var);
104  return var.value<std::vector<cv::Vec3f>>();
105 }
106 
107 
this class is used to detect a a colored circle object(s)
this class is used To Detect circles in an image
Definition: detectcircle.h:12
this class is used to Detect Color given it&#39;s range(min, max) of hsv colors.
Definition: detectcolor.h:13
Common Namespace for all Image Processor Algorithms.
this Class is used to perform morphological dilate operation on image see Morphological Operation...
Definition: dilate.h:13