# Evaluate FastCV acceleration
## How to measure FastCV HAL vs OpenCV performance
Compile the build with either of the following options
- To enable FastCV acceleration, use the `-DWITH_FASTCV=ON` option
- To enable default OpenCV on CPU, use the `-DWITH_FASTCV=OFF` option
Note
By default OpenCV acceleration with FastCV is enabled.
Once compilation is done, flash the build and boot the device.
All libraries are present in the `/usr/lib/` directory.
1. Copy the test bins to `/usr/bin` to run the tests.
scp -r opencv_perf_core root@[IP-address]:/usr/bin/
Copy to clipboard
2. Copy the test data to the device if not previously copied.
To obtain the test data, clone the projects at [https://github.com/opencv/opencv_extra/tree/4.11.0](https://github.com/opencv/opencv_extra/tree/4.11.0).
Use the `scp` command to push the test data to the desired location on the host. For example:
scp -r [file] root@[IP-ADDR]:/tmp
Copy to clipboard
3. To start the test on the target device, run the following commands.
cd /usr/bin/
chmod 777 opencv_perf*
export OPENCV_OPENCL_RUNTIME=disabled && export OPENCV_TEST_DATA_PATH=/tmp && /usr/bin/opencv_perf_core --gtest_filter=ArithmMixedTest.subtract/2 --perf_min_samples=100 --perf_force_samples=100 >> results_Arithm.txt
Copy to clipboard
The above commands run different test cases for the subtract API, with each test case looped over 100 times.
The results are collected in a `results_Arithm.txt` text file.
`results_Arithm.txt` includes details for different test cases including the test name, number of samples, resolution, mean time,
pass/fail status. For the following test case with FastCV acceleration enabled, the total time taken was **16 ms**.

**FastCV performance results**
With the default OpenCV, for the same test case, the total time taken was 23 ms.

**OpenCV performance results**
Run other test cases and compare the latency numbers between default OpenCV and FastCV accelerated OpenCV.
## Supported OpenCV APIs and corresponding FastCV APIs
| OpenCV module | OpenCV API | Underlying FastCV API for OpenCV acceleration |
| --- | --- | --- |
| IMGPROC | medianBlur | fcvFilterMedian3x3u8\_v3 |
| IMGPROC | sobel | fcvFilterSobel3x3u8s16 |
| IMGPROC | sobel | fcvFilterSobel5x5u8s16 |
| IMGPROC | sobel | fcvFilterSobel7x7u8s16 |
| IMGPROC | boxFilter | fcvBoxFilter3x3u8\_v3 |
| IMGPROC | boxFilter | fcvBoxFilter5x5u8\_v2 |
| IMGPROC | adaptiveThreshold | fcvAdaptiveThresholdGaussian3x3u8\_v2 |
| IMGPROC | adaptiveThreshold | fcvAdaptiveThresholdGaussian5x5u8\_v2 |
| IMGPROC | adaptiveThreshold | fcvAdaptiveThresholdMean3x3u8\_v2 |
| IMGPROC | adaptiveThreshold | fcvAdaptiveThresholdMean5x5u8\_v2 |
| IMGPROC | subtract | fcvImageDiffu8f32\_v2 |
| IMGPROC | pyrDown | fcvPyramidCreateu8\_v4 |
| IMGPROC | cvtColor | fcvColorRGB888toYCrCbu8\_v3 |
| IMGPROC | cvtColor | fcvColorRGB888ToHSV888u8 |
| IMGPROC | GaussianBlur | fcvFilterGaussian5x5u8\_v3 |
| IMGPROC | GaussianBlur | fcvFilterGaussian3x3u8\_v4 |
| IMGPROC | cvWarpPerspective | fcvWarpPerspectiveu8\_v5 |
| IMGPROC | Canny | fcvFilterCannyu8 |
| IMGPROC | boxFilter | fcvBoxFilterNxNf32 |
| CORE | lut | fcvTableLookupu8 |
| CORE | norm | fcvHammingDistanceu8 |
| CORE | multiply | fcvElementMultiplyu8u16\_v2 |
| CORE | multiply | fcvElementMultiplyu8 |
| CORE | multiply | fcvElementMultiplys16 |
| CORE | multiply | fcvElementMultiplyf32 |
| CORE | transpose | fcvTransposeu8\_v2 |
| CORE | transpose | fcvTransposeu16\_v2 |
| CORE | transpose | fcvTransposef32\_v2 |
| CORE | meanStdDev | fcvImageIntensityStats\_v2 |
| CORE | flip | fcvFlipu8 |
| CORE | flip | fcvFlipu16 |
| CORE | flip | fcvFlipRGB888u8 |
| CORE | rotate | fcvRotateImageu8 |
| CORE | rotate | fcvRotateImageInterleavedu8 |
| CORE | addWeighted | fcvAddWeightedu8\_v2 |
| CORE | SVD | fcvSVDf32\_v2 |
| CORE | Gemm | fcvMatrixMultiplyf32\_v2 |
| CORE | Gemm | fcvMultiplyScalarf32 |
| CORE | Gemm | fcvAddf32\_v2 |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| OpenCV extension APIs | FastCV APIs used | Description |
| --- | --- | --- |
| matmuls8s32 | fcvMatrixMultiplys8s32 | Matrix multiplication of two int8\_t type matrices |
| clusterEuclidean | fcvClusterEuclideanu8 | General function for computing cluster centers and cluster bindings |
| FAST10 | fcvCornerFast10InMaskScoreu8 | Extracts FAST corners and scores from the image based on the mask.
Source msut be 8-bit grayscale image where keypoints are detected |
| FAST10 | fcvCornerFast10InMasku8 | Extracts FAST corners from the image. |
| FAST10 | fcvCornerFast10Scoreu8 | Extracts FAST corners and scores from the image |
| FAST10 | fcvCornerFast10u8 | Extracts FAST corners from the image. |
| FFT | fcvFFTu8 | Computes the 1D or 2D Fast Fourier Transform of a real valued matrix. |
| IFFT | fcvIFFTf32 | Computes the 1D or 2D Inverse Fast Fourier Transform of a complex valued matrix. |
| fillConvexPoly | fcvFillConvexPolyu8 | This function fills the interior of a convex polygon with the specified color. |
| houghLines | fcvHoughLineu8 | Performs Hough Line detection |
| moments | fcvImageMomentsu8 | Computes weighted average (moment) of the image pixels’ intensities
Source pointer to the original Input must be of data 8-bit image. |
| moments | fcvImageMomentss32 | Computes weighted average (moment) of the image pixels’ intensities
Source Pointer to the original input must be of data type int32\_t. |
| moments | fcvImageMomentsf32 | Computes weighted average (moment) of the image pixels’ intensities
Source pointer to the original Input must be of data type float32\_t. |
| runMSER | fcvMserInit | Function to initialize MSER. |
| runMSER | fcvMserNN8Init | Function to initialize 8-neighbor MSER |
| runMSER | fcvMserExtu8\_v3 | Function to invoke MSER with a smaller memory footprint, the (optional) output of contour bound boxes, and additional information. |
| runMSER | fcvMserExtNN8u8 | Function to invoke 8-neighbor MSER, , with additional outputs for each contour. |
| runMSER | fcvMserNN8u8 | Function to invoke 8-neighbor MSER. |
| runMSER | fcvMserRelease | Function to release MSER resources. |
| remap | fcvRemapu8\_v2 | Applies a generic geometrical transformation to a greyscale CV\_8UC1 image. |
| remapRGBA | fcvRemapRGBA8888BLu8 | Applies a generic geometrical transformation to a 4-channel CV\_8UC4 image with bilinear interpolation |
| remapRGBA | fcvRemapRGBA8888NNu8 | Applies a generic geometrical transformation to a 4-channel CV\_8UC4 image with nearest neighbor interpolation |
| resizeDownBy2 | fcvScaleDownBy2u8\_v2 | Down-scale the image by averaging each 2x2 pixel block |
| resizeDownBy4 | fcvScaleDownBy4u8\_v2 | Down-scale the image by averaging each 4x4 pixel block |
| meanShift | fcvMeanShiftu8 | Applies the meanshift procedure and obtains the final converged position.
Source image must be 8 bit grayscale image. |
| meanShift | fcvMeanShifts32 | Applies the meanshift procedure and obtains the final converged position.
Source image must be int 32bit grayscale image. |
| meanShift | fcvMeanShiftf32 | Applies the meanshift procedure and obtains the final converged position.
Source image must be float 32bit grayscale image. |
| bilateralRecursive | fcvBilateralFilterRecursiveu8 | Here the smoothing is actually performed in gradient domain. |
| thresholdRange | fcvFilterThresholdRangeu8\_v2 | Binarizes a grayscale image based on a pair of threshold values. |
| bilateralFilter | fcvBilateralFilter5x5u8\_v3 | Bilateral smoothing with 5x5 bilateral kernel |
| bilateralFilter | fcvBilateralFilter7x7u8\_v3 | Bilateral smoothing with 7x7 bilateral kernel |
| bilateralFilter | fcvBilateralFilter9x9u8\_v3 | Bilateral smoothing with 9x9 bilateral kernel |
| calcHist | fcvImageIntensityHistogram | Creates a histogram of intensities for a rectangular region of a grayscale image. |
| gaussianBlur | fcvFilterGaussian3x3u8\_v4 | Blurs an image with 3x3 Gaussian filter with border handling scheme specified by user |
| gaussianBlur | fcvFilterGaussian5x5u8\_v3 | Blurs an image with 5x5 Gaussian filter |
| gaussianBlur | fcvFilterGaussian5x5s16\_v3 | Blurs an image with 5x5 Gaussian filter |
| gaussianBlur | fcvFilterGaussian5x5s32\_v3 | Blurs an image with 5x5 Gaussian filter |
| gaussianBlur | fcvFilterGaussian11x11u8\_v2 | Blurs an image with 11x11 Gaussian filter |
| filter2D | fcvFilterCorrNxNu8 | NxN correlation with non-separable kernel. Border values are ignored in this function. |
| filter2D | fcvFilterCorrNxNu8s16 | NxN correlation with non-separable kernel. Border values are ignored in this function. |
| filter2D | fcvFilterCorrNxNu8f32 | NxN correlation with non-separable kernel. Border values are ignored in this function. |
| sepFilter2D | fcvFilterCorrSepMxNu8 | MxN correlation with separable kernel. |
| sepFilter2D | fcvFilterCorrSep9x9s16\_v2 | 9x9 FIR filter (convolution) with seperable kernel. |
| sepFilter2D | fcvFilterCorrSep11x11s16\_v2 | 11x11 FIR filter (convolution) with seperable kernel. |
| sepFilter2D | fcvFilterCorrSep13x13s16\_v2 | 13x13 correlation with separable kernel. |
| sepFilter2D | fcvFilterCorrSep15x15s16\_v2 | 15x15 correlation with separable kernel. |
| sepFilter2D | fcvFilterCorrSep17x17s16\_v2 | 17x17 correlation with separable kernel. |
| sepFilter2D | fcvFilterCorrSepNxNs16 | NxN correlation with separable kernel. |
| sobel3x3u8 | fcvImageGradientSobelPlanars8\_v2 | Creates a 2D gradient image from source luminance data. This function computes central differences on 3x3 neighborhood and then convolves the result with Sobel kernel |
| sobel3x3u9 | fcvImageGradientSobelPlanars16\_v2 | Creates a 2D gradient image from source luminance data. This function computes central differences on 3x3 neighborhood and then convolves the result with Sobel kernel |
| sobel3x3u10 | fcvImageGradientSobelPlanars16\_v3 | Creates a 2D gradient image from source luminance data. This function computes central differences on 3x3 neighborhood and then convolves the result with Sobel kernel |
| sobel3x3u11 | fcvImageGradientSobelPlanarf32\_v2 | Creates a 2D gradient image from source luminance data.This function computes central differences on 3x3 neighborhood and then convolves the result with Sobel kernel |
| sobel3x3u12 | fcvImageGradientSobelPlanarf32\_v3 | Creates a 2D gradient image from source luminance data. This function computes central differences on 3x3 neighborhood and then convolves the result with Sobel kernel |
| sobel | fcvFilterSobel3x3u8\_v2 | 3x3 Sobel edge filter |
| sobel | fcvFilterSobel3x3u8s16 | Creates a 2D gradient image from source luminance data without normalization.This function computes the gradient of the input image by convolution with the 3x3 Sobel kernel. |
| sobel | fcvFilterSobel5x5u8s16 | Creates a 2D gradient image from source luminance data without normalization.This function computes the gradient of the input image by convolution with the 5x5 Sobel kernel. |
| sobel | fcvFilterSobel7x7u8s16 | Creates a 2D gradient image from source luminance data without normalization.This function computes the gradient of the input image by convolution with the 7x7 Sobel kernel |
| DCT | fcvDCTu8 | Performs forward discrete Cosine transform on uint8\_t pixels |
| iDCT | fcvIDCTs16 | Performs inverse discrete cosine transform on int16\_t coefficients |
| sobelPyramid | fcvPyramidAllocate | Allocates memory for Pyramid |
| sobelPyramid | fcvPyramidAllocate\_v2 | Allocates memory for Pyramid |
| sobelPyramid | fcvPyramidAllocate\_v3 | Allocates memory for Pyramid |
| sobelPyramid | fcvPyramidSobelGradientCreatei8 | Creates a gradient pyramid of integer8 from an image pyramid of uint8\_t |
| sobelPyramid | fcvPyramidSobelGradientCreatei16 | Creates a gradient pyramid of int16\_t from an image pyramid of uint8\_t |
| sobelPyramid | fcvPyramidSobelGradientCreatef32 | Creates a gradient pyramid of float32 from an image pyramid of uint8\_t |
| sobelPyramid | fcvPyramidDelete | Deallocates an array of fcvPyramidLevel. Can be used for any type(f32/s8/u8). |
| sobelPyramid | fcvPyramidDelete\_v2 | Deallocates an array of fcvPyramidLevel. Can be used for any type(f32/s8/u8). |
| sobelPyramid | fcvPyramidCreatef32\_v2 | Builds an image pyramid (with stride). Memory should be deallocated using fcvPyramidDelete\_v2 |
| sobelPyramid | fcvPyramidCreateu8\_v4 | Builds a Gaussian image pyramid. |
| trackOpticalFlowLK | fcvTrackLKOpticalFlowu8\_v3 | Optical flow (with stride so ROI can be supported) |
| trackOpticalFlowLK | fcvTrackLKOpticalFlowu8 | Optical flow. Bitwidth optimized implementation |
| warpPerspective2Plane | fcv2PlaneWarpPerspectiveu8 | Perspective warp two images using the same transformation. |
| ResizeDown | FcvScaleDownMNu8 | Image downscaling using MN method |
| ResizeDown | fcvScaleDownMNInterleaveu8 | Interleaved image downscaling using MN method |
| integrateImageYUV | fcvIntegrateImageYCbCr420PseudoPlanaru8 | This function calculates the integral images of a YCbCr420 image,
where the input YCbCr420 has UV interleaved. |
| NormalizeLocalBox | fcvNormalizeLocalBoxu8 | Calculate the local subtractive and contrastive normalization of the image. |
| NormalizeLocalBox | fcvNormalizeLocalBoxf32 | Calculate the local subtractive and contrastive normalization of the image. |
| Merge | fcvChannelCombine2Planesu8 | Combine two channels in an interleaved fashion |
| Merge | fcvChannelCombine3Planesu8 | Combine three channels in an interleaved fashion |
| Merge | fcvChannelCombine4Planesu8 | Combine four channels in an interleaved fashion |
| split | fcvDeinterleaveu8 | Performe image deinterleave for unsigned byte data. |
| split | fcvChannelExtractu8 | Extract channel as a single uint8\_t type plane from
an interleaved or multi-planar image format |
| warpAffine | fcvTransformAffineClippedu8\_v3 | Applies an affine transformation on a grayscale image using a 2x3 matrix. |
| warpAffine3Plane | fcv3ChannelTransformAffineClippedBCu8 | Applies an affine transformation on a 3-color channel image
using a 2x3 matrix using bicubic interpolation. |
| warpPatchAffine | fcvTransformAffineu8\_v2 | Warps the patch centered at nPos in the input image using the affine transform in nAffine |
| warpPerspective | fcvWarpPerspectiveu8\_v5 | Warps a grayscale image using the a perspective projection transformation
matrix (also known as a homography). |
| arithmetic\_op | fcvAddu8 | Matrix addition of two uint8\_t type matrixes to one uint8\_t matrix |
| arithmetic\_op | fcvAddf32\_v2 | Matrix addition of two float32\_t type matrixes. |
| arithmetic\_op | fcvAdds16\_v2 | Matrix addition of two int16\_t type matrixes which allows in-place operation |
| arithmetic\_op | fcvSubtracts16 | Matrix substration of two uint16\_t type matrixes |
| arithmetic\_op | fcvSubtractu8 | Matrix substration of two uint8\_t type matrixes |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
For FastCV Extension details, see [the extension’s documentation](https://docs.opencv.org/4.x/dc/db8/group__fastcv.html)
## Enable or disable FastCV acceleration
Enable
Enable FastCV HAL acceleration by including **-DWITH\_FASTCV=ON** in the OpenCV BitBake file in the
**EXTRA\_OECMAKE** options as shown below.
This flag allows compilation of OpenCV APIs with the FastCV HAL.
DEPENDS:qcom-custom-bsp += "qcom-fastcv-binaries"
EXTRA_OECMAKE += "-DOPENCV_ALLOW_DOWNLOADS=ON"
EXTRA_OECMAKE:append:qcom-custom-bsp = " -DWITH_FASTCV=ON "
#python () {
Copy to clipboard
Disable
Disable FastCV HAL acceleration by including **-DWITH\_FASTCV=OFF** in the OpenCV BitBake file in the
`EXTRA_OECMAKE` options as shown below and then recompile the OpenCV recipe using the devtool method.
DEPENDS:qcom-custom-bsp += "qcom-fastcv-binaries"
EXTRA_OECMAKE:append:qcom-custom-bsp = " -DWITH_FASTCV=OFF "
#python () {
# bsp_type = d.getVar('BSP_TYPE')
Copy to clipboard
The following shows how this flag is included in the CMakeLists files (`opencv/3rdparty/fastcv/CMakeLists.txt`):
if(NOT WITH_FASTCV OR NOT FASTCV_DIR)
message(STATUS "FastCV is not available, disabling related HAL and stuff")
return()
endif()
if(NOT ANDROID AND NOT UNIX)
message(FATAL_ERROR "FastCV HAL supports Android and UNIX only!")
endif()
set(OPENCV_3P_FASTCV_DIR ${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(hal)
Copy to clipboard
The following sample is one of the FastCV HAL API implementations with FastCV APIs.
`opencv/3rdparty/fastcv/src/fastcv_hal_core.cpp`
int fastcv_hal_sub8u32f(
const uchar* src1_data,
size_t src1_step,
const uchar* src2_data,
size_t src2_step,
float* dst_data,
size_t dst_step,
int width,
int height)
{
INITIALIZATION_CHECK;
fcvStatus status = FASTCV_SUCCESS;
if (src1_step < width && src2_step < width)
{
src1_step = width*sizeof(uchar);
src2_step = width*sizeof(uchar);
dst_step = width*sizeof(float);
}
status = fcvImageDiffu8f32_v2(src1_data, src2_data, width, height, src1_step,
src2_step, dst_data, dst_step);
CV_HAL_RETURN(status,hal_subtract);
}
Copy to clipboard
Last Published: Jun 19, 2026
[Previous Topic
Implement new sample app](https://docs.qualcomm.com/bundle/publicresource/80-70030-21/topics/sample-applications.md) [Next Topic
References](https://docs.qualcomm.com/bundle/publicresource/80-70030-21/topics/references.md)
Source: [https://docs.qualcomm.com/doc/80-70030-21/topic/fastcv-acceleration.html](https://docs.qualcomm.com/doc/80-70030-21/topic/fastcv-acceleration.html)