forked from hipudding/opencv_contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcann_interface.hpp
633 lines (581 loc) Β· 33.8 KB
/
cann_interface.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#ifndef OPENCV_CANNOPS_CANN_INTERFACE_HPP
#define OPENCV_CANNOPS_CANN_INTERFACE_HPP
#include "opencv2/cann.hpp"
namespace cv
{
namespace cann
{
/**
@addtogroup cann
@{
@defgroup cannops Operations for Ascend Backend.
@{
@defgroup cannops_elem Per-element Operations
@defgroup cannops_core Core Operations on Matrices
@defgroup cannimgproc Image Processing
@}
@}
*/
//! @addtogroup cannops_elem
//! @{
/** @brief Computes a matrix-matrix or matrix-scalar sum.
* @param src1 First source matrix or scalar.
* @param src2 Second source matrix or scalar. Matrix should have the same size and type as src1 .
* @param dst Destination matrix that has the same size and number of channels as the input
* array(s). The depth is defined by dtype or src1 depth.
* @param mask Optional operation mask, 8-bit single channel array, that specifies elements of the
* destination array to be changed. The mask can be used only with single channel images.
* @param dtype Optional depth of the output array.
* @param stream AscendStream for the asynchronous version.
* @sa cv::add cuda::add
*/
CV_EXPORTS_W void add(const InputArray src1, const InputArray src2, OutputArray dst,
const InputArray mask = noArray(), int dtype = -1,
AscendStream& stream = AscendStream::Null());
// This code should not be compiled nor analyzed by doxygen. This interface only for python binding
// code generation. add(InputArray, InputArray ...) can accept Scalar as its parametr.(Scalar -> Mat
// -> InputArray)
#ifdef NEVER_DEFINED
CV_EXPORTS_W void add(const InputArray src1, const Scalar& src2, OutputArray dst,
const InputArray mask = noArray(), int dtype = -1,
AscendStream& stream = AscendStream::Null());
CV_EXPORTS_W void add(const Scalar& src1, const InputArray src2, OutputArray dst,
const InputArray mask = noArray(), int dtype = -1,
AscendStream& stream = AscendStream::Null());
#endif
// More overload functions. In order to decouple from the main opencv repository and simplify
// user calling methods, besides the traditional Input/OutputArray parameters, some
// overloaded functions for the AcendMat parameter is also provided.
/** @overload */
CV_EXPORTS_W void add(const AscendMat& src1, const AscendMat& src2, CV_OUT AscendMat& dst,
const AscendMat& mask = AscendMat(), int dtype = -1,
AscendStream& stream = AscendStream::Null());
/** @overload */
CV_EXPORTS_W void add(const AscendMat& src1, const Scalar& src2, CV_OUT AscendMat& dst,
const AscendMat& mask = AscendMat(), int dtype = -1,
AscendStream& stream = AscendStream::Null());
/** @overload */
CV_EXPORTS_W void add(const Scalar& src1, const AscendMat& src2, CV_OUT AscendMat& dst,
const AscendMat& mask = AscendMat(), int dtype = -1,
AscendStream& stream = AscendStream::Null());
/** @brief Computes a matrix-matrix or matrix-scalar difference.
* @param src1 First source matrix or scalar.
* @param src2 Second source matrix or scalar. Matrix should have the same size and type as src1 .
* @param dst Destination matrix that has the same size and number of channels as the input
* array(s). The depth is defined by dtype or src1 depth.
* @param mask Optional operation mask, 8-bit single channel array, that specifies elements of the
* destination array to be changed. The mask can be used only with single channel images.
* @param dtype Optional depth of the output array.
* @param stream AscendStream for the asynchronous version.
* @sa cv::subtract cuda::subtract
*/
CV_EXPORTS_W void subtract(const InputArray src1, const InputArray src2, OutputArray dst,
const InputArray mask = noArray(), int dtype = -1,
AscendStream& stream = AscendStream::Null());
#ifdef NEVER_DEFINED
CV_EXPORTS_W void subtract(const InputArray src1, const Scalar& src2, OutputArray dst,
const InputArray mask = noArray(), int dtype = -1,
AscendStream& stream = AscendStream::Null());
CV_EXPORTS_W void subtract(const Scalar& src1, const InputArray src2, OutputArray dst,
const InputArray mask = noArray(), int dtype = -1,
AscendStream& stream = AscendStream::Null());
#endif
/** @overload */
CV_EXPORTS_W void subtract(const AscendMat& src1, const AscendMat& src2, CV_OUT AscendMat& dst,
const AscendMat& mask = AscendMat(), int dtype = -1,
AscendStream& stream = AscendStream::Null());
/** @overload */
CV_EXPORTS_W void subtract(const AscendMat& src1, const Scalar& src2, CV_OUT AscendMat& dst,
const AscendMat& mask = AscendMat(), int dtype = -1,
AscendStream& stream = AscendStream::Null());
/** @overload */
CV_EXPORTS_W void subtract(const Scalar& src1, const AscendMat& src2, CV_OUT AscendMat& dst,
const AscendMat& mask = AscendMat(), int dtype = -1,
AscendStream& stream = AscendStream::Null());
/** @brief Computes a matrix-matrix or matrix-scalar per-element product.
* @param src1 First source matrix or scalar.
* @param src2 Second source matrix or scalar. Matrix should have the same size and type as src1 .
* @param dst Destination matrix that has the same size and number of channels as the input
* array(s). The depth is defined by dtype or src1 depth.
* @param scale Optional scale factor.
* @param dtype Optional depth of the output array.
* @param stream AscendStream for the asynchronous version.
* @note when scale != 1, src must be one of the following types: float16, float32, int32
* @sa cv::multiply cuda::multiply
*/
CV_EXPORTS_W void multiply(const InputArray src1, const InputArray src2, OutputArray dst,
float scale = 1, int dtype = -1,
AscendStream& stream = AscendStream::Null());
#ifdef NEVER_DEFINED
CV_EXPORTS_W void multiply(const InputArray src1, const Scalar& src2, OutputArray dst,
float scale = 1, int dtype = -1,
AscendStream& stream = AscendStream::Null());
CV_EXPORTS_W void multiply(const Scalar& src1, const InputArray src2, OutputArray dst,
float scale = 1, int dtype = -1,
AscendStream& stream = AscendStream::Null());
#endif
/** @overload */
CV_EXPORTS_W void multiply(const AscendMat& src1, const AscendMat& src2, CV_OUT AscendMat& dst,
float scale = 1, int dtype = -1,
AscendStream& stream = AscendStream::Null());
/** @overload */
CV_EXPORTS_W void multiply(const AscendMat& src1, const Scalar& src2, CV_OUT AscendMat& dst,
float scale = 1, int dtype = -1,
AscendStream& stream = AscendStream::Null());
/** @overload */
CV_EXPORTS_W void multiply(const Scalar& src1, const AscendMat& src2, CV_OUT AscendMat& dst,
float scale = 1, int dtype = -1,
AscendStream& stream = AscendStream::Null());
/** @brief Computes a matrix-matrix or matrix-scalar division.
* @param src1 First source matrix or scalar.
* @param src2 Second source matrix or scalar. Matrix should have the same size and type as src1 .
* @param dst Destination matrix that has the same size and number of channels as the input
* array(s). The depth is defined by dtype or src1 depth.
* @param scale Optional scale factor.
* @param dtype Optional depth of the output array.
* @param stream AscendStream for the asynchronous version.
* @note when scale == 1, src must be one of the following types: float16, float32, double, uint16,
* int8, uint8, int16, int32, int64; when scale != 1, src must be one of the following types:
* int32, int16, float16, float32.
* @sa cv::divide cuda::divide
*/
CV_EXPORTS_W void divide(const InputArray src1, const InputArray src2, OutputArray dst,
float scale = 1, int dtype = -1,
AscendStream& stream = AscendStream::Null());
#ifdef NEVER_DEFINED
CV_EXPORTS_W void divide(const InputArray src1, const Scalar& src2, OutputArray dst,
float scale = 1, int dtype = -1,
AscendStream& stream = AscendStream::Null());
CV_EXPORTS_W void divide(const Scalar& src1, const InputArray src2, OutputArray dst,
float scale = 1, int dtype = -1,
AscendStream& stream = AscendStream::Null());
#endif
CV_EXPORTS_W void divide(const AscendMat& src1, const AscendMat& src2, CV_OUT AscendMat& dst,
float scale = 1, int dtype = -1,
AscendStream& stream = AscendStream::Null());
/** @overload */
CV_EXPORTS_W void divide(const AscendMat& src1, const Scalar& src2, CV_OUT AscendMat& dst,
float scale = 1, int dtype = -1,
AscendStream& stream = AscendStream::Null());
/** @overload */
CV_EXPORTS_W void divide(const Scalar& src1, const AscendMat& src2, CV_OUT AscendMat& dst,
float scale = 1, int dtype = -1,
AscendStream& stream = AscendStream::Null());
/** @brief Performs a per-element bitwise conjunction of two matrices (or of matrix and scalar).
* @param src1 First source matrix or scalar.
* @param src2 Second source matrix or scalar.
* @param dst Destination matrix that has the same size and number of channels as the input
* array(s). The depth is defined by dtype or src1 depth.
* @param mask Optional operation mask, 8-bit single channel array, that specifies elements of the
* destination array to be changed. The mask can be used only with single channel images.
* @param stream AscendStream for the asynchronous version.
* @note src must be one of the following types: int32, int16, uint16
* @sa cv::bitwise_and cuda::bitwise_and
*/
CV_EXPORTS_W void bitwise_and(const InputArray src1, const InputArray src2, OutputArray dst,
const InputArray mask = noArray(),
AscendStream& stream = AscendStream::Null());
#ifdef NEVER_DEFINED
CV_EXPORTS_W void bitwise_and(const InputArray src1, const Scalar& src2, OutputArray dst,
const InputArray mask = noArray(),
AscendStream& stream = AscendStream::Null());
CV_EXPORTS_W void bitwise_and(const Scalar& src1, const InputArray src2, OutputArray dst,
const InputArray mask = noArray(),
AscendStream& stream = AscendStream::Null());
#endif
CV_EXPORTS_W void bitwise_and(const AscendMat& src1, const AscendMat& src2, CV_OUT AscendMat& dst,
const AscendMat& mask = AscendMat(),
AscendStream& stream = AscendStream::Null());
/** @overload */
CV_EXPORTS_W void bitwise_and(const AscendMat& src1, const Scalar& src2, CV_OUT AscendMat& dst,
const AscendMat& mask = AscendMat(),
AscendStream& stream = AscendStream::Null());
/** @overload */
CV_EXPORTS_W void bitwise_and(const Scalar& src1, const AscendMat& src2, CV_OUT AscendMat& dst,
const AscendMat& mask = AscendMat(),
AscendStream& stream = AscendStream::Null());
/** @brief Performs a per-element bitwise disjunction of two matrices (or of matrix and scalar).
* @param src1 First source matrix or scalar.
* @param src2 Second source matrix or scalar.
* @param dst Destination matrix that has the same size and number of channels as the input
* array(s). The depth is defined by dtype or src1 depth.
* @param mask Optional operation mask, 8-bit single channel array, that specifies elements of the
* destination array to be changed. The mask can be used only with single channel images.
* @param stream AscendStream for the asynchronous version.
* @note src must be one of the following types: int32, int16, uint16
* @sa cv::bitwise_or cuda::bitwise_or
*/
CV_EXPORTS_W void bitwise_or(const InputArray src1, const InputArray src2, OutputArray dst,
const InputArray mask = noArray(),
AscendStream& stream = AscendStream::Null());
#ifdef NEVER_DEFINED
CV_EXPORTS_W void bitwise_or(const InputArray src1, const Scalar& src2, OutputArray dst,
const InputArray mask = noArray(),
AscendStream& stream = AscendStream::Null());
CV_EXPORTS_W void bitwise_or(const Scalar& src1, const InputArray src2, OutputArray dst,
const InputArray mask = noArray(),
AscendStream& stream = AscendStream::Null());
#endif
CV_EXPORTS_W void bitwise_or(const AscendMat& src1, const AscendMat& src2, CV_OUT AscendMat& dst,
const AscendMat& mask = AscendMat(),
AscendStream& stream = AscendStream::Null());
/** @overload */
CV_EXPORTS_W void bitwise_or(const AscendMat& src1, const Scalar& src2, CV_OUT AscendMat& dst,
const AscendMat& mask = AscendMat(),
AscendStream& stream = AscendStream::Null());
/** @overload */
CV_EXPORTS_W void bitwise_or(const Scalar& src1, const AscendMat& src2, CV_OUT AscendMat& dst,
const AscendMat& mask = AscendMat(),
AscendStream& stream = AscendStream::Null());
/** @brief Performs a per-element bitwise exclusive or operation of two matrices (or of matrix and
* scalar).
* @param src1 First source matrix or scalar.
* @param src2 Second source matrix or scalar.
* @param dst Destination matrix that has the same size and number of channels as the input
* array(s). The depth is defined by dtype or src1 depth.
* @param mask Optional operation mask, 8-bit single channel array, that specifies elements of the
* destination array to be changed. The mask can be used only with single channel images.
* @param stream AscendStream for the asynchronous version.
* @note src must be one of the following types: int32, int16, uint16
* @sa cv::bitwise_xor cuda::bitwise_xor
*/
CV_EXPORTS_W void bitwise_xor(const InputArray src1, const InputArray src2, OutputArray dst,
const InputArray mask = noArray(),
AscendStream& stream = AscendStream::Null());
#ifdef NEVER_DEFINED
CV_EXPORTS_W void bitwise_xor(const InputArray src1, const Scalar& src2, OutputArray dst,
const InputArray mask = noArray(),
AscendStream& stream = AscendStream::Null());
CV_EXPORTS_W void bitwise_xor(const Scalar& src1, const InputArray src2, OutputArray dst,
const InputArray mask = noArray(),
AscendStream& stream = AscendStream::Null());
#endif
CV_EXPORTS_W void bitwise_xor(const AscendMat& src1, const AscendMat& src2, CV_OUT AscendMat& dst,
const AscendMat& mask = AscendMat(),
AscendStream& stream = AscendStream::Null());
/** @overload */
CV_EXPORTS_W void bitwise_xor(const AscendMat& src1, const Scalar& src2, CV_OUT AscendMat& dst,
const AscendMat& mask = AscendMat(),
AscendStream& stream = AscendStream::Null());
/** @overload */
CV_EXPORTS_W void bitwise_xor(const Scalar& src1, const AscendMat& src2, CV_OUT AscendMat& dst,
const AscendMat& mask = AscendMat(),
AscendStream& stream = AscendStream::Null());
/** @brief Performs a per-element bitwise inversion.
* @param src First source matrix.
* @param dst Destination matrix that has the same size and number of channels as the input
* array(s). The depth is defined by dtype or src1 depth.
* @param mask Optional operation mask, 8-bit single channel array, that specifies elements of the
* destination array to be changed. The mask can be used only with single channel images.
* @param stream AscendStream for the asynchronous version.
* @note src must be one of the following types: int32, int16, uint16
* @sa cv::bitwise_not cuda::bitwise_not
*/
CV_EXPORTS_W void bitwise_not(const InputArray src, OutputArray dst,
const InputArray mask = noArray(),
AscendStream& stream = AscendStream::Null());
/** @overload */
CV_EXPORTS_W void bitwise_not(const AscendMat& src, CV_OUT AscendMat& dst,
const AscendMat& mask = AscendMat(),
AscendStream& stream = AscendStream::Null());
/** @brief Computes the weighted sum of two arrays.
@param src1 First source array.
@param alpha Weight for the first array elements.
@param src2 Second source array of the same size and channel number as src1 .
@param beta Weight for the second array elements.
@param dst Destination array that has the same size and number of channels as the input arrays.
@param gamma Scalar added to each sum.
@param dtype Optional depth of the destination array. When both input arrays have the same depth,
dtype can be set to -1, which will be equivalent to src1.depth().
@param stream Stream for the asynchronous version.
The function addWeighted calculates the weighted sum of two arrays as follows:
\f[\texttt{dst} (I)= \texttt{saturate} ( \texttt{src1} (I)* \texttt{alpha} + \texttt{src2} (I)*
\texttt{beta} + \texttt{gamma} )\f]
where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each
channel is processed independently.
@note src must be one of the following types: int32, int16, float16, float32.
@sa cv::addWeighted cv::cuda::addWeighted
*/
CV_EXPORTS_W void addWeighted(const InputArray src1, double alpha, const InputArray src2,
double beta, double gamma, OutputArray dst, int dtype = -1,
AscendStream& stream = AscendStream::Null());
/** @overload */
CV_EXPORTS_W void addWeighted(const AscendMat& src1, double alpha, const AscendMat& src2,
double beta, double gamma, CV_OUT AscendMat& dst, int dtype = -1,
AscendStream& stream = AscendStream::Null());
/** @brief Applies a fixed-level threshold to each array element.
@param src Source array (single-channel).
@param dst Destination array with the same size and type as src .
@param thresh Threshold value.
@param maxval Maximum value to use with THRESH_BINARY and THRESH_BINARY_INV threshold types.
@param type Threshold type. For details, see threshold . The THRESH_MASK, THRESH_OTSU and
THRESH_TRIANGLE threshold types are not supported.
@param stream AscendStream for the asynchronous version.
@note src must be one of the following types: float16, float32.
@sa cv::threshold cv::cuda::threshold
*/
CV_EXPORTS_W double threshold(const InputArray src, OutputArray dst, double thresh, double maxval,
int type, AscendStream& stream = AscendStream::Null());
/** @overload */
CV_EXPORTS_W double threshold(const AscendMat& src, CV_OUT AscendMat& dst, double thresh,
double maxval, int type, AscendStream& stream = AscendStream::Null());
//! @} cannops_elem
//! @addtogroup cannops_core
//! @{
/** @brief Makes a multi-channel matrix out of several single-channel matrices.
@param src Array/vector of source matrices.
@param n Number of source matrices.
@param dst Destination matrix.
@param stream AscendStream for the asynchronous version.
@note src must be one of the following types: float16, float32, double, int32, int16, int8, int64,
uint8, uint16, uint32, uint64.
@sa cv::merge cv::cuda::merge
*/
CV_EXPORTS_W void merge(const AscendMat* src, size_t n, CV_OUT AscendMat& dst,
AscendStream& stream = AscendStream::Null());
/** @overload */
CV_EXPORTS_W void merge(const std::vector<AscendMat>& src, CV_OUT AscendMat& dst,
AscendStream& stream = AscendStream::Null());
/** @overload */
CV_EXPORTS_W void merge(const AscendMat* src, size_t n, OutputArray& dst,
AscendStream& stream = AscendStream::Null());
/** @overload */
CV_EXPORTS_W void merge(const std::vector<AscendMat>& src, OutputArray& dst,
AscendStream& stream = AscendStream::Null());
/** @brief Copies each plane of a multi-channel matrix into an array.
@param src Source matrix.
@param dst Destination array/vector of single-channel matrices.
@param stream AscendStream for the asynchronous version.
@note src must be one of the types:float16, float32, double, int64, int32, uint8, uint16, uint32,
uint64, int8, int16, bool
@sa cv::split cv::cuda::split
*/
CV_EXPORTS_W void split(const AscendMat& src, AscendMat* dst,
AscendStream& stream = AscendStream::Null());
/** @overload */
CV_EXPORTS_W void split(const AscendMat& src, CV_OUT std::vector<AscendMat>& dst,
AscendStream& stream = AscendStream::Null());
/** @overload */
CV_EXPORTS_W void split(const InputArray src, AscendMat* dst,
AscendStream& stream = AscendStream::Null());
/** @overload */
CV_EXPORTS_W void split(const InputArray src, CV_OUT std::vector<AscendMat>& dst,
AscendStream& stream = AscendStream::Null());
/** @brief Transposes a matrix.
@param src Source matrix.
@param dst Destination matrix.
@param stream AscendStream for the asynchronous version.
@note src must be one of the following types:
float16,float,int8,int16,int32,int64,uint8,uint16,uint32,uint64,bool
@sa cv::transpose cv::cuda::transpose
*/
CV_EXPORTS_W void transpose(InputArray src, OutputArray dst,
AscendStream& stream = AscendStream::Null());
/** @overload */
CV_EXPORTS_W void transpose(const AscendMat& src, CV_OUT AscendMat& dst,
AscendStream& stream = AscendStream::Null());
/** @brief Flips a 2D matrix around vertical, horizontal, or both axes.
@param src Source matrix.
@param dst Destination matrix.
@param flipCode Flip mode for the source:
- 0 Flips around x-axis.
- \> 0 Flips around y-axis.
- \< 0 Flips around both axes.
@param stream AscendStream for the asynchronous version.
@note src must be one of the following types: float16,float,int64,int32,int16,uint16
@sa cv::flip cv::cuda::flip
*/
CV_EXPORTS_W void flip(InputArray src, OutputArray dst, int flipCode,
AscendStream& stream = AscendStream::Null());
/** @overload */
CV_EXPORTS_W void flip(const AscendMat& src, CV_OUT AscendMat& dst, int flipCode,
AscendStream& stream = AscendStream::Null());
/** @brief Rotates a 2D array in multiples of 90 degrees.
The function cv::rotate rotates the array in one of three different ways:
* Rotate by 90 degrees clockwise (rotateCode = ROTATE_90_CLOCKWISE).
* Rotate by 180 degrees clockwise (rotateCode = ROTATE_180).
* Rotate by 270 degrees clockwise (rotateCode = ROTATE_90_COUNTERCLOCKWISE).
@param src input array.
@param dst output array of the same type as src. The size is the same with ROTATE_180,
and the rows and cols are switched for ROTATE_90_CLOCKWISE and ROTATE_90_COUNTERCLOCKWISE.
@param rotateCode an enum to specify how to rotate the array; see the enum #RotateFlags
@param stream AscendStream for the asynchronous version.
@note src must be one of the following types: float16,float,int64,int32,int16,uint16
@sa cv::rotate
*/
CV_EXPORTS_W void rotate(InputArray src, OutputArray dst, int rotateCode,
AscendStream& stream = AscendStream::Null());
/** @overload */
CV_EXPORTS_W void rotate(const AscendMat& src, CV_OUT AscendMat& dst, int rotateMode,
AscendStream& stream = AscendStream::Null());
/** @brief crop a 2D array.
The function crops the matrix by given cv::Rect.
Output matrix must be of the same depth as input one, size is specified by given rect size.
@param src input array.
@param rect a rect to crop a array to
@param stream AscendStream for the asynchronous version.
@sa cv::gapi::crop
*/
CV_EXPORTS_W AscendMat crop(InputArray src, const Rect& rect,
AscendStream& stream = AscendStream::Null());
/** @overload */
CV_EXPORTS_W AscendMat crop(const AscendMat& src, const Rect& rect,
AscendStream& stream = AscendStream::Null());
//! interpolation algorithm
enum InterpolationFlags
{
/** nearest neighbor interpolation */
INTER_NEAREST = 0,
/** bilinear interpolation */
INTER_LINEAR = 1,
/** bicubic interpolation */
INTER_CUBIC = 2,
/** resampling using pixel area relation. It may be a preferred method for image decimation, as
it gives moire'-free results. But when the image is zoomed, it is similar to the INTER_NEAREST
method. */
INTER_AREA = 3,
/** mask for interpolation codes */
INTER_MAX = 7,
};
/** @brief Resizes an image src down to or up to the specified size.
@param src input image
@param dst output image; it has the size dsize (when it is non-zero) or the size computed from
src.size(), fx, and fy; the type of dst is the same as of src.
@param dsize output image size; if it equals zero, it is computed as:
\f[ππππ£π = πππ£π(πππππ(ππ‘*πππ.ππππ), πππππ(ππ’*πππ.πππ π))\f]
Either dsize or both fx and fy must be non-zero.
@param fx scale factor along the horizontal axis; when it equals 0, it is computed as
\f[(ππππππ)ππππ£π.π ππππ/πππ.ππππ\f]
@param fy scale factor along the vertical axis; when it equals 0, it is computed as
\f[(ππππππ)ππππ£π.ππππππ/πππ.πππ π\f]
@param interpolation interpolation method(see **cv.cann.InterpolationFlags**)
@param stream AscendStream for the asynchronous version.
* @note There are some constraints for the input datatype:
* when resampling using
* nearest neighbor or bilinear interpolation: Input images must be uint8, and only GRAY and BGR
images are supported. The resolution of input and output images must in range of [10*6,
4096*4096].
* bicubic interpolation: Input images can be of different types, output images must be
float or uint8.
* pixel area interpolation: Input images can be of different types but output images
are always float.\n
* Only the following devices are supported when resampling using nearest neighbor or bilinear
interpolation: Atlas Inference Series products, Atlas 200/500 A2 Inference products and
Atlas A2 Training Series products/Atlas 300I A2 Inference products
@sa cv::resize
*/
CV_EXPORTS_W void resize(InputArray src, OutputArray dst, Size dsize, double fx, double fy,
int interpolation, AscendStream& stream = AscendStream::Null());
/** @overload */
CV_EXPORTS_W void resize(const AscendMat& src, CV_OUT AscendMat& dst, Size dsize, double fx,
double fy, int interpolation, AscendStream& stream = AscendStream::Null());
/** @brief crop a sub image from a big one, and resize it to certain size.
@param src input array.
@param dst output array. it has the size dsize (when it is non-zero) or the size computed from
src.size(), fx, and fy; the type of dst is the same as of src.
@param rect a rect to crop a array to
@param dsize output image size; if it equals zero, it is computed as cv::resize do.
@param fx scale factor along the horizontal axis; when it equals 0, it is computed as
\f[(ππππππ)ππππ£π.π ππππ/πππ.ππππ\f]
@param fy scale factor along the vertical axis; when it equals 0, it is computed as
\f[(ππππππ)ππππ£π.ππππππ/πππ.πππ π\f]
@param interpolation interpolation method, only support INTER_NEAREST and INTER_LINEAR here.
(see **cv.cann.InterpolationFlags**)
@note The input images must be uint8, and only GRAY and BGR images are supported. The resolution of
input and output images must in range of [10*6, 4096*4096].
@note Only the following devices are supported: Atlas Inference Series products, Atlas 200/500 A2
Inference products and Atlas A2 Training Series products/Atlas 300I A2 Inference products.
@sa cv::gapi::crop, cv::resize, cv::cann::resize
*/
CV_EXPORTS_W void cropResize(const InputArray src, OutputArray dst, const Rect& rect, Size dsize,
double fx, double fy, int interpolation);
/** @overload */
CV_EXPORTS_W void cropResize(const AscendMat& src, CV_OUT AscendMat& dst, const Rect& rect,
Size dsize, double fx, double fy, int interpolation);
/** @brief crop a sub image from a big one, resize it to certain size, and form the top/left border
and fills it with specified bordertype.
@param src input array.
@param dst output array; it has the size Size(dsize.height + top, dsize.width + left).
@param rect a rect to crop a array to
@param dsize resize size;
@param fx scale factor along the horizontal axis;
@param fy scale factor along the vertical axis;
@param interpolation interpolation method, only INTER_NEAREST and INTER_LINEAR are supported.
(see **cv.cann.InterpolationFlags**)
@param borderType border extrapolate method, only cv::BorderTypes::BORDER_CONSTANT and
cv::BorderTypes::BORDER_REPLICATE are supported.
@param value Border BGR or YUV value if borderType==BORDER_CONSTANT.
@param top Number of pixels for top padding
@param left Number of pixels for left padding
@note The input images must be uint8, and only GRAY and BGR images are supported. The resolution of
input and output images must in range of [10*6, 4096*4096].
@note Only the following devices are supported: Atlas Inference Series products, Atlas 200/500 A2
Inference products and Atlas A2 Training Series products/Atlas 300I A2 Inference products.
@sa cv::gapi::crop, cv::resize, cv::cann::resize, cv::BorderTypes
*/
CV_EXPORTS_W void cropResizeMakeBorder(const InputArray src, OutputArray dst, const Rect& rect,
Size dsize, double fx, double fy, int interpolation, int top,
int left, const int borderType, Scalar value = Scalar());
/** @overload */
CV_EXPORTS_W void cropResizeMakeBorder(const AscendMat& src, CV_OUT AscendMat& dst,
const Rect& rect, Size dsize, double fx, double fy,
int interpolation, int top, int left, const int borderType,
Scalar value = Scalar());
/** @brief Forms a border and fills it with specified bordertype around the copy of input image.
@param src Source image.
@param dst Destination image of the same type as src and the size Size(src.cols+left+right,
src.rows+top+bottom).
@param top Number of pixels for top padding
@param bottom Number of pixels for bottom padding
@param left Number of pixels for left padding
@param right Number of pixels for right padding
Parameter specifying how many pixels in each direction from the source image rectangle to
extrapolate. For example, top=1, bottom=1, left=1, right=1 mean that 1 pixel-wide border needs to be
built.
@param borderType Border type. only cv::BorderTypes::BORDER_CONSTANT and
cv::BorderTypes::BORDER_REPLICATE are supported.
@param value Border BGR or YUV value if borderType==BORDER_CONSTANT.
@note The input images must be uint8, and only GRAY and BGR images are supported. The resolution of
input and output images must in range of [10*6, 4096*4096].
@note Only the following devices are supported: Atlas Inference Series products, Atlas 200/500 A2
Inference products and Atlas A2 Training Series products/Atlas 300I A2 Inference products.
@sa cv::copyMakeBorder, cv::borderInterpolate
*/
CV_EXPORTS_W void copyMakeBorder(const InputArray src, OutputArray dst, int top, int bottom,
int left, int right, int borderType,
const Scalar& value = Scalar());
/** @overload */
CV_EXPORTS_W void copyMakeBorder(const AscendMat& src, CV_OUT AscendMat& dst, int top, int bottom,
int left, int right, int borderType,
const Scalar& value = Scalar());
//! @} cannops_core
//! @addtogroup cannimgproc
//! @{
/** @brief Converts an image from one color space to another.
@param src Source image with CV_8U , CV_16U , or CV_32F depth and 1, 3, or 4 channels.
@param dst Destination image.
@param code Color space conversion code. For details, see cv::ColorConversionCodes .
@param dstCn Number of channels in the destination image. If the parameter is 0, the number of the
channels is derived automatically from src and the code .
@param stream AscendStream for the asynchronous version.
@note The supported conversion types are as follows:
{ CV_BGR2BGRA, CV_BGRA2BGR, CV_BGR2RGBA, CV_RGBA2BGR,
CV_BGR2RGB, CV_BGRA2RGBA, CV_BGR2GRAY, CV_RGB2GRAY,
CV_GRAY2BGR, CV_GRAY2BGRA, CV_BGRA2GRAY, CV_RGBA2GRAY,
CV_BGR2XYZ, CV_RGB2XYZ, CV_XYZ2BGR, CV_XYZ2RGB,
CV_BGR2YCrCb, CV_RGB2YCrCb, CV_YCrCb2BGR, CV_YCrCb2RGB,
CV_BGR2YUV, CV_RGB2YUV, CV_YUV2BGR, CV_YUV2RGB }
@sa cv::cvtColor cv::cuda::cvtColor
*/
CV_EXPORTS_W void cvtColor(const InputArray src, OutputArray dst, int code, int dstCn = 0,
AscendStream& stream = AscendStream::Null());
/** @overload */
CV_EXPORTS_W void cvtColor(const AscendMat& src, CV_OUT AscendMat& dst, int code, int dstCn = 0,
AscendStream& stream = AscendStream::Null());
//! @} cannimgproc
} // namespace cann
} // namespace cv
#endif // OPENCV_CANNOPS_CANN_INTERFACE_HPP