Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

As/xuezha 2nd post bindings #3853

Closed
wants to merge 11 commits into from
3 changes: 1 addition & 2 deletions modules/fastcv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ FastCV extension for OpenCV

This module provides wrappers for several FastCV functions not covered by the corresponding HAL in OpenCV or have implementation incompatible with OpenCV.
Please note that:
1. This module supports ARM architecture only. This means that CMake script aborts configuration under x86 platform even if you don't want to build binaries for your machine and just want to build docs or enable code analysis in your IDE. In that case you should fix CMakeLists.txt file as told inside it.
2. Test data is stored in misc folder. Before running tests on a device you should copy the content of `misc/` folder to `$YOUR_TESTDATA_PATH/fastcv/` folder on a device.
1. This module supports ARM architecture only. This means that CMake script will not configure or build under x86 platform.
8 changes: 7 additions & 1 deletion modules/fastcv/include/opencv2/fastcv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,29 @@

#include "opencv2/fastcv/arithm.hpp"
#include "opencv2/fastcv/bilateralFilter.hpp"
#include "opencv2/fastcv/blur.hpp"
#include "opencv2/fastcv/cluster.hpp"
#include "opencv2/fastcv/draw.hpp"
#include "opencv2/fastcv/edges.hpp"
#include "opencv2/fastcv/fast10.hpp"
#include "opencv2/fastcv/fft.hpp"
#include "opencv2/fastcv/hough.hpp"
#include "opencv2/fastcv/ipptransform.hpp"
#include "opencv2/fastcv/moments.hpp"
#include "opencv2/fastcv/mser.hpp"
#include "opencv2/fastcv/pyramid.hpp"
#include "opencv2/fastcv/remap.hpp"
#include "opencv2/fastcv/scale.hpp"
#include "opencv2/fastcv/shift.hpp"
#include "opencv2/fastcv/smooth.hpp"
#include "opencv2/fastcv/thresh.hpp"
#include "opencv2/fastcv/tracking.hpp"
#include "opencv2/fastcv/warp.hpp"

/**
* @defgroup fastcv Module-wrapper for FastCV hardware accelerated functions
* @{
* @}
*/

#endif // OPENCV_FASTCV_ARITHM_HPP
#endif // OPENCV_FASTCV_HPP
3 changes: 2 additions & 1 deletion modules/fastcv/include/opencv2/fastcv/arithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ namespace fastcv {

/**
* @brief Matrix multiplication of two int8_t type matrices

* uses signed integer input/output whereas cv::gemm uses floating point input/output
* matmuls8s32 provides enhanced speed on Qualcomm's processors
* @param src1 First source matrix of type CV_8S
* @param src2 Second source matrix of type CV_8S
* @param dst Resulting matrix of type CV_32S
Expand Down
64 changes: 64 additions & 0 deletions modules/fastcv/include/opencv2/fastcv/blur.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef OPENCV_FASTCV_BLUR_HPP
#define OPENCV_FASTCV_BLUR_HPP

#include <opencv2/core.hpp>

namespace cv {
namespace fastcv {

/**
* @defgroup fastcv Module-wrapper for FastCV hardware accelerated functions
*/

//! @addtogroup fastcv
//! @{

/**
* @brief Gaussian blur with sigma = 0 and square kernel size. The way of handling borders is different with cv::GaussianBlur,
* leading to slight variations in the output.
* @param _src Intput image with type CV_8UC1
* @param _dst Output image with type CV_8UC1
* @param kernel_size Filer kernel size. One of 3, 5, 11
* @param blur_border If set to true, border is blurred by 0-padding adjacent values.(A variant of the constant border)
* If set to false, borders up to half-kernel width are ignored (e.g. 1 pixel in the 3x3 case).
*
* @sa GaussianBlur
*/
CV_EXPORTS_W void gaussianBlur(InputArray _src, OutputArray _dst, int kernel_size = 3, bool blur_border = true);

/**
* @brief NxN correlation with non-separable kernel. Borders up to half-kernel width are ignored
* @param _src Intput image with type CV_8UC1
* @param _dst Output image with type CV_8UC1, CV_16SC1 or CV_32FC1
* @param ddepth The depth of output image
* @param _kernel Filer kernel data
*
* @sa Filter2D
*/
CV_EXPORTS_W void filter2D(InputArray _src, OutputArray _dst, int ddepth, InputArray _kernel);

/**
* @brief NxN correlation with separable kernel. If srcImg and dstImg point to the same address and srcStride equals to dstStride,
* it will do in-place. Borders up to half-kernel width are ignored.
* The way of handling overflow is different with OpenCV, this function will do right shift for
* the intermediate results and final result.
* @param _src Intput image with type CV_8UC1
* @param _dst Output image with type CV_8UC1, CV_16SC1
* @param ddepth The depth of output image
* @param _kernelX Filer kernel data in x direction
* @param _kernelY Filer kernel data in Y direction (For CV_16SC1, the kernelX and kernelY should be same)
*
* @sa sepFilter2D
*/
CV_EXPORTS_W void sepFilter2D(InputArray _src, OutputArray _dst, int ddepth, InputArray _kernelX, InputArray _kernelY);
//! @}

} // fastcv::
} // cv::

