> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 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>
  **Note**

  By default OpenCV acceleration with FastCV is enabled.
</Note>

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.
   ```bash theme={null}
   scp -r opencv_perf_core root@[IP-address]:/usr/bin/
   ```
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.13.0](https://github.com/opencv/opencv_extra/tree/4.13.0).

   Use the `scp` command to push the test data to the desired location on the host. For example:

   ```bash theme={null}
   scp -r [file] root@[IP-ADDR]:/tmp
   ```
3. To start the test on the target device, run the following commands.
   ```bash theme={null}
   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
   ```

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**.

<img src="https://mintcdn.com/qualcomm-prod/RietNfmN9gs2vaJw/Technologies/Vision/images/testing-fastcv-results.png?fit=max&auto=format&n=RietNfmN9gs2vaJw&q=85&s=6c9cc956e8fa4c018d0282029f0ec43e" alt="FastCV performance results" width="975" height="318" data-path="Technologies/Vision/images/testing-fastcv-results.png" />

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

<img src="https://mintcdn.com/qualcomm-prod/RietNfmN9gs2vaJw/Technologies/Vision/images/testing-opencv-results.png?fit=max&auto=format&n=RietNfmN9gs2vaJw&q=85&s=28b75a5396bf57b8eab06252f22dc2ac" alt="OpenCV performance results" width="735" height="225" data-path="Technologies/Vision/images/testing-opencv-results.png" />

Run other test cases and compare the latency numbers between default OpenCV and FastCV accelerated OpenCV.

## **Supported OpenCV APIs and corresponding FastCV APIs**

<Card>
  <b style={{fontSize: "1.1rem", display: "block", textAlign: "center"}}>Supported OpenCV APIs</b>

  <table>
    <thead>
      <tr>
        <th style={{color: "white", fontWeight: "bold"}}>OpenCV module</th>
        <th style={{color: "white", fontWeight: "bold"}}>OpenCV API</th>
        <th style={{color: "white", fontWeight: "bold"}}>Underlying FastCV API for OpenCV acceleration</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td rowspan="19">IMGPROC</td>
        <td>medianBlur</td>
        <td>fcvFilterMedian3x3u8\_v3</td>
      </tr>

      <tr><td>sobel</td><td>fcvFilterSobel3x3u8s16</td></tr>
      <tr><td>sobel</td><td>fcvFilterSobel5x5u8s16</td></tr>
      <tr><td>sobel</td><td>fcvFilterSobel7x7u8s16</td></tr>
      <tr><td>boxFilter</td><td>fcvBoxFilter3x3u8\_v3</td></tr>
      <tr><td>boxFilter</td><td>fcvBoxFilter5x5u8\_v2</td></tr>
      <tr><td>adaptiveThreshold</td><td>fcvAdaptiveThresholdGaussian3x3u8\_v2</td></tr>
      <tr><td>adaptiveThreshold</td><td>fcvAdaptiveThresholdGaussian5x5u8\_v2</td></tr>
      <tr><td>adaptiveThreshold</td><td>fcvAdaptiveThresholdMean3x3u8\_v2</td></tr>
      <tr><td>adaptiveThreshold</td><td>fcvAdaptiveThresholdMean5x5u8\_v2</td></tr>
      <tr><td>subtract</td><td>fcvImageDiffu8f32\_v2</td></tr>
      <tr><td>pyrDown</td><td>fcvPyramidCreateu8\_v4</td></tr>
      <tr><td>cvtColor</td><td>fcvColorRGB888toYCrCbu8\_v3</td></tr>
      <tr><td>cvtColor</td><td>fcvColorRGB888ToHSV888u8</td></tr>
      <tr><td>GaussianBlur</td><td>fcvFilterGaussian5x5u8\_v3</td></tr>
      <tr><td>GaussianBlur</td><td>fcvFilterGaussian3x3u8\_v4</td></tr>
      <tr><td>cvWarpPerspective</td><td>fcvWarpPerspectiveu8\_v5</td></tr>
      <tr><td>Canny</td><td>fcvFilterCannyu8</td></tr>
      <tr><td>boxFilter</td><td>fcvBoxFilterNxNf32</td></tr>

      <tr>
        <td rowspan="20">CORE</td>
        <td>lut</td>
        <td>fcvTableLookupu8</td>
      </tr>

      <tr><td>norm</td><td>fcvHammingDistanceu8</td></tr>
      <tr><td>multiply</td><td>fcvElementMultiplyu8u16\_v2</td></tr>
      <tr><td>multiply</td><td>fcvElementMultiplyu8</td></tr>
      <tr><td>multiply</td><td>fcvElementMultiplys16</td></tr>
      <tr><td>multiply</td><td>fcvElementMultiplyf32</td></tr>
      <tr><td>transpose</td><td>fcvTransposeu8\_v2</td></tr>
      <tr><td>transpose</td><td>fcvTransposeu16\_v2</td></tr>
      <tr><td>transpose</td><td>fcvTransposef32\_v2</td></tr>
      <tr><td>meanStdDev</td><td>fcvImageIntensityStats\_v2</td></tr>
      <tr><td>flip</td><td>fcvFlipu8</td></tr>
      <tr><td>flip</td><td>fcvFlipu16</td></tr>
      <tr><td>flip</td><td>fcvFlipRGB888u8</td></tr>
      <tr><td>rotate</td><td>fcvRotateImageu8</td></tr>
      <tr><td>rotate</td><td>fcvRotateImageInterleavedu8</td></tr>
      <tr><td>addWeighted</td><td>fcvAddWeightedu8\_v2</td></tr>
      <tr><td>SVD</td><td>fcvSVDf32\_v2</td></tr>
      <tr><td>Gemm</td><td>fcvMatrixMultiplyf32\_v2</td></tr>
      <tr><td>Gemm</td><td>fcvMultiplyScalarf32</td></tr>
      <tr><td>Gemm</td><td>fcvAddf32\_v2</td></tr>
    </tbody>
  </table>
</Card>

<Card>
  <b style={{fontSize: "1.1rem", display: "block", textAlign: "center"}}>FastCV CPU extension</b>

  <table>
    <thead>
      <tr>
        <th style={{color: "white", fontWeight: "bold"}}>OpenCV extension APIs</th>
        <th style={{color: "white", fontWeight: "bold"}}>FastCV APIs used</th>
        <th style={{color: "white", fontWeight: "bold"}}>Description</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td rowspan="5">arithmetic\_op</td>
        <td>fcvAddu8</td>
        <td>Matrix addition of two uint8\_t type matrixes to one uint8\_t matrix</td>
      </tr>

      <tr><td>fcvAddf32\_v2</td><td>Matrix addition of two float32\_t type matrixes.</td></tr>
      <tr><td>fcvAdds16\_v2</td><td>Matrix addition of two int16\_t type matrixes which allows in-place operation</td></tr>
      <tr><td>fcvSubtracts16</td><td>Matrix substration of two uint16\_t type matrixes</td></tr>
      <tr><td>fcvSubtractu8</td><td>Matrix substration of two uint8\_t type matrixes</td></tr>

      <tr>
        <td rowspan="3">bilateralFilter</td>
        <td>fcvBilateralFilter5x5u8\_v3</td>
        <td>Bilateral smoothing with 5x5 bilateral kernel</td>
      </tr>

      <tr><td>fcvBilateralFilter7x7u8\_v3</td><td>Bilateral smoothing with 7x7 bilateral kernel</td></tr>
      <tr><td>fcvBilateralFilter9x9u8\_v3</td><td>Bilateral smoothing with 9x9 bilateral kernel</td></tr>
      <tr><td>bilateralRecursive</td><td>fcvBilateralFilterRecursiveu8</td><td>Here the smoothing is actually performed in gradient domain.</td></tr>

      <tr>
        <td rowspan="3">buildPyramid</td>
        <td>fcvPyramidAllocate\_v3</td>
        <td>Allocates memory for an image pyramid. This API can be removed without notice and should only be used for testing.</td>
      </tr>

      <tr><td>fcvPyramidCreateu8\_v4</td><td>Creates an image pyramid from an 8-bit unsigned (grayscale) source image.</td></tr>
      <tr><td>fcvPyramidDelete\_v2</td><td>Deallocates an array of fcvPyramidLevel. Can be used for any type (f32/s8/u8).</td></tr>
      <tr><td>calcHist</td><td>fcvImageIntensityHistogram</td><td>Creates a histogram of intensities for a rectangular region of a grayscale image.</td></tr>
      <tr><td>clusterEuclidean</td><td>fcvClusterEuclideanu8</td><td>General function for computing cluster centers and cluster bindings</td></tr>

      <tr>
        <td rowspan="18">cvtColor</td>
        <td>fcvColorYCbCr420PseudoPlanarToYCbCr444PseudoPlanaru8</td>
        <td>Color conversion from pseudo planar YCbCr420 to pseudo planar YCbCr444.</td>
      </tr>

      <tr><td>fcvColorYCbCr420PseudoPlanarToYCbCr422PseudoPlanaru8</td><td>Color conversion from pseudo planar YCbCr420 to pseudo planar YCbCr422.</td></tr>
      <tr><td>fcvColorYCbCr422PseudoPlanarToYCbCr444PseudoPlanaru8</td><td>Color conversion from pseudo planar YCbCr422 to pseudo planar YCbCr444.</td></tr>
      <tr><td>fcvColorYCbCr422PseudoPlanarToYCbCr420PseudoPlanaru8</td><td>Color conversion from pseudo planar YCbCr422 to pseudo planar YCbCr420.</td></tr>
      <tr><td>fcvColorYCbCr444PseudoPlanarToYCbCr422PseudoPlanaru8</td><td>Color conversion from pseudo planar YCbCr444 to pseudo planar YCbCr422.</td></tr>
      <tr><td>fcvColorYCbCr444PseudoPlanarToYCbCr420PseudoPlanaru8</td><td>Color conversion from pseudo planar YCbCr444 to pseudo planar YCbCr420.</td></tr>
      <tr><td>fcvColorRGB565ToYCbCr444PseudoPlanaru8</td><td>Color conversion from RGB565 to pseudo-planar YCbCr444.</td></tr>
      <tr><td>fcvColorRGB565ToYCbCr422PseudoPlanaru8</td><td>Color conversion from RGB565 to pseudo-planar YCbCr422.</td></tr>
      <tr><td>fcvColorRGB565ToYCbCr420PseudoPlanaru8</td><td>Color conversion from RGB565 to pseudo-planar YCbCr420.</td></tr>
      <tr><td>fcvColorRGB888ToYCbCr444PseudoPlanaru8</td><td>Color conversion from RGB888 to pseudo-planar YCbCr444.</td></tr>
      <tr><td>fcvColorRGB888ToYCbCr422PseudoPlanaru8</td><td>Color conversion from RGB888 to pseudo-planar YCbCr422.</td></tr>
      <tr><td>fcvColorRGB888ToYCbCr420PseudoPlanaru8</td><td>Color conversion from RGB888 to pseudo-planar YCbCr420.</td></tr>
      <tr><td>fcvColorYCbCr420PseudoPlanarToRGB565u8</td><td>Color conversion from pseudo-planar YCbCr420 to RGB565.</td></tr>
      <tr><td>fcvColorYCbCr422PseudoPlanarToRGB565u8</td><td>Color conversion from pseudo-planar YCbCr422 to RGB565.</td></tr>
      <tr><td>fcvColorYCbCr422PseudoPlanarToRGB888u8</td><td>Color conversion from pseudo-planar YCbCr422 to RGB888.</td></tr>
      <tr><td>fcvColorYCbCr422PseudoPlanarToRGBA8888u8</td><td>Color conversion from pseudo-planar YCbCr422 to RGBA8888.</td></tr>
      <tr><td>fcvColorYCbCr444PseudoPlanarToRGB565u8</td><td>Color conversion from pseudo-planar YCbCr444 to RGB565.</td></tr>
      <tr><td>fcvColorYCbCr444PseudoPlanarToRGB888u8</td><td>Color conversion from pseudo-planar YCbCr444 to RGB888.</td></tr>
      <tr><td>DCT</td><td>fcvDCTu8</td><td>Performs forward discrete Cosine transform on uint8\_t pixels</td></tr>

      <tr>
        <td rowspan="4">FAST10</td>
        <td>fcvCornerFast10InMaskScoreu8</td>
        <td>Extracts FAST corners and scores from the image based on the mask.</td>
      </tr>

      <tr><td>fcvCornerFast10InMasku8</td><td>Extracts FAST corners from the image.</td></tr>
      <tr><td>fcvCornerFast10Scoreu8</td><td>Extracts FAST corners and scores from the image</td></tr>
      <tr><td>fcvCornerFast10u8</td><td>Extracts FAST corners from the image.</td></tr>
      <tr><td>FFT</td><td>fcvFFTu8</td><td>Computes the 1D or 2D Fast Fourier Transform of a real valued matrix.</td></tr>
      <tr><td>fillConvexPoly</td><td>fcvFillConvexPolyu8</td><td>This function fills the interior of a convex polygon with the specified color.</td></tr>

      <tr>
        <td rowspan="3">filter2D</td>
        <td>fcvFilterCorrNxNu8</td>
        <td>NxN correlation with non-separable kernel. Border values are ignored in this function.</td>
      </tr>

      <tr><td>fcvFilterCorrNxNu8s16</td><td>NxN correlation with non-separable kernel. Border values are ignored in this function.</td></tr>
      <tr><td>fcvFilterCorrNxNu8f32</td><td>NxN correlation with non-separable kernel. Border values are ignored in this function.</td></tr>

      <tr>
        <td rowspan="5">gaussianBlur</td>
        <td>fcvFilterGaussian3x3u8\_v4</td>
        <td>Blurs an image with 3x3 Gaussian filter with border handling scheme specified by user</td>
      </tr>

      <tr><td>fcvFilterGaussian5x5u8\_v3</td><td>Blurs an image with 5x5 Gaussian filter</td></tr>
      <tr><td>fcvFilterGaussian5x5s16\_v3</td><td>Blurs an image with 5x5 Gaussian filter</td></tr>
      <tr><td>fcvFilterGaussian5x5s32\_v3</td><td>Blurs an image with 5x5 Gaussian filter</td></tr>
      <tr><td>fcvFilterGaussian11x11u8\_v2</td><td>Blurs an image with 11x11 Gaussian filter</td></tr>
      <tr><td>houghLines</td><td>fcvHoughLineu8</td><td>Performs Hough Line detection</td></tr>
      <tr><td>iDCT</td><td>fcvIDCTs16</td><td>Performs inverse discrete cosine transform on int16\_t coefficients</td></tr>
      <tr><td>IFFT</td><td>fcvIFFTf32</td><td>Computes the 1D or 2D Inverse Fast Fourier Transform of a complex valued matrix.</td></tr>
      <tr><td>integrateImageYUV</td><td>fcvIntegrateImageYCbCr420PseudoPlanaru8</td><td>This function calculates the integral images of a YCbCr420 image, where the input YCbCr420 has UV interleaved.</td></tr>
      <tr><td>matmuls8s32</td><td>fcvMatrixMultiplys8s32</td><td>Matrix multiplication of two int8\_t type matrices</td></tr>

      <tr>
        <td rowspan="3">meanShift</td>
        <td>fcvMeanShiftu8</td>
        <td>Applies the meanshift procedure and obtains the final converged position. Source image must be 8 bit grayscale image.</td>
      </tr>

      <tr><td>fcvMeanShifts32</td><td>Applies the meanshift procedure and obtains the final converged position. Source image must be int 32bit grayscale image.</td></tr>
      <tr><td>fcvMeanShiftf32</td><td>Applies the meanshift procedure and obtains the final converged position. Source image must be float 32bit grayscale image.</td></tr>

      <tr>
        <td rowspan="3">Merge</td>
        <td>fcvChannelCombine2Planesu8</td>
        <td>Combine two channels in an interleaved fashion</td>
      </tr>

      <tr><td>fcvChannelCombine3Planesu8</td><td>Combine three channels in an interleaved fashion</td></tr>
      <tr><td>fcvChannelCombine4Planesu8</td><td>Combine four channels in an interleaved fashion</td></tr>

      <tr>
        <td rowspan="3">moments</td>
        <td>fcvImageMomentsu8</td>
        <td>Computes weighted average (moment) of the image pixels’ intensities. Input must be of data 8-bit image.</td>
      </tr>

      <tr><td>fcvImageMomentss32</td><td>Computes weighted average (moment) of the image pixels’ intensities. Input must be of data type int32\_t.</td></tr>
      <tr><td>fcvImageMomentsf32</td><td>Computes weighted average (moment) of the image pixels’ intensities. Input must be of data type float32\_t.</td></tr>

      <tr>
        <td rowspan="2">NormalizeLocalBox</td>
        <td>fcvNormalizeLocalBoxu8</td>
        <td>Calculate the local subtractive and contrastive normalization of the image.</td>
      </tr>

      <tr><td>fcvNormalizeLocalBoxf32</td><td>Calculate the local subtractive and contrastive normalization of the image.</td></tr>
      <tr><td>remap</td><td>fcvRemapu8\_v2</td><td>Applies a generic geometrical transformation to a greyscale CV\_8UC1 image.</td></tr>

      <tr>
        <td rowspan="2">remapRGBA</td>
        <td>fcvRemapRGBA8888BLu8</td>
        <td>Applies a generic geometrical transformation to a 4-channel CV\_8UC4 image with bilinear interpolation</td>
      </tr>

      <tr><td>fcvRemapRGBA8888NNu8</td><td>Applies a generic geometrical transformation to a 4-channel CV\_8UC4 image with nearest neighbor interpolation</td></tr>
      <tr><td>resizeDownBy2</td><td>fcvScaleDownBy2u8\_v2</td><td>Down-scale the image by averaging each 2x2 pixel block</td></tr>
      <tr><td>resizeDownBy4</td><td>fcvScaleDownBy4u8\_v2</td><td>Down-scale the image by averaging each 4x4 pixel block</td></tr>

      <tr>
        <td rowspan="2">ResizeDown</td>
        <td>FcvScaleDownMNu8</td>
        <td>Image downscaling using MN method</td>
      </tr>

      <tr><td>fcvScaleDownMNInterleaveu8</td><td>Interleaved image downscaling using MN method</td></tr>

      <tr>
        <td rowspan="6">runMSER</td>
        <td>fcvMserInit</td>
        <td>Function to initialize MSER.</td>
      </tr>

      <tr><td>fcvMserNN8Init</td><td>Function to initialize 8-neighbor MSER</td></tr>
      <tr><td>fcvMserExtu8\_v3</td><td>Function to invoke MSER with a smaller memory footprint, the (optional) output of contour bound boxes, and additional information.</td></tr>
      <tr><td>fcvMserExtNN8u8</td><td>Function to invoke 8-neighbor MSER, with additional outputs for each contour.</td></tr>
      <tr><td>fcvMserNN8u8</td><td>Function to invoke 8-neighbor MSER.</td></tr>
      <tr><td>fcvMserRelease</td><td>Function to release MSER resources.</td></tr>

      <tr>
        <td rowspan="7">sepFilter2D</td>
        <td>fcvFilterCorrSepMxNu8</td>
        <td>MxN correlation with separable kernel.</td>
      </tr>

      <tr><td>fcvFilterCorrSep9x9s16\_v2</td><td>9x9 FIR filter (convolution) with seperable kernel.</td></tr>
      <tr><td>fcvFilterCorrSep11x11s16\_v2</td><td>11x11 FIR filter (convolution) with seperable kernel.</td></tr>
      <tr><td>fcvFilterCorrSep13x13s16\_v2</td><td>13x13 correlation with separable kernel.</td></tr>
      <tr><td>fcvFilterCorrSep15x15s16\_v2</td><td>15x15 correlation with separable kernel.</td></tr>
      <tr><td>fcvFilterCorrSep17x17s16\_v2</td><td>17x17 correlation with separable kernel.</td></tr>
      <tr><td>fcvFilterCorrSepNxNs16</td><td>NxN correlation with separable kernel.</td></tr>

      <tr>
        <td rowspan="4">sobel</td>
        <td>fcvFilterSobel3x3u8\_v2</td>
        <td>3x3 Sobel edge filter</td>
      </tr>

      <tr><td>fcvFilterSobel3x3u8s16</td><td>Creates a 2D gradient image from source luminance data without normalization. Convolution with the 3x3 Sobel kernel.</td></tr>
      <tr><td>fcvFilterSobel5x5u8s16</td><td>Creates a 2D gradient image from source luminance data without normalization. Convolution with the 5x5 Sobel kernel.</td></tr>
      <tr><td>fcvFilterSobel7x7u8s16</td><td>Creates a 2D gradient image from source luminance data without normalization. Convolution with the 7x7 Sobel kernel.</td></tr>

      <tr>
        <td rowspan="10">sobelPyramid</td>
        <td>fcvPyramidAllocate</td>
        <td>Allocates memory for Pyramid</td>
      </tr>

      <tr><td>fcvPyramidAllocate\_v2</td><td>Allocates memory for Pyramid</td></tr>
      <tr><td>fcvPyramidAllocate\_v3</td><td>Allocates memory for Pyramid</td></tr>
      <tr><td>fcvPyramidSobelGradientCreatei8</td><td>Creates a gradient pyramid of integer8 from an image pyramid of uint8\_t</td></tr>
      <tr><td>fcvPyramidSobelGradientCreatei16</td><td>Creates a gradient pyramid of int16\_t from an image pyramid of uint8\_t</td></tr>
      <tr><td>fcvPyramidSobelGradientCreatef32</td><td>Creates a gradient pyramid of float32 from an image pyramid of uint8\_t</td></tr>
      <tr><td>fcvPyramidDelete</td><td>Deallocates an array of fcvPyramidLevel. Can be used for any type(f32/s8/u8).</td></tr>
      <tr><td>fcvPyramidDelete\_v2</td><td>Deallocates an array of fcvPyramidLevel. Can be used for any type(f32/s8/u8).</td></tr>
      <tr><td>fcvPyramidCreatef32\_v2</td><td>Builds an image pyramid (with stride). Memory should be deallocated using fcvPyramidDelete\_v2</td></tr>
      <tr><td>fcvPyramidCreateu8\_v4</td><td>Builds a Gaussian image pyramid.</td></tr>
      <tr><td>sobel3x3u8</td><td>fcvImageGradientSobelPlanars8\_v2</td><td>Creates a 2D gradient image from source luminance data using 3x3 neighborhood with Sobel kernel</td></tr>
      <tr><td>sobel3x3u9</td><td>fcvImageGradientSobelPlanars16\_v2</td><td>Creates a 2D gradient image from source luminance data using 3x3 neighborhood with Sobel kernel</td></tr>
      <tr><td>sobel3x3u10</td><td>fcvImageGradientSobelPlanars16\_v3</td><td>Creates a 2D gradient image from source luminance data using 3x3 neighborhood with Sobel kernel</td></tr>
      <tr><td>sobel3x3u11</td><td>fcvImageGradientSobelPlanarf32\_v2</td><td>Creates a 2D gradient image from source luminance data using 3x3 neighborhood with Sobel kernel</td></tr>
      <tr><td>sobel3x3u12</td><td>fcvImageGradientSobelPlanarf32\_v3</td><td>Creates a 2D gradient image from source luminance data using 3x3 neighborhood with Sobel kernel</td></tr>

      <tr>
        <td rowspan="2">split</td>
        <td>fcvDeinterleaveu8</td>
        <td>Performe image deinterleave for unsigned byte data.</td>
      </tr>

      <tr><td>fcvChannelExtractu8</td><td>Extract channel as a single uint8\_t type plane from an interleaved or multi-planar image format</td></tr>
      <tr><td>thresholdRange</td><td>fcvFilterThresholdRangeu8\_v2</td><td>Binarizes a grayscale image based on a pair of threshold values.</td></tr>

      <tr>
        <td rowspan="2">trackOpticalFlowLK</td>
        <td>fcvTrackLKOpticalFlowu8\_v3</td>
        <td>Optical flow (with stride so ROI can be supported)</td>
      </tr>

      <tr><td>fcvTrackLKOpticalFlowu8</td><td>Optical flow. Bitwidth optimized implementation</td></tr>
      <tr><td>warpAffine</td><td>fcvTransformAffineClippedu8\_v3</td><td>Applies an affine transformation on a grayscale image using a 2x3 matrix.</td></tr>
      <tr><td>warpAffine3Plane</td><td>fcv3ChannelTransformAffineClippedBCu8</td><td>Applies an affine transformation on a 3-color channel image using a 2x3 matrix using bicubic interpolation.</td></tr>
      <tr><td>warpPatchAffine</td><td>fcvTransformAffineu8\_v2</td><td>Warps the patch centered at nPos in the input image using the affine transform in nAffine</td></tr>
      <tr><td>warpPerspective</td><td>fcvWarpPerspectiveu8\_v5</td><td>Warps a grayscale image using the a perspective projection transformation matrix (also known as a homography).</td></tr>
      <tr><td>warpPerspective2Plane</td><td>fcv2PlaneWarpPerspectiveu8</td><td>Perspective warp two images using the same transformation.</td></tr>
    </tbody>
  </table>
</Card>

<Card>
  <b style={{fontSize: "1.1rem", display: "block", textAlign: "center"}}>FastCV QDSP extensions</b>

  <table>
    <thead>
      <tr>
        <th style={{color: "white", fontWeight: "bold"}}>OpenCV extension APIs</th>
        <th style={{color: "white", fontWeight: "bold"}}>FastCV APIs used</th>
        <th style={{color: "white", fontWeight: "bold"}}>Description</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>Canny</td>
        <td>fcvFilterCannyu8Q</td>
        <td>Canny edge detection with more algorithm configuration controls.</td>
      </tr>

      <tr>
        <td>fcvdspinit</td>
        <td>fcvQ6Init</td>
        <td>Initializes the FastCV DSP environment.</td>
      </tr>

      <tr>
        <td>fcvdspdeinit</td>
        <td>fcvQ6DeInit</td>
        <td>Deinitializes the FastCV DSP environment.</td>
      </tr>

      <tr>
        <td>FFT</td>
        <td>fcvFFTu8Q</td>
        <td>Computes the 1D or 2D Fast Fourier Transform of a real valued matrix.</td>
      </tr>

      <tr>
        <td rowspan="4">filter2D</td>
        <td>fcvFilterCorr3x3s8\_v2Q</td>
        <td>3x3 correlation with non-separable kernel.</td>
      </tr>

      <tr>
        <td>fcvFilterCorrNxNu8Q</td>
        <td>NxN correlation with non-separable kernel. Border values are ignored in this function.</td>
      </tr>

      <tr>
        <td>fcvFilterCorrNxNu8s16Q</td>
        <td>NxN correlation with non-separable kernel. Border values are ignored in this function.</td>
      </tr>

      <tr>
        <td>fcvFilterCorrNxNu8f32Q</td>
        <td>NxN correlation with non-separable kernel. Border values are ignored in this function.</td>
      </tr>

      <tr>
        <td>IFFT</td>
        <td>fcvIFFTf32Q</td>
        <td>Computes the 1D or 2D Inverse Fast Fourier Transform of a complex valued matrix.</td>
      </tr>

      <tr>
        <td>sumOfAbsoluteDiffs</td>
        <td>fcvSumOfAbsoluteDiffs8x8u8\_v2Q</td>
        <td>Sum of absolute differences of an image against an 8x8 template.</td>
      </tr>

      <tr>
        <td>thresholdOtsu</td>
        <td>fcvFilterThresholdOtsuu8Q</td>
        <td>Binarizes a grayscale image using Otsu’s method.</td>
      </tr>
    </tbody>
  </table>
</Card>

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.

```bash theme={null}
DEPENDS:qcom-custom-bsp += "qcom-fastcv-binaries"

EXTRA_OECMAKE += "-DOPENCV_ALLOW_DOWNLOADS=ON"
EXTRA_OECMAKE:append:qcom-custom-bsp = " -DWITH_FASTCV=ON "
#python () {
```

**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.

```bash theme={null}
DEPENDS:qcom-custom-bsp += "qcom-fastcv-binaries"

EXTRA_OECMAKE:append:qcom-custom-bsp = " -DWITH_FASTCV=OFF "
#python () {
#    bsp_type = d.getVar('BSP_TYPE')
```

The following shows how this flag is included in the CMakeLists files (`opencv/3rdparty/fastcv/CMakeLists.txt`):

```cmake theme={null}
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)
```

The following sample is one of the FastCV HAL API implementations with FastCV APIs.

`opencv/3rdparty/fastcv/src/fastcv_hal_core.cpp`

```cpp theme={null}
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);
}
```
