1 // This file is part of OpenCV project.
2 // It is subject to the license terms in the LICENSE file found in the top-level directory
3 // of this distribution and at http://opencv.org/license.html.
4 //
5 // Copyright (C) 2018-2020 Intel Corporation
6
7
8 #include "precomp.hpp"
9
10 #include <opencv2/gapi/gscalar.hpp>
11 #include <opencv2/gapi/gcall.hpp>
12 #include <opencv2/gapi/gkernel.hpp>
13 #include <opencv2/gapi/imgproc.hpp>
14
15 namespace cv { namespace gapi {
16
sepFilter(const GMat & src,int ddepth,const Mat & kernelX,const Mat & kernelY,const Point & anchor,const Scalar & delta,int borderType,const Scalar & borderVal)17 GMat sepFilter(const GMat& src, int ddepth, const Mat& kernelX, const Mat& kernelY, const Point& anchor,
18 const Scalar& delta, int borderType, const Scalar& borderVal)
19 {
20 return imgproc::GSepFilter::on(src, ddepth, kernelX, kernelY, anchor, delta, borderType, borderVal);
21 }
22
filter2D(const GMat & src,int ddepth,const Mat & kernel,const Point & anchor,const Scalar & delta,int borderType,const Scalar & bordVal)23 GMat filter2D(const GMat& src, int ddepth, const Mat& kernel, const Point& anchor, const Scalar& delta, int borderType,
24 const Scalar& bordVal)
25 {
26 return imgproc::GFilter2D::on(src, ddepth, kernel, anchor, delta, borderType, bordVal);
27 }
28
boxFilter(const GMat & src,int dtype,const Size & ksize,const Point & anchor,bool normalize,int borderType,const Scalar & bordVal)29 GMat boxFilter(const GMat& src, int dtype, const Size& ksize, const Point& anchor,
30 bool normalize, int borderType, const Scalar& bordVal)
31 {
32 return imgproc::GBoxFilter::on(src, dtype, ksize, anchor, normalize, borderType, bordVal);
33 }
34
blur(const GMat & src,const Size & ksize,const Point & anchor,int borderType,const Scalar & bordVal)35 GMat blur(const GMat& src, const Size& ksize, const Point& anchor,
36 int borderType, const Scalar& bordVal)
37 {
38 return imgproc::GBlur::on(src, ksize, anchor, borderType, bordVal);
39 }
40
gaussianBlur(const GMat & src,const Size & ksize,double sigmaX,double sigmaY,int borderType,const Scalar & bordVal)41 GMat gaussianBlur(const GMat& src, const Size& ksize, double sigmaX, double sigmaY,
42 int borderType, const Scalar& bordVal)
43 {
44 return imgproc::GGaussBlur::on(src, ksize, sigmaX, sigmaY, borderType, bordVal);
45 }
46
medianBlur(const GMat & src,int ksize)47 GMat medianBlur(const GMat& src, int ksize)
48 {
49 return imgproc::GMedianBlur::on(src, ksize);
50 }
51
erode(const GMat & src,const Mat & kernel,const Point & anchor,int iterations,int borderType,const Scalar & borderValue)52 GMat erode(const GMat& src, const Mat& kernel, const Point& anchor, int iterations,
53 int borderType, const Scalar& borderValue )
54 {
55 return imgproc::GErode::on(src, kernel, anchor, iterations, borderType, borderValue);
56 }
57
erode3x3(const GMat & src,int iterations,int borderType,const Scalar & borderValue)58 GMat erode3x3(const GMat& src, int iterations,
59 int borderType, const Scalar& borderValue )
60 {
61 return erode(src, cv::Mat(), cv::Point(-1, -1), iterations, borderType, borderValue);
62 }
63
dilate(const GMat & src,const Mat & kernel,const Point & anchor,int iterations,int borderType,const Scalar & borderValue)64 GMat dilate(const GMat& src, const Mat& kernel, const Point& anchor, int iterations,
65 int borderType, const Scalar& borderValue)
66 {
67 return imgproc::GDilate::on(src, kernel, anchor, iterations, borderType, borderValue);
68 }
69
dilate3x3(const GMat & src,int iterations,int borderType,const Scalar & borderValue)70 GMat dilate3x3(const GMat& src, int iterations,
71 int borderType, const Scalar& borderValue)
72 {
73 return dilate(src, cv::Mat(), cv::Point(-1,-1), iterations, borderType, borderValue);
74 }
75
morphologyEx(const GMat & src,const MorphTypes op,const Mat & kernel,const Point & anchor,const int iterations,const BorderTypes borderType,const Scalar & borderValue)76 GMat morphologyEx(const GMat &src, const MorphTypes op, const Mat &kernel, const Point &anchor,
77 const int iterations, const BorderTypes borderType, const Scalar &borderValue)
78 {
79 return imgproc::GMorphologyEx::on(src, op, kernel, anchor, iterations,
80 borderType, borderValue);
81 }
82
Sobel(const GMat & src,int ddepth,int dx,int dy,int ksize,double scale,double delta,int borderType,const Scalar & bordVal)83 GMat Sobel(const GMat& src, int ddepth, int dx, int dy, int ksize,
84 double scale, double delta,
85 int borderType, const Scalar& bordVal)
86 {
87 return imgproc::GSobel::on(src, ddepth, dx, dy, ksize, scale, delta, borderType, bordVal);
88 }
89
SobelXY(const GMat & src,int ddepth,int order,int ksize,double scale,double delta,int borderType,const Scalar & bordVal)90 std::tuple<GMat, GMat> SobelXY(const GMat& src, int ddepth, int order, int ksize,
91 double scale, double delta,
92 int borderType, const Scalar& bordVal)
93 {
94 return imgproc::GSobelXY::on(src, ddepth, order, ksize, scale, delta, borderType, bordVal);
95 }
96
Laplacian(const GMat & src,int ddepth,int ksize,double scale,double delta,int borderType)97 GMat Laplacian(const GMat& src, int ddepth, int ksize, double scale, double delta, int borderType)
98 {
99 return imgproc::GLaplacian::on(src, ddepth, ksize, scale, delta, borderType);
100 }
101
bilateralFilter(const GMat & src,int d,double sigmaColor,double sigmaSpace,int borderType)102 GMat bilateralFilter(const GMat& src, int d, double sigmaColor, double sigmaSpace, int borderType)
103 {
104 return imgproc::GBilateralFilter::on(src, d, sigmaColor, sigmaSpace, borderType);
105 }
106
equalizeHist(const GMat & src)107 GMat equalizeHist(const GMat& src)
108 {
109 return imgproc::GEqHist::on(src);
110 }
111
Canny(const GMat & src,double thr1,double thr2,int apertureSize,bool l2gradient)112 GMat Canny(const GMat& src, double thr1, double thr2, int apertureSize, bool l2gradient)
113 {
114 return imgproc::GCanny::on(src, thr1, thr2, apertureSize, l2gradient);
115 }
116
goodFeaturesToTrack(const GMat & image,int maxCorners,double qualityLevel,double minDistance,const Mat & mask,int blockSize,bool useHarrisDetector,double k)117 cv::GArray<cv::Point2f> goodFeaturesToTrack(const GMat& image, int maxCorners, double qualityLevel,
118 double minDistance, const Mat& mask, int blockSize,
119 bool useHarrisDetector, double k)
120 {
121 return imgproc::GGoodFeatures::on(image, maxCorners, qualityLevel, minDistance, mask, blockSize,
122 useHarrisDetector, k);
123 }
124
125 GArray<GArray<Point>>
findContours(const GMat & src,const RetrievalModes mode,const ContourApproximationModes method,const GOpaque<Point> & offset)126 findContours(const GMat &src, const RetrievalModes mode, const ContourApproximationModes method,
127 const GOpaque<Point> &offset)
128 {
129 return imgproc::GFindContours::on(src, mode, method, offset);
130 }
131
132 GArray<GArray<Point>>
findContours(const GMat & src,const RetrievalModes mode,const ContourApproximationModes method)133 findContours(const GMat &src, const RetrievalModes mode, const ContourApproximationModes method)
134 {
135 return imgproc::GFindContoursNoOffset::on(src, mode, method);
136 }
137
138
139 std::tuple<GArray<GArray<Point>>,GArray<Vec4i>>
findContoursH(const GMat & src,const RetrievalModes mode,const ContourApproximationModes method,const GOpaque<Point> & offset)140 findContoursH(const GMat &src, const RetrievalModes mode, const ContourApproximationModes method,
141 const GOpaque<Point> &offset)
142 {
143 return imgproc::GFindContoursH::on(src, mode, method, offset);
144 }
145
146 std::tuple<GArray<GArray<Point>>,GArray<Vec4i>>
findContoursH(const GMat & src,const RetrievalModes mode,const ContourApproximationModes method)147 findContoursH(const GMat &src, const RetrievalModes mode, const ContourApproximationModes method)
148 {
149 return imgproc::GFindContoursHNoOffset::on(src, mode, method);
150 }
151
boundingRect(const GMat & src)152 GOpaque<Rect> boundingRect(const GMat& src)
153 {
154 return imgproc::GBoundingRectMat::on(src);
155 }
156
boundingRect(const GArray<Point2i> & src)157 GOpaque<Rect> boundingRect(const GArray<Point2i>& src)
158 {
159 return imgproc::GBoundingRectVector32S::on(src);
160 }
161
boundingRect(const GArray<Point2f> & src)162 GOpaque<Rect> boundingRect(const GArray<Point2f>& src)
163 {
164 return imgproc::GBoundingRectVector32F::on(src);
165 }
166
fitLine2D(const GMat & src,const DistanceTypes distType,const double param,const double reps,const double aeps)167 GOpaque<Vec4f> fitLine2D(const GMat& src, const DistanceTypes distType, const double param,
168 const double reps, const double aeps)
169 {
170 return imgproc::GFitLine2DMat::on(src, distType, param, reps, aeps);
171 }
172
fitLine2D(const GArray<Point2i> & src,const DistanceTypes distType,const double param,const double reps,const double aeps)173 GOpaque<Vec4f> fitLine2D(const GArray<Point2i>& src, const DistanceTypes distType,
174 const double param, const double reps, const double aeps)
175 {
176 return imgproc::GFitLine2DVector32S::on(src, distType, param, reps, aeps);
177 }
178
fitLine2D(const GArray<Point2f> & src,const DistanceTypes distType,const double param,const double reps,const double aeps)179 GOpaque<Vec4f> fitLine2D(const GArray<Point2f>& src, const DistanceTypes distType,
180 const double param, const double reps, const double aeps)
181 {
182 return imgproc::GFitLine2DVector32F::on(src, distType, param, reps, aeps);
183 }
184
fitLine2D(const GArray<Point2d> & src,const DistanceTypes distType,const double param,const double reps,const double aeps)185 GOpaque<Vec4f> fitLine2D(const GArray<Point2d>& src, const DistanceTypes distType,
186 const double param, const double reps, const double aeps)
187 {
188 return imgproc::GFitLine2DVector64F::on(src, distType, param, reps, aeps);
189 }
190
fitLine3D(const GMat & src,const DistanceTypes distType,const double param,const double reps,const double aeps)191 GOpaque<Vec6f> fitLine3D(const GMat& src, const DistanceTypes distType, const double param,
192 const double reps, const double aeps)
193 {
194 return imgproc::GFitLine3DMat::on(src, distType, param, reps, aeps);
195 }
196
fitLine3D(const GArray<Point3i> & src,const DistanceTypes distType,const double param,const double reps,const double aeps)197 GOpaque<Vec6f> fitLine3D(const GArray<Point3i>& src, const DistanceTypes distType,
198 const double param, const double reps, const double aeps)
199 {
200 return imgproc::GFitLine3DVector32S::on(src, distType, param, reps, aeps);
201 }
202
fitLine3D(const GArray<Point3f> & src,const DistanceTypes distType,const double param,const double reps,const double aeps)203 GOpaque<Vec6f> fitLine3D(const GArray<Point3f>& src, const DistanceTypes distType,
204 const double param, const double reps, const double aeps)
205 {
206 return imgproc::GFitLine3DVector32F::on(src, distType, param, reps, aeps);
207 }
208
fitLine3D(const GArray<Point3d> & src,const DistanceTypes distType,const double param,const double reps,const double aeps)209 GOpaque<Vec6f> fitLine3D(const GArray<Point3d>& src, const DistanceTypes distType,
210 const double param, const double reps, const double aeps)
211 {
212 return imgproc::GFitLine3DVector64F::on(src, distType, param, reps, aeps);
213 }
214
BGR2RGB(const GMat & src)215 GMat BGR2RGB(const GMat& src)
216 {
217 return imgproc::GBGR2RGB::on(src);
218 }
219
RGB2Gray(const GMat & src)220 GMat RGB2Gray(const GMat& src)
221 {
222 return imgproc::GRGB2Gray::on(src);
223 }
224
RGB2Gray(const GMat & src,float rY,float gY,float bY)225 GMat RGB2Gray(const GMat& src, float rY, float gY, float bY)
226 {
227 return imgproc::GRGB2GrayCustom::on(src, rY, gY, bY);
228 }
229
BGR2Gray(const GMat & src)230 GMat BGR2Gray(const GMat& src)
231 {
232 return imgproc::GBGR2Gray::on(src);
233 }
234
RGB2YUV(const GMat & src)235 GMat RGB2YUV(const GMat& src)
236 {
237 return imgproc::GRGB2YUV::on(src);
238 }
239
BGR2LUV(const GMat & src)240 GMat BGR2LUV(const GMat& src)
241 {
242 return imgproc::GBGR2LUV::on(src);
243 }
244
LUV2BGR(const GMat & src)245 GMat LUV2BGR(const GMat& src)
246 {
247 return imgproc::GLUV2BGR::on(src);
248 }
249
BGR2YUV(const GMat & src)250 GMat BGR2YUV(const GMat& src)
251 {
252 return imgproc::GBGR2YUV::on(src);
253 }
254
YUV2BGR(const GMat & src)255 GMat YUV2BGR(const GMat& src)
256 {
257 return imgproc::GYUV2BGR::on(src);
258 }
259
YUV2RGB(const GMat & src)260 GMat YUV2RGB(const GMat& src)
261 {
262 return imgproc::GYUV2RGB::on(src);
263 }
264
BGR2I420(const GMat & src)265 GMat BGR2I420(const GMat& src)
266 {
267 return imgproc::GBGR2I420::on(src);
268 }
269
RGB2I420(const GMat & src)270 GMat RGB2I420(const GMat& src)
271 {
272 return imgproc::GRGB2I420::on(src);
273 }
274
I4202BGR(const GMat & src)275 GMat I4202BGR(const GMat& src)
276 {
277 return imgproc::GI4202BGR::on(src);
278 }
279
I4202RGB(const GMat & src)280 GMat I4202RGB(const GMat& src)
281 {
282 return imgproc::GI4202RGB::on(src);
283 }
284
NV12toRGB(const GMat & src_y,const GMat & src_uv)285 GMat NV12toRGB(const GMat& src_y, const GMat& src_uv)
286 {
287 return imgproc::GNV12toRGB::on(src_y, src_uv);
288 }
289
NV12toBGR(const GMat & src_y,const GMat & src_uv)290 GMat NV12toBGR(const GMat& src_y, const GMat& src_uv)
291 {
292 return imgproc::GNV12toBGR::on(src_y, src_uv);
293 }
294
RGB2Lab(const GMat & src)295 GMat RGB2Lab(const GMat& src)
296 {
297 return imgproc::GRGB2Lab::on(src);
298 }
299
BayerGR2RGB(const GMat & src_gr)300 GMat BayerGR2RGB(const GMat& src_gr)
301 {
302 return imgproc::GBayerGR2RGB::on(src_gr);
303 }
304
RGB2HSV(const GMat & src)305 GMat RGB2HSV(const GMat& src)
306 {
307 return imgproc::GRGB2HSV::on(src);
308 }
309
RGB2YUV422(const GMat & src)310 GMat RGB2YUV422(const GMat& src)
311 {
312 return imgproc::GRGB2YUV422::on(src);
313 }
314
NV12toGray(const GMat & y,const GMat & uv)315 GMat NV12toGray(const GMat &y, const GMat &uv)
316 {
317 return imgproc::GNV12toGray::on(y, uv);
318 }
319
NV12toRGBp(const GMat & y,const GMat & uv)320 GMatP NV12toRGBp(const GMat &y, const GMat &uv)
321 {
322 return imgproc::GNV12toRGBp::on(y, uv);
323 }
324
NV12toBGRp(const GMat & y,const GMat & uv)325 GMatP NV12toBGRp(const GMat &y, const GMat &uv)
326 {
327 return imgproc::GNV12toBGRp::on(y, uv);
328 }
329
330 } //namespace gapi
331 } //namespace cv
332