vendor: OpenCV 5.0.0 snapshot at 755e50675d97db9b7d449d8bd6b09888646f6c6e

This commit is contained in:
Gitea Mirror Bot
2026-08-22 00:11:13 +08:00
commit 12022378a3
3872 changed files with 2513409 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2024-2025 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef OPENCV_FASTCV_HPP
#define OPENCV_FASTCV_HPP
#include <opencv2/core.hpp>
#include "opencv2/fastcv/arithm.hpp"
#include "opencv2/fastcv/bilateralFilter.hpp"
#include "opencv2/fastcv/blur.hpp"
#include "opencv2/fastcv/channel.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/histogram.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"
#include "opencv2/fastcv/allocator.hpp"
#include "opencv2/fastcv/dsp_init.hpp"
#include "opencv2/fastcv/sad_dsp.hpp"
#include "opencv2/fastcv/thresh_dsp.hpp"
#include "opencv2/fastcv/fft_dsp.hpp"
#include "opencv2/fastcv/edges_dsp.hpp"
#include "opencv2/fastcv/blur_dsp.hpp"
#include "opencv2/fastcv/color.hpp"
/**
* @defgroup fastcv Module-wrapper for FastCV hardware accelerated functions
* @{
* @}
*/
#endif // OPENCV_FASTCV_HPP
@@ -0,0 +1,67 @@
/*
* Copyright (c) 2025 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef OPENCV_FASTCV_ALLOCATOR_HPP
#define OPENCV_FASTCV_ALLOCATOR_HPP
#include <opencv2/core.hpp>
#include <set>
#include <mutex>
namespace cv {
namespace fastcv {
//! @addtogroup fastcv
//! @{
/**
* @brief Resource manager for FastCV allocations.
* This class manages active allocations.
*/
class QcResourceManager {
public:
static QcResourceManager& getInstance();
void addAllocation(void* ptr);
void removeAllocation(void* ptr);
private:
QcResourceManager() = default;
std::set<void*> activeAllocations;
std::mutex resourceMutex;
};
/**
* @brief Qualcomm's custom allocator.
* This allocator uses Qualcomm's memory management functions.
*
* Note: The userdata field of cv::UMatData is used to store the file descriptor (fd) of the allocated memory.
*
*/
class QcAllocator : public cv::MatAllocator {
public:
QcAllocator();
~QcAllocator();
cv::UMatData* allocate(int dims, const int* sizes, int type, void* data0, size_t* step, cv::AccessFlag flags, cv::UMatUsageFlags usageFlags) const CV_OVERRIDE;
bool allocate(cv::UMatData* u, cv::AccessFlag accessFlags, cv::UMatUsageFlags usageFlags) const CV_OVERRIDE;
void deallocate(cv::UMatData* u) const CV_OVERRIDE;
};
/**
* @brief Gets the default Qualcomm's allocator.
* This function returns a pointer to the default Qualcomm's allocator, which is optimized
* for use with DSP.
*
* @return Pointer to the default FastCV allocator.
*/
CV_EXPORTS cv::MatAllocator* getQcAllocator();
//! @}
} // namespace fastcv
} // namespace cv
#endif // OPENCV_FASTCV_ALLOCATOR_HPP
@@ -0,0 +1,89 @@
/*
* Copyright (c) 2024-2025 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef OPENCV_FASTCV_ARITHM_HPP
#define OPENCV_FASTCV_ARITHM_HPP
#include <opencv2/core.hpp>
#define FCV_CMP_EQ(val1,val2) (fabs(val1 - val2) < FLT_EPSILON)
#define FCV_OPTYPE(depth,op) ((depth<<3) + op)
namespace cv {
namespace fastcv {
//! @addtogroup 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
*/
CV_EXPORTS_W void matmuls8s32(InputArray src1, InputArray src2, OutputArray dst);
//! @}
//! @addtogroup fastcv
//! @{
/**
* @brief Arithmetic add and subtract operations for two matrices
* It is optimized for Qualcomm's processors
* @param src1 First source matrix, can be of type CV_8U, CV_16S, CV_32F.
* Note: CV_32F not supported for subtract
* @param src2 Second source matrix of same type and size as src1
* @param dst Resulting matrix of type as src mats
* @param op type of operation - 0 for add and 1 for subtract
*/
CV_EXPORTS_W void arithmetic_op(InputArray src1, InputArray src2, OutputArray dst, int op);
//! @}
//! @addtogroup fastcv
//! @{
/**
* @brief Matrix multiplication of two float type matrices
* R = a*A*B + b*C where A,B,C,R are matrices and a,b are constants
* It is optimized for Qualcomm's processors
* @param src1 First source matrix of type CV_32F
* @param src2 Second source matrix of type CV_32F with same rows as src1 cols
* @param dst Resulting matrix of type CV_32F
* @param alpha multiplying factor for src1 and src2
* @param src3 Optional third matrix of type CV_32F to be added to matrix product
* @param beta multiplying factor for src3
*/
CV_EXPORTS_W void gemm(InputArray src1, InputArray src2, OutputArray dst, float alpha = 1.0,
InputArray src3 = noArray(), float beta = 0.0);
//! @}
//! @addtogroup fastcv
//! @{
/**
* @brief Integral of a YCbCr420 image.
* Note: Input height should be multiple of 2. Input width and stride should be multiple of 16.
* Output stride should be multiple of 8.
* It is optimized for Qualcomm's processors
* @param Y Input Y component of 8UC1 YCbCr420 image.
* @param CbCr Input CbCr component(interleaved) of 8UC1 YCbCr420 image.
* @param IY Output Y integral of CV_32S one channel, size (Y height + 1)*(Y width + 1)
* @param ICb Output Cb integral of CV_32S one channel, size (Y height/2 + 1)*(Y width/2 + 1)
* @param ICr Output Cr integral of CV_32S one channel, size (Y height/2 + 1)*(Y width/2 + 1)
*/
CV_EXPORTS_W void integrateYUV(InputArray Y, InputArray CbCr, OutputArray IY, OutputArray ICb, OutputArray ICr);
//! @}
} // fastcv::
} // cv::
#endif // OPENCV_FASTCV_ARITHM_HPP
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef OPENCV_FASTCV_BILATERALFILTER_HPP
#define OPENCV_FASTCV_BILATERALFILTER_HPP
#include <opencv2/core.hpp>
namespace cv {
namespace fastcv {
//! @addtogroup fastcv
//! @{
/**
* @brief Applies Bilateral filter to an image considering d-pixel diameter of each pixel's neighborhood.
This filter does not work inplace.
* @param _src Intput image with type CV_8UC1
* @param _dst Destination image with same type as _src
* @param d kernel size (can be 5, 7 or 9)
* @param sigmaColor Filter sigma in the color space.
Typical value is 50.0f.
Increasing this value means increasing the influence of the neighboring pixels of more different color to the smoothing result.
* @param sigmaSpace Filter sigma in the coordinate space.
Typical value is 1.0f.
Increasing this value means increasing the influence of farther neighboring pixels within the kernel size distance to the smoothing result.
* @param borderType border mode used to extrapolate pixels outside of the image
*/
CV_EXPORTS_W void bilateralFilter( InputArray _src, OutputArray _dst, int d,
float sigmaColor, float sigmaSpace,
int borderType = BORDER_DEFAULT );
//! @}
} // fastcv::
} // cv::
#endif // OPENCV_FASTCV_BILATERALFILTER_HPP
@@ -0,0 +1,80 @@
/*
* Copyright (c) 2024-2025 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);
//! @}
//! @addtogroup fastcv
//! @{
/**
* @brief Calculates the local subtractive and contrastive normalization of the image.
* Each pixel of the image is normalized by the mean and standard deviation of the patch centred at the pixel.
* It is optimized for Qualcomm's processors.
* @param _src Input image, should have one channel CV_8U or CV_32F
* @param _dst Output array, should be one channel, CV_8S if src of type CV_8U, or CV_32F if src of CV_32F
* @param pSize Patch size for mean and std dev calculation
* @param useStdDev If 1, bot mean and std dev will be used for normalization, if 0, only mean used
*/
CV_EXPORTS_W void normalizeLocalBox(InputArray _src, OutputArray _dst, Size pSize, bool useStdDev);
//! @}
} // fastcv::
} // cv::
#endif // OPENCV_FASTCV_BLUR_HPP
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2025 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef OPENCV_FASTCV_BLUR_DSP_HPP
#define OPENCV_FASTCV_BLUR_DSP_HPP
#include <opencv2/core.hpp>
namespace cv {
namespace fastcv {
namespace dsp {
//! @addtogroup fastcv
//! @{
/**
* @brief Filter an image with non-separable kernel
* @param _src Intput image with type CV_8UC1, src size should be greater than 176*144
* @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
*/
CV_EXPORTS void filter2D(InputArray _src, OutputArray _dst, int ddepth, InputArray _kernel);
//! @}
} // dsp::
} // fastcv::
} // cv::
#endif // OPENCV_FASTCV_BLUR_DSP_HPP
@@ -0,0 +1,45 @@
/*
* Copyright (c) 2025 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef OPENCV_FASTCV_CHANNEL_HPP
#define OPENCV_FASTCV_CHANNEL_HPP
#include <opencv2/core.hpp>
namespace cv {
namespace fastcv {
//! @addtogroup fastcv
//! @{
/**
* @brief Creates one multi-channel mat out of several single-channel CV_8U mats.
* Optimized for Qualcomm's processors
* @param mv input vector of matrices to be merged; all the matrices in mv must be of CV_8UC1 and have the same size
* Note: numbers of mats can be 2,3 or 4.
* @param dst output array of depth CV_8U and same size as mv[0]; The number of channels
* will be the total number of matrices in the matrix array
*/
CV_EXPORTS_W void merge(InputArrayOfArrays mv, OutputArray dst);
//! @}
//! @addtogroup fastcv
//! @{
/**
* @brief Splits an CV_8U multi-channel mat into several CV_8UC1 mats
* Optimized for Qualcomm's processors
* @param src input 2,3 or 4 channel mat of depth CV_8U
* @param mv output vector of size src.channels() of CV_8UC1 mats
*/
CV_EXPORTS_W void split(InputArray src, OutputArrayOfArrays mv);
//! @}
} // fastcv::
} // cv::
#endif // OPENCV_FASTCV_CHANNEL_HPP
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef OPENCV_FASTCV_CLUSTER_HPP
#define OPENCV_FASTCV_CLUSTER_HPP
#include <opencv2/core.hpp>
namespace cv {
namespace fastcv {
//! @addtogroup 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.
* Size is K rows by D columns, can be non-continuous.
* @param newClusterCenters Resulting cluster centers array of type 32f, each row represents found center.
* Size is set to be K rows by D columns.
* @param clusterSizes Resulting cluster member counts array of type uint32, size is set to be 1 row by K columns.
* @param clusterBindings Resulting points indices array of type uint32, each index tells to which cluster the corresponding point belongs to.
* Size is set to be 1 row by numPointsUsed columns.
* @param clusterSumDists Resulting distance sums array of type 32f, each number is a sum of distances between each cluster center to its belonging points.
* Size is set to be 1 row by K columns
* @param numPointsUsed Number of points to clusterize starting from 0 to numPointsUsed-1 inclusively. Sets to N if negative.
*/
CV_EXPORTS_W void clusterEuclidean(InputArray points, InputArray clusterCenters, OutputArray newClusterCenters,
OutputArray clusterSizes, OutputArray clusterBindings, OutputArray clusterSumDists,
int numPointsUsed = -1);
//! @}
} // fastcv::
} // cv::
#endif // OPENCV_FASTCV_CLUSTER_HPP
@@ -0,0 +1,43 @@
// 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_FASTCV_COLOR_HPP
#define OPENCV_FASTCV_COLOR_HPP
#include <opencv2/core.hpp>
namespace cv
{
namespace fastcv
{
enum ColorConversionCodes {
// FastCV-specific color conversion codes (avoid collision with OpenCV core)
COLOR_YUV2YUV444sp_NV12 = 156, //!< FastCV: YCbCr420PseudoPlanar to YCbCr444PseudoPlanar
COLOR_YUV2YUV422sp_NV12 = 157, //!< FastCV: YCbCr420PseudoPlanar to YCbCr422PseudoPlanar
COLOR_YUV422sp2YUV444sp = 158, //!< FastCV: YCbCr422PseudoPlanar to YCbCr444PseudoPlanar
COLOR_YUV422sp2YUV_NV12 = 159, //!< FastCV: YCbCr422PseudoPlanar to YCbCr420PseudoPlanar
COLOR_YUV444sp2YUV422sp = 160, //!< FastCV: YCbCr444PseudoPlanar to YCbCr422PseudoPlanar
COLOR_YUV444sp2YUV_NV12 = 161, //!< FastCV: YCbCr444PseudoPlanar to YCbCr420PseudoPlanar
COLOR_YUV2RGB565_NV12 = 162, //!< FastCV: YCbCr420PseudoPlanar to RGB565
COLOR_YUV422sp2RGB565 = 163, //!< FastCV: YCbCr422PseudoPlanar to RGB565
COLOR_YUV422sp2RGB = 164, //!< FastCV: YCbCr422PseudoPlanar to RGB888
COLOR_YUV422sp2RGBA = 165, //!< FastCV: YCbCr422PseudoPlanar to RGBA8888
COLOR_YUV444sp2RGB565 = 166, //!< FastCV: YCbCr444PseudoPlanar to RGB565
COLOR_YUV444sp2RGB = 167, //!< FastCV: YCbCr444PseudoPlanar to RGB888
COLOR_YUV444sp2RGBA = 168, //!< FastCV: YCbCr444PseudoPlanar to RGBA8888
COLOR_RGB2YUV_NV12 = 169, //!< FastCV: RGB888 to YCbCr420PseudoPlanar
COLOR_RGB5652YUV444sp = 170, //!< FastCV: RGB565 to YCbCr444PseudoPlanar
COLOR_RGB5652YUV422sp = 171, //!< FastCV: RGB565 to YCbCr422PseudoPlanar
COLOR_RGB5652YUV_NV12 = 172, //!< FastCV: RGB565 to YCbCr420PseudoPlanar
COLOR_RGB2YUV444sp = 173, //!< FastCV: RGB888 to YCbCr444PseudoPlanar
COLOR_RGB2YUV422sp = 174, //!< FastCV: RGB888 to YCbCr422PseudoPlanar
};
CV_EXPORTS_W void cvtColor(InputArray src, OutputArray dst, int code);
}}; //cv::fastcv namespace end
#endif // OPENCV_FASTCV_COLOR_HPP
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef OPENCV_FASTCV_DRAW_HPP
#define OPENCV_FASTCV_DRAW_HPP
#include <opencv2/core.hpp>
namespace cv {
namespace fastcv {
//! @addtogroup 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)
*/
CV_EXPORTS_W void fillConvexPoly(InputOutputArray img, InputArray pts, Scalar color);
//! @}
} // fastcv::
} // cv::
#endif // OPENCV_FASTCV_DRAW_HPP
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2025 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef OPENCV_FASTCV_DSP_INIT_HPP
#define OPENCV_FASTCV_DSP_INIT_HPP
#include <opencv2/core.hpp>
namespace cv {
namespace fastcv {
namespace dsp {
//! @addtogroup fastcv
//! @{
/**
* @brief Initializes the FastCV DSP environment.
*
* This function sets up the necessary environment and resources for the DSP to operate.
* It must be called once at the very beginning of the use case or program to ensure that
* the DSP is properly initialized before any DSP-related operations are performed.
*
* @note This function must be called at the start of the use case or program, before any
* DSP-related operations.
*
* @return int Returns 0 on success, and a non-zero value on failure.
*/
CV_EXPORTS int fcvdspinit();
/**
* @brief Deinitializes the FastCV DSP environment.
*
* This function releases the resources and environment set up by the 'fcvdspinit' function.
* It should be called before the use case or program exits to ensure that all DSP resources
* are properly cleaned up and no memory leaks occur.
*
* @note This function must be called at the end of the use case or program, after all DSP-related
* operations are complete.
*/
CV_EXPORTS void fcvdspdeinit();
//! @}
} // dsp::
} // fastcv::
} // cv::
#endif // OPENCV_FASTCV_DSP_INIT_HPP
@@ -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
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2025 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef OPENCV_FASTCV_EDGES_DSP_HPP
#define OPENCV_FASTCV_EDGES_DSP_HPP
#include "opencv2/core/mat.hpp"
namespace cv {
namespace fastcv {
namespace dsp {
/**
* @defgroup fastcv Module-wrapper for FastCV hardware accelerated functions
*/
//! @addtogroup fastcv
//! @{
/**
* @brief Canny edge detector applied to a 8 bit grayscale image
* @param _src Input image with type CV_8UC1
* @param _dst Output 8-bit image containing the edge detection results
* @param lowThreshold First threshold
* @param highThreshold Second threshold
* @param apertureSize The Sobel kernel size for calculating gradient. Supported sizes are 3, 5 and 7.
* @param L2gradient L2 Gradient or L1 Gradient
*/
CV_EXPORTS void Canny(InputArray _src, OutputArray _dst, int lowThreshold, int highThreshold, int apertureSize = 3, bool L2gradient = false);
//! @}
} // dsp::
} // fastcv::
} // cv::
#endif //OPENCV_FASTCV_EDGES_DSP_HPP
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef OPENCV_FASTCV_FAST10_HPP
#define OPENCV_FASTCV_FAST10_HPP
#include <opencv2/core.hpp>
namespace cv {
namespace fastcv {
//! @addtogroup fastcv
//! @{
/**
* @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
For more details see documentation to `fcvCornerFast9InMaskScoreu8` function in FastCV
* @param coords Output array of CV_32S containing interleave x, y positions of detected corners
* @param scores Optional output array containing the scores of the detected corners.
The score is the highest threshold that can still validate the detected corner.
A higher score value indicates a stronger corner feature.
For example, a corner of score 108 is stronger than a corner of score 50
* @param barrier FAST threshold. The threshold is used to compare difference between intensity value
of the central pixel and pixels on a circle surrounding this pixel
* @param border Number for pixels to ignore from top,bottom,right,left of the image. Defaults to 4 if it's below 4
* @param nmsEnabled Enable non-maximum suppresion to prune weak key points
*/
CV_EXPORTS_W void FAST10(InputArray src, InputArray mask, OutputArray coords, OutputArray scores, int barrier, int border, bool nmsEnabled);
//! @}
} // fastcv::
} // cv::
#endif // OPENCV_FASTCV_FAST10_HPP
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef OPENCV_FASTCV_FFT_HPP
#define OPENCV_FASTCV_FFT_HPP
#include <opencv2/core.hpp>
namespace cv {
namespace fastcv {
//! @addtogroup 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.
Hence the dimensions of the dst are (srcWidth, srcHeight)
*/
CV_EXPORTS_W void FFT(InputArray src, OutputArray dst);
/**
* @brief Computes the 1D or 2D Inverse Fast Fourier Transform of a complex 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.
* @param src Input array of type CV_32FC2 containing FFT Re and Im coefficients stored in separate channels.
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 IFFT matrix of type CV_8U. The matrix is real valued and has no imaginary components.
Hence the dimensions of the dst are (srcWidth , srcHeight)
*/
CV_EXPORTS_W void IFFT(InputArray src, OutputArray dst);
//! @}
} // fastcv::
} // cv::
#endif // OPENCV_FASTCV_FFT_HPP
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2025 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef OPENCV_FASTCV_FFT_DSP_HPP
#define OPENCV_FASTCV_FFT_DSP_HPP
#include <opencv2/core.hpp>
namespace cv {
namespace fastcv {
namespace dsp {
//! @addtogroup 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.
* @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.
Hence the dimensions of the dst are (srcWidth, srcHeight)
*/
CV_EXPORTS void FFT(InputArray src, OutputArray dst);
/**
* @brief Computes the 1D or 2D Inverse Fast Fourier Transform of a complex 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.
* @param src Input array of type CV_32FC2 containing FFT Re and Im coefficients stored in separate channels.
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 IFFT matrix of type CV_8U. The matrix is real valued and has no imaginary components.
Hence the dimensions of the dst are (srcWidth , srcHeight)
*/
CV_EXPORTS void IFFT(InputArray src, OutputArray dst);
//! @}
} // dsp::
} // fastcv::
} // cv::
#endif // OPENCV_FASTCV_FFT_DSP_HPP
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef OPENCV_FASTCV_HISTOGRAM_HPP
#define OPENCV_FASTCV_HISTOGRAM_HPP
#include <opencv2/core.hpp>
namespace cv {
namespace fastcv {
//! @addtogroup fastcv
//! @{
/**
* @brief Calculates histogram of input image. This function implements specific use case of
* 256-bin histogram calculation for 8u single channel images in an optimized way.
* @param _src Intput image with type CV_8UC1
* @param _hist Output histogram of type int of 256 bins
*/
CV_EXPORTS_W void calcHist( InputArray _src, OutputArray _hist );
//! @}
} // fastcv::
} // cv::
#endif // OPENCV_FASTCV_HISTOGRAM_HPP
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef OPENCV_FASTCV_HOUGH_HPP
#define OPENCV_FASTCV_HOUGH_HPP
#include <opencv2/core.hpp>
namespace cv {
namespace fastcv {
//! @addtogroup 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
* Values close to 1.0 reduces the number of detected lines. Values close to 0.0
* detect more lines, but may be noisy. Recommended value is 0.25.
*/
CV_EXPORTS_W void houghLines(InputArray src, OutputArray lines, double threshold = 0.25);
//! @}
} // fastcv::
} // cv::
#endif // OPENCV_FASTCV_HOUGH_HPP
@@ -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
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef OPENCV_FASTCV_MOMENTS_HPP
#define OPENCV_FASTCV_MOMENTS_HPP
#include <opencv2/core.hpp>
namespace cv {
namespace fastcv {
//! @addtogroup 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. This function cv::fastcv::moments()
* calculate the moments using floating point calculations whereas cv::moments() calculate moments using double.
* @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);
//! @}
} // fastcv::
} // cv::
#endif // OPENCV_FASTCV_MOMENTS_HPP
@@ -0,0 +1,116 @@
/*
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef OPENCV_FASTCV_MSER_HPP
#define OPENCV_FASTCV_MSER_HPP
#include <opencv2/core.hpp>
namespace cv {
namespace fastcv {
//! @addtogroup fastcv
//! @{
/**
* @brief MSER blob detector for grayscale images
*
*/
class CV_EXPORTS_W FCVMSER
{
public:
/**
* @brief Structure containing additional information about found contour
*
*/
struct ContourData
{
uint32_t variation; //!< Variation of a contour from previous grey level
int32_t polarity; //!< Polarity for a contour. This value is 1 if this is a MSER+ region, -1 if this is a MSER- region.
uint32_t nodeId; //!< Node ID for a contour
uint32_t nodeCounter; //!< Node counter for a contour
};
/**
* @brief Creates MSER detector
*
* @param imgSize Image size. Image width has to be greater than 50, and image height has to be greater than 5.
* @param numNeighbors Number of neighbors in contours, can be 4 or 8
* @param delta Delta to be used in MSER algorithm (the difference in grayscale values
within which the region is stable ).
Typical value range [0.8 8], typical value 2
* @param minArea Minimum area (number of pixels) of a mser contour.
Typical value range [10 50], typical value 30
* @param maxArea Maximum area (number of pixels) of a mser contour.
Typical value 14400 or 0.25*width*height
* @param maxVariation Maximum variation in grayscale between 2 levels allowed.
Typical value range [0.1 1.0], typical value 0.15
* @param minDiversity Minimum diversity in grayscale between 2 levels allowed.
Typical value range [0.1 1.0], typical value 0.2
* @return Feature detector object ready for detection
*/
CV_WRAP static Ptr<FCVMSER> create( const cv::Size& imgSize,
int numNeighbors = 4,
int delta = 2,
int minArea = 30,
int maxArea = 14400,
float maxVariation = 0.15f,
float minDiversity = 0.2f);
/**
* @brief This is an overload for detect() function
*
* @param src Source image of type CV_8UC1. Image width has to be greater than 50, and image height has to be greater than 5.
Pixels at the image boundary are not processed. If boundary pixels are important
for a particular application, please consider padding the input image with dummy
pixels of one pixel wide.
* @param contours Array containing found contours
*/
CV_WRAP virtual void detect(InputArray src, std::vector<std::vector<Point>>& contours) = 0;
/**
* @brief This is an overload for detect() function
*
* @param src Source image of type CV_8UC1. Image width has to be greater than 50, and image height has to be greater than 5.
Pixels at the image boundary are not processed. If boundary pixels are important
for a particular application, please consider padding the input image with dummy
pixels of one pixel wide.
* @param contours Array containing found contours
* @param boundingBoxes Array containing bounding boxes of found contours
*/
CV_WRAP virtual void detect(InputArray src, std::vector<std::vector<Point>>& contours, std::vector<cv::Rect>& boundingBoxes) = 0;
/**
* @brief Runs MSER blob detector on the grayscale image
*
* @param src Source image of type CV_8UC1. Image width has to be greater than 50, and image height has to be greater than 5.
Pixels at the image boundary are not processed. If boundary pixels are important
for a particular application, please consider padding the input image with dummy
pixels of one pixel wide.
* @param contours Array containing found contours
* @param boundingBoxes Array containing bounding boxes of found contours
* @param contourData Array containing additional information about found contours
*/
virtual void detect(InputArray src, std::vector<std::vector<Point>>& contours, std::vector<cv::Rect>& boundingBoxes,
std::vector<ContourData>& contourData) = 0;
CV_WRAP virtual cv::Size getImgSize() = 0;
CV_WRAP virtual int getNumNeighbors() = 0;
CV_WRAP virtual int getDelta() = 0;
CV_WRAP virtual int getMinArea() = 0;
CV_WRAP virtual int getMaxArea() = 0;
CV_WRAP virtual float getMaxVariation() = 0;
CV_WRAP virtual float getMinDiversity() = 0;
virtual ~FCVMSER() {}
};
//! @}
} // fastcv::
} // cv::
#endif // OPENCV_FASTCV_MSER_HPP
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2024-2025 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef OPENCV_FASTCV_PYRAMID_HPP
#define OPENCV_FASTCV_PYRAMID_HPP
#include <opencv2/core.hpp>
namespace cv {
namespace fastcv {
//! @addtogroup fastcv
//! @{
/**
* @brief Creates a gradient pyramid from an image pyramid
* Note: The borders are ignored during gradient calculation.
* @param pyr Input pyramid of 1-channel 8-bit images. Only continuous images are supported.
* @param dx Horizontal Sobel gradient pyramid of the same size as pyr
* @param dy Verical Sobel gradient pyramid of the same size as pyr
* @param outType Type of output data, can be CV_8S, CV_16S or CV_32F
*/
CV_EXPORTS_W void sobelPyramid(InputArrayOfArrays pyr, OutputArrayOfArrays dx, OutputArrayOfArrays dy, int outType = CV_8S);
/**
* @brief Builds an image pyramid of float32 arising from a single
original image - that are successively downscaled w.r.t. the
pre-set levels. This API supports both ORB scaling and scale down by half.
*
* @param src Input single-channel image of type 8U or 32F
* @param pyr Output array containing nLevels downscaled image copies
* @param nLevels Number of pyramid levels to produce
* @param scaleBy2 to scale images 2x down or by a factor of 1/(2)^(1/4) which is approximated as 0.8408964 (ORB downscaling),
* ORB scaling is not supported for float point images
* @param borderType how to process border, the options are BORDER_REFLECT (maps to FASTCV_BORDER_REFLECT),
* BORDER_REFLECT_101 (maps to FASTCV_BORDER_REFLECT_V2) and BORDER_REPLICATE (maps to FASTCV_BORDER_REPLICATE).
* Other border types are mapped to FASTCV_BORDER_UNDEFINED(border pixels are ignored). Currently, borders only
* supported for downscaling by half, ignored for ORB scaling. Also ignored for float point images
* @param borderValue what value should be used to fill border, ignored for float point images
*/
CV_EXPORTS_W void buildPyramid(InputArray src, OutputArrayOfArrays pyr, int nLevels, bool scaleBy2 = true,
int borderType = cv::BORDER_REFLECT, uint8_t borderValue = 0);
//! @}
} // fastcv::
} // cv::
#endif // OPENCV_FASTCV_PYRAMID_HPP
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef OPENCV_FASTCV_REMAP_HPP
#define OPENCV_FASTCV_REMAP_HPP
#include <opencv2/core.hpp>
namespace cv {
namespace fastcv {
//! @addtogroup fastcv
//! @{
/**
* @brief Applies a generic geometrical transformation to a greyscale CV_8UC1 image.
* @param src The first input image data, type CV_8UC1
* @param dst The output image data, type CV_8UC1
* @param map1 Floating-point CV_32FC1 matrix with each element as the column coordinate of the mapped location in the source image
* @param map2 Floating-point CV_32FC1 matrix with each element as the row coordinate of the mapped location in the source image.
* @param interpolation Only INTER_NEAREST and INTER_LINEAR interpolation is supported
* @param borderValue constant pixel value
*/
CV_EXPORTS_W void remap( InputArray src, OutputArray dst,
InputArray map1, InputArray map2,
int interpolation, int borderValue=0);
/**
* @brief Applies a generic geometrical transformation to a 4-channel CV_8UC4 image with bilinear or nearest neighbor interpolation
* @param src The first input image data, type CV_8UC4
* @param dst The output image data, type CV_8UC4
* @param map1 Floating-point CV_32FC1 matrix with each element as the column coordinate of the mapped location in the source image
* @param map2 Floating-point CV_32FC1 matrix with each element as the row coordinate of the mapped location in the source image.
* @param interpolation Only INTER_NEAREST and INTER_LINEAR interpolation is supported
*/
CV_EXPORTS_W void remapRGBA( InputArray src, OutputArray dst,
InputArray map1, InputArray map2, int interpolation);
//! @}
} // fastcv::
} // cv::
#endif // OPENCV_FASTCV_REMAP_HPP
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2025 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef OPENCV_FASTCV_SAD_HPP
#define OPENCV_FASTCV_SAD_HPP
#include <opencv2/core.hpp>
namespace cv {
namespace fastcv {
namespace dsp {
/**
* @defgroup fastcv Module-wrapper for FastCV hardware accelerated functions
*/
//! @addtogroup fastcv
//! @{
/**
* @brief Sum of absolute differences of an image against an 8x8 template.
* @param _patch The first input image data, type CV_8UC1
* @param _src The input image data, type CV_8UC1
* @param _dst The output image data, type CV_16UC1
*/
CV_EXPORTS void sumOfAbsoluteDiffs(cv::InputArray _patch, cv::InputArray _src, cv::OutputArray _dst);
//! @}
} // dsp::
} // fastcv::
} // cv::
#endif // OPENCV_FASTCV_SAD_HPP
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2025 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef OPENCV_FASTCV_SCALE_HPP
#define OPENCV_FASTCV_SCALE_HPP
#include <opencv2/core.hpp>
namespace cv {
namespace fastcv {
//! @addtogroup fastcv
//! @{
/**
* @brief Down-scales the image using specified scaling factors or dimensions.
* This function supports both single-channel (CV_8UC1) and two-channel (CV_8UC2) images.
*
* @param _src The input image data, type CV_8UC1 or CV_8UC2.
* @param _dst The output image data, type CV_8UC1 or CV_8UC2.
* @param dsize The desired size of the output image. If empty, it is calculated using inv_scale_x and inv_scale_y.
* @param inv_scale_x The inverse scaling factor for the width. If dsize is provided, this parameter is ignored.
* @param inv_scale_y The inverse scaling factor for the height. If dsize is provided, this parameter is ignored.
*
* @note If dsize is not specified, inv_scale_x and inv_scale_y must be strictly positive.
*/
CV_EXPORTS_W void resizeDown(cv::InputArray _src, cv::OutputArray _dst, Size dsize, double inv_scale_x, double inv_scale_y);
//! @}
} // fastcv::
} // cv::
#endif // OPENCV_FASTCV_SCALE_HPP
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef OPENCV_FASTCV_SHIFT_HPP
#define OPENCV_FASTCV_SHIFT_HPP
#include <opencv2/core.hpp>
namespace cv {
namespace fastcv {
//! @addtogroup fastcv
//! @{
/**
* @brief Applies the meanshift procedure and obtains the final converged position.
This function applies the meanshift procedure to an original image (usually a probability image)
and obtains the final converged position. The converged position search will stop either it has reached
the required accuracy or the maximum number of iterations. Moments used in the algorithm are calculated
in floating point.
This function isn't bit-exact with cv::meanShift but provides improved latency on Snapdragon processors.
* @param src 8-bit, 32-bit int or 32-bit float grayscale image which is usually a probability image
* computed based on object histogram
* @param rect Initial search window position which also returns the final converged window position
* @param termCrit The criteria used to finish the MeanShift which consists of two termination criteria:
* 1) epsilon: required accuracy; 2) max_iter: maximum number of iterations
* @return Iteration number at which the loop stopped
*/
CV_EXPORTS_W int meanShift(InputArray src, Rect& rect, TermCriteria termCrit);
//! @}
} // fastcv::
} // cv::
#endif // OPENCV_FASTCV_SHIFT_HPP
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef OPENCV_FASTCV_SMOOTH_HPP
#define OPENCV_FASTCV_SMOOTH_HPP
#include <opencv2/core.hpp>
namespace cv {
namespace fastcv {
//! @addtogroup fastcv
//! @{
/**
* @brief Recursive Bilateral Filtering
Different from traditional bilateral filtering, here the smoothing is actually performed in gradient domain.
The algorithm claims that it's more efficient than the original bilateral filtering in both image quality and computation.
See algorithm description in the paper Recursive Bilateral Filtering, ECCV2012 by Prof Yang Qingxiong
This function isn't bit-exact with cv::bilateralFilter but provides improved latency on Snapdragon processors.
* @param src Input image, should have one CV_8U channel
* @param dst Output array having one CV_8U channel
* @param sigmaColor Sigma in the color space, the bigger the value the more color difference is smoothed by the algorithm
* @param sigmaSpace Sigma in the coordinate space, the bigger the value the more distant pixels are smoothed
*/
CV_EXPORTS_W void bilateralRecursive(cv::InputArray src, cv::OutputArray dst, float sigmaColor = 0.03f, float sigmaSpace = 0.1f);
//! @}
} // fastcv::
} // cv::
#endif // OPENCV_FASTCV_SMOOTH_HPP
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef OPENCV_FASTCV_THRESH_HPP
#define OPENCV_FASTCV_THRESH_HPP
#include <opencv2/core.hpp>
namespace cv {
namespace fastcv {
//! @addtogroup fastcv
//! @{
/**
* @brief Binarizes a grayscale image based on a pair of threshold values. The binarized image will be in the two values
* selected by user
* this function provides improved latency on Snapdragon processor.
* @param src 8-bit grayscale image
* @param dst Output image of the same size and type as input image, can be the same as input image
* @param lowThresh The lower threshold value for binarization
* @param highThresh The higher threshold value for binarization
* @param trueValue The value assigned to the destination pixel if the source is within the range inclusively defined by the
* pair of threshold values
* @param falseValue The value assigned to the destination pixel if the source is out of the range inclusively defined by the
* pair of threshold values
*/
CV_EXPORTS_W void thresholdRange(InputArray src, OutputArray dst, int lowThresh, int highThresh, int trueValue, int falseValue);
//! @}
} // fastcv::
} // cv::
#endif // OPENCV_FASTCV_THRESH_HPP
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2025 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef OPENCV_FASTCV_THRESH_DSP_HPP
#define OPENCV_FASTCV_THRESH_DSP_HPP
#include <opencv2/core.hpp>
namespace cv {
namespace fastcv {
namespace dsp {
//! @addtogroup fastcv
//! @{
/**
* @brief Binarizes a grayscale image using Otsu's method.
* Sets the pixel to max(255) if it's value is greater than the threshold;
* else, set the pixel to min(0). The threshold is searched that minimizes
* the intra-class variance (the variance within the class).
*
* @param _src Input 8-bit grayscale image. Size of buffer is srcStride*srcHeight bytes.
* @param _dst Output 8-bit binarized image. Size of buffer is dstStride*srcHeight bytes.
* @param type Threshold type that can be either 0 or 1.
* NOTE: For threshold type=0, the pixel is set as
* maxValue if it's value is greater than the threshold; else, it is set as zero.
* For threshold type=1, the pixel is set as zero if it's
* value is greater than the threshold; else, it is set as maxValue.
*/
CV_EXPORTS void thresholdOtsu(InputArray _src, OutputArray _dst, bool type);
//! @}
} // dsp::
} // fastcv::
} // cv::
#endif // OPENCV_FASTCV_THRESH_DSP_HPP
@@ -0,0 +1,65 @@
/*
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef OPENCV_FASTCV_TRACKING_HPP
#define OPENCV_FASTCV_TRACKING_HPP
#include <opencv2/core.hpp>
namespace cv {
namespace fastcv {
//! @addtogroup fastcv
//! @{
/**
* @brief Calculates sparse optical flow using Lucas-Kanade algorithm
* accepts 8-bit unsigned integer image
* Provides faster execution time on Qualcomm's processor
* @param src Input single-channel image of type 8U, initial motion frame
* @param dst Input single-channel image of type 8U, final motion frame, should have the same size and stride as initial frame
* @param srcPyr Pyramid built from intial motion frame
* @param dstPyr Pyramid built from final motion frame
* @param ptsIn Array of initial subpixel coordinates of starting points, should contain 32F 2D elements
* @param ptsOut Output array of calculated final points, should contain 32F 2D elements
* @param ptsEst Input array of estimations for final points, should contain 32F 2D elements, can be empty
* @param statusVec Output array of int32 values indicating status of each feature, can be empty
* @param winSize Size of window for optical flow searching. Width and height ust be odd numbers. Suggested values are 5, 7 or 9
* @param termCriteria Termination criteria containing max number of iterations, max epsilon and stop condition
*/
CV_EXPORTS_W void trackOpticalFlowLK(InputArray src, InputArray dst,
InputArrayOfArrays srcPyr, InputArrayOfArrays dstPyr,
InputArray ptsIn, OutputArray ptsOut, InputArray ptsEst,
OutputArray statusVec, cv::Size winSize = cv::Size(7, 7),
cv::TermCriteria termCriteria = cv::TermCriteria(cv::TermCriteria::MAX_ITER | cv::TermCriteria::EPS,
/* maxIterations */ 7, /* maxEpsilon */ 0.03f * 0.03f));
/**
* @brief Overload for v1 of the LK tracking function
*
* @param src Input single-channel image of type 8U, initial motion frame
* @param dst Input single-channel image of type 8U, final motion frame, should have the same size and stride as initial frame
* @param srcPyr Pyramid built from intial motion frame
* @param dstPyr Pyramid built from final motion frame
* @param srcDxPyr Pyramid of Sobel derivative by X of srcPyr
* @param srcDyPyr Pyramid of Sobel derivative by Y of srcPyr
* @param ptsIn Array of initial subpixel coordinates of starting points, should contain 32F 2D elements
* @param ptsOut Output array of calculated final points, should contain 32F 2D elements
* @param statusVec Output array of int32 values indicating status of each feature, can be empty
* @param winSize Size of window for optical flow searching. Width and height ust be odd numbers. Suggested values are 5, 7 or 9
* @param maxIterations Maximum number of iterations to try
*/
CV_EXPORTS_W void trackOpticalFlowLK(InputArray src, InputArray dst,
InputArrayOfArrays srcPyr, InputArrayOfArrays dstPyr,
InputArrayOfArrays srcDxPyr, InputArrayOfArrays srcDyPyr,
InputArray ptsIn, OutputArray ptsOut,
OutputArray statusVec, cv::Size winSize = cv::Size(7, 7), int maxIterations = 7);
//! @}
} // fastcv::
} // cv::
#endif // OPENCV_FASTCV_TRACKING_HPP
@@ -0,0 +1,92 @@
/*
* Copyright (c) 2024-2025 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef OPENCV_WARP_HPP
#define OPENCV_WARP_HPP
#include <opencv2/imgproc.hpp>
namespace cv {
namespace fastcv {
/**
* @defgroup fastcv Module-wrapper for FastCV hardware accelerated functions
*/
//! @addtogroup fastcv
//! @{
/**
* @brief Transform an image using perspective transformation, same as cv::warpPerspective but not bit-exact.
* @param _src Input 8-bit image.
* @param _dst Output 8-bit image.
* @param _M0 3x3 perspective transformation matrix.
* @param dsize Size of the output image.
* @param interpolation Interpolation method. Only cv::INTER_NEAREST, cv::INTER_LINEAR and cv::INTER_AREA are supported.
* @param borderType Pixel extrapolation method. Only cv::BORDER_CONSTANT, cv::BORDER_REPLICATE and cv::BORDER_TRANSPARENT
* are supported.
* @param borderValue Value used in case of a constant border.
*/
CV_EXPORTS_W void warpPerspective(InputArray _src, OutputArray _dst, InputArray _M0, Size dsize, int interpolation, int borderType,
const Scalar& borderValue);
/**
* @brief Perspective warp two images using the same transformation. Bi-linear interpolation is used where applicable.
* For example, to warp a grayscale image and an alpha image at the same time, or warp two color channels.
* @param _src1 First input 8-bit image. Size of buffer is src1Stride*srcHeight bytes.
* @param _src2 Second input 8-bit image. Size of buffer is src2Stride*srcHeight bytes.
* @param _dst1 First warped output image (correspond to src1). Size of buffer is dst1Stride*dstHeight bytes, type CV_8UC1
* @param _dst2 Second warped output image (correspond to src2). Size of buffer is dst2Stride*dstHeight bytes, type CV_8UC1
* @param _M0 The 3x3 perspective transformation matrix (inversed map)
* @param dsize The output image size
*/
CV_EXPORTS_W void warpPerspective2Plane(InputArray _src1, InputArray _src2, OutputArray _dst1, OutputArray _dst2,
InputArray _M0, Size dsize);
/**
* @brief Performs an affine transformation on an input image using a provided transformation matrix.
*
* This function performs two types of operations based on the transformation matrix:
*
* 1. Standard Affine Transformation (2x3 matrix):
* - Transforms the entire input image using the affine matrix
* - Supports both CV_8UC1 and CV_8UC3 types
*
* 2. Patch Extraction with Transformation (2x2 matrix):
* - Extracts and transforms a patch from the input image
* - Only supports CV_8UC1 type
* - If input is a ROI: patch is extracted from ROI center in the original image
* - If input is full image: patch is extracted from image center
*
* @param _src Input image. Supported formats:
* - CV_8UC1: 8-bit single-channel
* - CV_8UC3: 8-bit three-channel - only for 2x3 matrix
* @param _dst Output image. Will have the same type as src and size specified by dsize
* @param _M 2x2/2x3 affine transformation matrix (inversed map)
* @param dsize Output size:
* - For 2x3 matrix: Size of the output image
* - For 2x2 matrix: Size of the extracted patch
* @param interpolation Interpolation method. Only applicable for 2x3 transformation with CV_8UC1 input.
* Options:
* - INTER_NEAREST: Nearest-neighbor interpolation
* - INTER_LINEAR: Bilinear interpolation (default)
* - INTER_AREA: Area-based interpolation
* - INTER_CUBIC: Bicubic interpolation
* Note: CV_8UC3 input always use bicubic interpolation internally
* @param borderValue Constant pixel value for border pixels. Only applicable for 2x3 transformations
* with single-channel input.
*
* @note The affine matrix follows the inverse mapping convention, applied to destination coordinates
* to produce corresponding source coordinates.
* @note The function uses 'FASTCV_BORDER_CONSTANT' for border handling, with the specified 'borderValue'.
*/
CV_EXPORTS_W void warpAffine(InputArray _src, OutputArray _dst, InputArray _M, Size dsize, int interpolation = INTER_LINEAR,
int borderValue = 0);
//! @}
}
}
#endif