#endif // OPENCV_FASTCV_BLUR_HPP
3 changes: 2 additions & 1 deletion modules/fastcv/include/opencv2/fastcv/cluster.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ namespace fastcv {

/**
* @brief Clusterizes N input points in D-dimensional space into K clusters
*
* Accepts 8-bit unsigned integer points
* Provides faster execution time than cv::kmeans on Qualcomm's processors
* @param points Points array of type 8u, each row represets a point.
* Size is N rows by D columns, can be non-continuous.
* @param clusterCenters Initial cluster centers array of type 32f, each row represents a center.
Expand Down
2 changes: 1 addition & 1 deletion modules/fastcv/include/opencv2/fastcv/draw.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace fastcv {
/**
* @brief Draw convex polygon
This function fills the interior of a convex polygon with the specified color.

Requires the width and stride to be multple of 8.
* @param img Image to draw on. Should have up to 4 8-bit channels
* @param pts Array of polygon points coordinates. Should contain N two-channel or 2*N one-channel 32-bit integer elements
* @param color Color of drawn polygon stored as B,G,R and A(if supported)
Expand Down
53 changes: 53 additions & 0 deletions modules/fastcv/include/opencv2/fastcv/edges.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef OPENCV_EDGES_HPP
#define OPENCV_EDGES_HPP

#include "opencv2/core/mat.hpp"

namespace cv {
namespace fastcv {
/**
* @defgroup fastcv Module-wrapper for FastCV hardware accelerated functions
*/

//! @addtogroup fastcv
//! @{

/**
* @brief Creates a 2D gradient image from source luminance data without normalization.
* Calculate X direction 1 order derivative or Y direction 1 order derivative or both at the same time, .
* @param _src Input image with type CV_8UC1
* @param _dx Buffer to store horizontal gradient. Must be (dxyStride)*(height) bytes in size.
* If NULL, the horizontal gradient will not be calculated.
* @param _dy Buffer to store vertical gradient. Must be (dxyStride)*(height) bytes in size.
* If NULL, the vertical gradient will not be calculated
* @param kernel_size Sobel kernel size, support 3x3, 5x5, 7x7
* @param borderType Border type, support BORDER_CONSTANT, BORDER_REPLICATE
* @param borderValue Border value for constant border
*/
CV_EXPORTS_W void sobel(InputArray _src, OutputArray _dx, OutputArray _dy, int kernel_size, int borderType, int borderValue);

/**
* @brief Creates a 2D gradient image from source luminance data without normalization.
* This function computes central differences on 3x3 neighborhood and then convolves the result with Sobel kernel,
* borders up to half-kernel width are ignored.
* @param _src Input image with type CV_8UC1
* @param _dst If _dsty is given, buffer to store horizontal gradient, otherwise, output 8-bit image of |dx|+|dy|.
* Size of buffer is (srcwidth)*(srcheight) bytes
* @param _dsty (Optional)Buffer to store vertical gradient. Must be (srcwidth)*(srcheight) in size.
* @param ddepth The depth of output image CV_8SC1,CV_16SC1,CV_32FC1,
* @param normalization If do normalization for the result
*/
CV_EXPORTS_W void sobel3x3u8(InputArray _src, OutputArray _dst, OutputArray _dsty = noArray(), int ddepth = CV_8U,
bool normalization = false);

//! @}

}
}

