Skip to content

Commit

Permalink
Fix code according to review
Browse files Browse the repository at this point in the history
1. Delete the macro definition ENABLE_DVPP_INTERFACE in modules/cannops/src/dvpp_call.cpp
2. Add dvpp interface version and supported device description
  • Loading branch information
MengqingCao committed Jan 15, 2024
1 parent 5570ce5 commit 1386f6b
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 29 deletions.
5 changes: 5 additions & 0 deletions modules/cannops/include/opencv2/cann.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,16 @@ CV_EXPORTS_W void finalizeAcl();

/**
* @brief init DVPP system.
* @note The DVPP interfaces used are all version V2.
* Supported devices: Atlas Inference Series products, Atlas 200/500 A2 Inference products and
* Atlas A2 Training Series products/Atlas 300I A2 Inference products
*/
CV_EXPORTS_W void initDvpp();

/**
* @brief finalize DVPP system.
* @note Supported devices: Atlas Inference Series products, Atlas 200/500 A2 Inference products and
* Atlas A2 Training Series products/Atlas 300I A2 Inference products
*/
CV_EXPORTS_W void finalizeDvpp();

Expand Down
60 changes: 36 additions & 24 deletions modules/cannops/include/opencv2/cann_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,29 +463,6 @@ CV_EXPORTS_W AscendMat crop(InputArray src, const Rect& rect,
/** @overload */
CV_EXPORTS_W AscendMat crop(const AscendMat& src, const Rect& rect,
AscendStream& stream = AscendStream::Null());
/** @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**)
@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.
@sa cv::resize
*/

//! interpolation algorithm
enum InterpolationFlags
Expand All @@ -504,6 +481,34 @@ enum InterpolationFlags
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 */
Expand All @@ -524,6 +529,8 @@ src.size(), fx, and fy; the type of dst is the same as of src.
(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,
Expand All @@ -532,7 +539,8 @@ CV_EXPORTS_W void cropResize(const InputArray src, OutputArray dst, const Rect&
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, and resize it to certain size.
/** @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
Expand All @@ -548,6 +556,8 @@ cv::BorderTypes::BORDER_REPLICATE are supported.
@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
*/

Expand Down Expand Up @@ -575,6 +585,8 @@ 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,
Expand Down
13 changes: 12 additions & 1 deletion modules/cannops/include/opencv2/dvpp_call.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ struct AscendPicDesc
AscendPicDesc(const Mat& mat, hi_pixel_format _picture_format);
};

/******************************hi_mpi_vpc warppers****************************/
/*
***************************** hi_mpi_vpc warppers ***************************
The DVPP VPC interfaces here are all version v2. 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.
*/
inline void vpcResizeWarpper(hi_vpc_chn chnId, hi_vpc_pic_info& inPic, hi_vpc_pic_info& outPic,
int interpolation, uint32_t* taskID)
{
Expand All @@ -59,6 +64,12 @@ void vpcCopyMakeBorderWarpper(hi_vpc_chn chnId, hi_vpc_pic_info& inPic, hi_vpc_p
uint32_t* taskID, int* offsets, int bordertype, Scalar value);
/*****************************************************************************/

/**
* @brief Interface for calling DVPP operator descriptors.
* The DVPP VPC interfaces here are all version v2. Supported devices: Atlas Inference Series
* products, Atlas 200/500 A2 Inference products and Atlas A2 Training Series products/Atlas 300I A2
* Inference products.
*/
class DvppOperatorDesc
{
private:
Expand Down
4 changes: 0 additions & 4 deletions modules/cannops/src/dvpp_call.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// 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 ENABLE_DVPP_INTERFACE
#define ENABLE_DVPP_INTERFACE

#include <acl/acl.h>
#include <acl/dvpp/hi_dvpp.h>
Expand Down Expand Up @@ -310,5 +308,3 @@ DvppOperatorDesc& DvppOperatorDesc::getResult(AscendMat& dst, uint32_t& taskIDRe

} // namespace cann
} // namespace cv

#endif // ENABLE_DVPP_INTERFACE

0 comments on commit 1386f6b

Please sign in to comment.