Skip to content

Commit 2c7591c

Browse files
Merge pull request #3824 from CodeLinaro:FastcvHAL_1stPost
Depends on opencv/opencv#26316 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [ ] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
1 parent 5409e01 commit 2c7591c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+3629
-0
lines changed

modules/fastcv/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
if(HAVE_FASTCV)
2+
set(the_description "Qualcomm FastCV accelerated functions")
3+
ocv_define_module(fastcv opencv_core opencv_imgproc opencv_features2d opencv_video WRAP python java)
4+
ocv_module_include_directories(
5+
"${CMAKE_CURRENT_SOURCE_DIR}/include"
6+
${FastCV_INCLUDE_PATH})
7+
8+
ocv_target_link_libraries(${the_module} ${FASTCV_LIBRARY})
9+
ocv_target_compile_definitions(${the_module} PRIVATE -DHAVE_FASTCV=1)
10+
ocv_install_3rdparty_licenses(FastCV "${OpenCV_BINARY_DIR}/3rdparty/fastcv/LICENSE")
11+
else()
12+
ocv_module_disable(fastcv)
13+
endif()

modules/fastcv/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FastCV extension for OpenCV
2+
===========================
3+
4+
This module provides wrappers for several FastCV functions not covered by the corresponding HAL in OpenCV or have implementation incompatible with OpenCV.
5+
Please note that:
6+
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.
7+
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.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#ifndef OPENCV_FASTCV_HPP
7+
#define OPENCV_FASTCV_HPP
8+
9+
#include <opencv2/core.hpp>
10+
11+
/**
12+
* @defgroup fastcv Module-wrapper for FastCV hardware accelerated functions
13+
*/
14+
15+
#include "opencv2/fastcv/arithm.hpp"
16+
#include "opencv2/fastcv/bilateralFilter.hpp"
17+
#include "opencv2/fastcv/cluster.hpp"
18+
#include "opencv2/fastcv/draw.hpp"
19+
#include "opencv2/fastcv/fast10.hpp"
20+
#include "opencv2/fastcv/fft.hpp"
21+
#include "opencv2/fastcv/hough.hpp"
22+
#include "opencv2/fastcv/moments.hpp"
23+
#include "opencv2/fastcv/mser.hpp"
24+
#include "opencv2/fastcv/remap.hpp"
25+
#include "opencv2/fastcv/scale.hpp"
26+
#include "opencv2/fastcv/shift.hpp"
27+
#include "opencv2/fastcv/smooth.hpp"
28+
#include "opencv2/fastcv/thresh.hpp"
29+
30+
//! @}
31+
32+
#endif // OPENCV_FASTCV_ARITHM_HPP
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#ifndef OPENCV_FASTCV_ARITHM_HPP
7+
#define OPENCV_FASTCV_ARITHM_HPP
8+
9+
#include <opencv2/core.hpp>
10+
11+
namespace cv {
12+
namespace fastcv {
13+
14+
//! @addtogroup fastcv
15+
//! @{
16+
17+
/**
18+
* @brief Matrix multiplication of two int8_t type matrices
19+
20+
* @param src1 First source matrix of type CV_8S
21+
* @param src2 Second source matrix of type CV_8S
22+
* @param dst Resulting matrix of type CV_32S
23+
*/
24+
CV_EXPORTS_W void matmuls8s32(InputArray src1, InputArray src2, OutputArray dst);
25+
//! @}
26+
27+
} // fastcv::
28+
} // cv::
29+
30+
#endif // OPENCV_FASTCV_ARITHM_HPP
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#ifndef OPENCV_FASTCV_BILATERALFILTER_HPP
7+
#define OPENCV_FASTCV_BILATERALFILTER_HPP
8+
9+
#include <opencv2/core.hpp>
10+
11+
namespace cv {
12+
namespace fastcv {
13+
14+
//! @addtogroup fastcv
15+
//! @{
16+
17+
/**
18+
* @brief Applies Bilateral filter to an image considering d-pixel diameter of each pixel's neighborhood.
19+
This filter does not work inplace.
20+
21+
* @param _src Intput image with type CV_8UC1
22+
* @param _dst Destination image with same type as _src
23+
* @param d kernel size (can be 5, 7 or 9)
24+
* @param sigmaColor Filter sigma in the color space.
25+
Typical value is 50.0f.
26+
Increasing this value means increasing the influence of the neighboring pixels of more different color to the smoothing result.
27+
* @param sigmaSpace Filter sigma in the coordinate space.
28+
Typical value is 1.0f.
29+
Increasing this value means increasing the influence of farther neighboring pixels within the kernel size distance to the smoothing result.
30+
* @param borderType border mode used to extrapolate pixels outside of the image
31+
*/
32+
CV_EXPORTS_W void bilateralFilter( InputArray _src, OutputArray _dst, int d,
33+
float sigmaColor, float sigmaSpace,
34+
int borderType = BORDER_DEFAULT );
35+
36+
//! @}
37+
38+
} // fastcv::
39+
} // cv::
40+
41+
#endif // OPENCV_FASTCV_BILATERALFILTER_HPP
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#ifndef OPENCV_FASTCV_CLUSTER_HPP
7+
#define OPENCV_FASTCV_CLUSTER_HPP
8+
9+
#include <opencv2/core.hpp>
10+
11+
namespace cv {
12+
namespace fastcv {
13+
14+
//! @addtogroup fastcv
15+
//! @{
16+
17+
/**
18+
* @brief Clusterizes N input points in D-dimensional space into K clusters
19+
*
20+
* @param points Points array of type 8u, each row represets a point.
21+
* Size is N rows by D columns, can be non-continuous.
22+
* @param clusterCenters Initial cluster centers array of type 32f, each row represents a center.
23+
* Size is K rows by D columns, can be non-continuous.
24+
* @param newClusterCenters Resulting cluster centers array of type 32f, each row represents found center.
25+
* Size is set to be K rows by D columns.
26+
* @param clusterSizes Resulting cluster member counts array of type uint32, size is set to be 1 row by K columns.
27+
* @param clusterBindings Resulting points indices array of type uint32, each index tells to which cluster the corresponding point belongs to.
28+
* Size is set to be 1 row by numPointsUsed columns.
29+
* @param clusterSumDists Resulting distance sums array of type 32f, each number is a sum of distances between each cluster center to its belonging points.
30+
* Size is set to be 1 row by K columns
31+
* @param numPointsUsed Number of points to clusterize starting from 0 to numPointsUsed-1 inclusively. Sets to N if negative.
32+
*/
33+
CV_EXPORTS_W void clusterEuclidean(InputArray points, InputArray clusterCenters, OutputArray newClusterCenters,
34+
OutputArray clusterSizes, OutputArray clusterBindings, OutputArray clusterSumDists,
35+
int numPointsUsed = -1);
36+
37+
//! @}
38+
39+
} // fastcv::
40+
} // cv::
41+
42+
#endif // OPENCV_FASTCV_CLUSTER_HPP
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#ifndef OPENCV_FASTCV_DRAW_HPP
7+
#define OPENCV_FASTCV_DRAW_HPP
8+
9+
#include <opencv2/core.hpp>
10+
11+
namespace cv {
12+
namespace fastcv {
13+
14+
//! @addtogroup fastcv
15+
//! @{
16+
17+
/**
18+
* @brief Draw convex polygon
19+
This function fills the interior of a convex polygon with the specified color.
20+
21+
* @param img Image to draw on. Should have up to 4 8-bit channels
22+
* @param pts Array of polygon points coordinates. Should contain N two-channel or 2*N one-channel 32-bit integer elements
23+
* @param color Color of drawn polygon stored as B,G,R and A(if supported)
24+
*/
25+
CV_EXPORTS_W void fillConvexPoly(InputOutputArray img, InputArray pts, Scalar color);
26+
27+
//! @}
28+
29+
} // fastcv::
30+
} // cv::
31+
32+
#endif // OPENCV_FASTCV_DRAW_HPP
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#ifndef OPENCV_FASTCV_FAST10_HPP
7+
#define OPENCV_FASTCV_FAST10_HPP
8+
9+
#include <opencv2/core.hpp>
10+
11+
namespace cv {
12+
namespace fastcv {
13+
14+
//! @addtogroup fastcv
15+
//! @{
16+
17+
/**
18+
* @brief Extracts FAST corners and scores from the image based on the mask.
19+
The mask specifies pixels to be ignored by the detector
20+
21+
* @param src 8-bit grayscale image
22+
* @param mask Optional mask indicating which pixels should be omited from corner dection.
23+
Its size should be k times image width and height, where k = 1/2, 1/4 , 1/8 , 1, 2, 4 and 8
24+
For more details see documentation to `fcvCornerFast9InMaskScoreu8` function in FastCV
25+
* @param coords Output array of CV_32S containing interleave x, y positions of detected corners
26+
* @param scores Optional output array containing the scores of the detected corners.
27+
The score is the highest threshold that can still validate the detected corner.
28+
A higher score value indicates a stronger corner feature.
29+
For example, a corner of score 108 is stronger than a corner of score 50
30+
* @param barrier FAST threshold. The threshold is used to compare difference between intensity value
31+
of the central pixel and pixels on a circle surrounding this pixel
32+
* @param border Number for pixels to ignore from top,bottom,right,left of the image. Defaults to 4 if it's below 4
33+
* @param nmsEnabled Enable non-maximum suppresion to prune weak key points
34+
*/
35+
CV_EXPORTS_W void FAST10(InputArray src, InputArray mask, OutputArray coords, OutputArray scores, int barrier, int border, bool nmsEnabled);
36+
37+
//! @}
38+
39+
} // fastcv::
40+
} // cv::
41+
42+
#endif // OPENCV_FASTCV_FAST10_HPP
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#ifndef OPENCV_FASTCV_FFT_HPP
7+
#define OPENCV_FASTCV_FFT_HPP
8+
9+
#include <opencv2/core.hpp>
10+
11+
namespace cv {
12+
namespace fastcv {
13+
14+
//! @addtogroup fastcv
15+
//! @{
16+
17+
/**
18+
* @brief Computes the 1D or 2D Fast Fourier Transform of a real valued matrix.
19+
For the 2D case, the width and height of the input and output matrix must be powers of 2.
20+
For the 1D case, the height of the matrices must be 1, while the width must be a power of 2.
21+
22+
* @param src Input array of CV_8UC1. The dimensions of the matrix must be powers of 2 for the 2D case,
23+
and in the 1D case, the height must be 1, while the width must be a power of 2.
24+
* @param dst The computed FFT matrix of type CV_32FC2. The FFT Re and Im coefficients are stored in different channels.
25+
Hence the dimensions of the dst are (srcWidth, srcHeight)
26+
*/
27+
CV_EXPORTS_W void FFT(InputArray src, OutputArray dst);
28+
29+
/**
30+
* @brief Computes the 1D or 2D Inverse Fast Fourier Transform of a complex valued matrix.
31+
For the 2D case, The width and height of the input and output matrix must be powers of 2.
32+
For the 1D case, the height of the matrices must be 1, while the width must be a power of 2.
33+
34+
* @param src Input array of type CV_32FC2 containing FFT Re and Im coefficients stored in separate channels.
35+
The dimensions of the matrix must be powers of 2 for the 2D case, and in the 1D case, the height must be 1,
36+
while the width must be a power of 2.
37+
* @param dst The computed IFFT matrix of type CV_8U. The matrix is real valued and has no imaginary components.
38+
Hence the dimensions of the dst are (srcWidth , srcHeight)
39+
*/
40+
CV_EXPORTS_W void IFFT(InputArray src, OutputArray dst);
41+
42+
//! @}
43+
44+
} // fastcv::
45+
} // cv::
46+
47+
#endif // OPENCV_FASTCV_FFT_HPP
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#ifndef OPENCV_FASTCV_HOUGH_HPP
7+
#define OPENCV_FASTCV_HOUGH_HPP
8+
9+
#include <opencv2/core.hpp>
10+
11+
namespace cv {
12+
namespace fastcv {
13+
14+
//! @addtogroup fastcv
15+
//! @{
16+
17+
/**
18+
* @brief Performs Hough Line detection
19+
*
20+
* @param src Input 8-bit image containing binary contour. Width and step should be divisible by 8
21+
* @param lines Output array containing detected lines in a form of (x1, y1, x2, y2) where all numbers are 32-bit floats
22+
* @param threshold Controls the minimal length of a detected line. Value must be between 0.0 and 1.0
23+
* Values close to 1.0 reduces the number of detected lines. Values close to 0.0
24+
* detect more lines, but may be noisy. Recommended value is 0.25.
25+
*/
26+
CV_EXPORTS_W void houghLines(InputArray src, OutputArray lines, double threshold = 0.25);
27+
28+
//! @}
29+
30+
} // fastcv::
31+
} // cv::
32+
33+
#endif // OPENCV_FASTCV_HOUGH_HPP
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#ifndef OPENCV_FASTCV_MOMENTS_HPP
7+
#define OPENCV_FASTCV_MOMENTS_HPP
8+
9+
#include <opencv2/core.hpp>
10+
11+
namespace cv {
12+
namespace fastcv {
13+
14+
//! @addtogroup fastcv
15+
//! @{
16+
17+
/**
18+
* @brief Calculates all of the moments up to the third order of the image pixels' intensities
19+
The results are returned in the structure cv::Moments.
20+
* @param _src Input image with type CV_8UC1, CV_32SC1, CV_32FC1
21+
* @param binary If 1, binary image (0x00-black, oxff-white); if 0, grayscale image
22+
*/
23+
CV_EXPORTS cv::Moments moments(InputArray _src, bool binary);
24+
25+
//! @}
26+
27+
} // fastcv::
28+
} // cv::
29+
30+
#endif // OPENCV_FASTCV_MOMENTS_HPP

0 commit comments

Comments
 (0)