#endif
7 changes: 4 additions & 3 deletions modules/fastcv/include/opencv2/fastcv/fast10.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ namespace fastcv {
//! @{

/**
* @brief Extracts FAST corners and scores from the image based on the mask.
The mask specifies pixels to be ignored by the detector

* @brief Extracts FAST10 corners and scores from the image based on the mask.
* The mask specifies pixels to be ignored by the detector
* designed for corner detection on Qualcomm's processors, provides enhanced speed.
*
* @param src 8-bit grayscale image
* @param mask Optional mask indicating which pixels should be omited from corner dection.
Its size should be k times image width and height, where k = 1/2, 1/4 , 1/8 , 1, 2, 4 and 8
Expand Down
2 changes: 1 addition & 1 deletion modules/fastcv/include/opencv2/fastcv/fft.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace fastcv {
* @brief Computes the 1D or 2D Fast Fourier Transform of a real valued matrix.
For the 2D case, the width and height of the input and output matrix must be powers of 2.
For the 1D case, the height of the matrices must be 1, while the width must be a power of 2.

Accepts 8-bit unsigned integer array, whereas cv::dft accepts floating-point or complex array.
* @param src Input array of CV_8UC1. The dimensions of the matrix must be powers of 2 for the 2D case,
and in the 1D case, the height must be 1, while the width must be a power of 2.
* @param dst The computed FFT matrix of type CV_32FC2. The FFT Re and Im coefficients are stored in different channels.
Expand Down
23 changes: 22 additions & 1 deletion modules/fastcv/include/opencv2/fastcv/hough.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace fastcv {

/**
* @brief Performs Hough Line detection
*
*
* @param src Input 8-bit image containing binary contour. Width and step should be divisible by 8
* @param lines Output array containing detected lines in a form of (x1, y1, x2, y2) where all numbers are 32-bit floats
* @param threshold Controls the minimal length of a detected line. Value must be between 0.0 and 1.0
Expand All @@ -25,6 +25,27 @@ namespace fastcv {
*/
CV_EXPORTS_W void houghLines(InputArray src, OutputArray lines, double threshold = 0.25);


/**
* @brief Finds circles in a grayscale image using Hough transform.
* The radius of circle varies from 0 to max(srcWidth, srcHeight).
*
* @param src Input 8-bit image containing binary contour. Step should be divisible by 8, data start should be 128-bit aligned
* @param circles Output array containing detected circles in a form (x, y, r) where all numbers are 32-bit integers
* @param minDist Minimum distance between the centers of the detected circles
* @param cannyThreshold The higher threshold of the two passed to the Canny() edge detector
* (the lower one is twice smaller). Default is 100.
* @param accThreshold The accumulator threshold for the circle centers at the detection
* stage. The smaller it is, the more false circles may be detected.
* Circles, corresponding to the larger accumulator values, will be
* returned first. Default is 100.
* @param minRadius Minimum circle radius, default is 0
* @param maxRadius Maximum circle radius, default is 0
*/
CV_EXPORTS_W void houghCircles(InputArray src, OutputArray circles, uint32_t minDist,
uint32_t cannyThreshold = 100, uint32_t accThreshold = 100,
uint32_t minRadius = 0, uint32_t maxRadius = 0);

//! @}

} // fastcv::
Expand Down
39 changes: 39 additions & 0 deletions modules/fastcv/include/opencv2/fastcv/ipptransform.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef OPENCV_FASTCV_IPPTRANSFORM_HPP
#define OPENCV_FASTCV_IPPTRANSFORM_HPP

#include <opencv2/core.hpp>

namespace cv {
namespace fastcv {

//! @addtogroup fastcv
//! @{

/**
* @brief This function performs 8x8 forward discrete Cosine transform on input image
* accepts input of type 8-bit unsigned integer and produces output of type 16-bit signed integer
* provides faster execution time than cv::dct on Qualcomm's processor
* @param src Input image of type CV_8UC1
* @param dst Output image of type CV_16SC1
*/
CV_EXPORTS_W void DCT(InputArray src, OutputArray dst);

/**
* @brief This function performs 8x8 inverse discrete Cosine transform on input image
* provides faster execution time than cv::dct in inverse case on Qualcomm's processor
* @param src Input image of type CV_16SC1
* @param dst Output image of type CV_8UC1
*/
CV_EXPORTS_W void IDCT(InputArray src, OutputArray dst);

//! @}

} // fastcv::
} // cv::

#endif // OPENCV_FASTCV_IPPTRANSFORM_HPP
5 changes: 3 additions & 2 deletions modules/fastcv/include/opencv2/fastcv/moments.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ namespace fastcv {
/**
* @brief Calculates all of the moments up to the third order of the image pixels' intensities
The results are returned in the structure cv::Moments.
* @param _src Input image with type CV_8UC1, CV_32SC1, CV_32FC1
* @param binary If 1, binary image (0x00-black, oxff-white); if 0, grayscale image
* @param _src Input image with type CV_8UC1, CV_32SC1, CV_32FC1
* @param binary If true, assumes the image to be binary (0x00 for black, 0xff for white), otherwise assumes the image to be
* grayscale.
*/
CV_EXPORTS cv::Moments moments(InputArray _src, bool binary);

Expand Down
Loading