FastCV Extension code for OpenCV 2ndpost-1#3844
Conversation
Add gaussianBlur, filter2d, sepFilter2d,sobel and warpPerspective into fastcv module
| * @param minRadius Minimum circle radius, default is 0 | ||
| * @param maxRadius Maximum circle radius, default is 0 |
There was a problem hiding this comment.
I propose to move the note about radius here. Also it's not clear what zero means.
| * @param srcPyr Pyramid built from intial motion frame | ||
| * @param dstPyr Pyramid built from final motion frame |
There was a problem hiding this comment.
Should they be fp32 pyramids produced by cv::fastcv::buildPyramid? Please add reference here
| * @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 |
There was a problem hiding this comment.
The same about references
| * | ||
| * @sa GaussianBlur | ||
| */ | ||
| CV_EXPORTS_W void gaussianBlur(cv::InputArray _src, cv::OutputArray _dst, int kernel_size = 3, bool blur_border = true); |
There was a problem hiding this comment.
What is the difference with HAL version?
| * | ||
| * @sa Filter2D | ||
| */ | ||
| CV_EXPORTS_W void filter2D(InputArray _src, OutputArray _dst, int ddepth, InputArray _kernel); |
There was a problem hiding this comment.
What is difference with cv::Filter2d? Why it's not in HAL.
| * | ||
| * @sa sepFilter2D | ||
| */ | ||
| CV_EXPORTS_W void sepFilter2D(InputArray _src, OutputArray _dst, int ddepth, InputArray _kernelX, InputArray _kernelY); |
| * @param _dsty If this param is needed, will store the result of Y direction 1 order derivative | ||
| * @param normalization If do normalization for the result | ||
| */ | ||
| CV_EXPORTS_W void sobel3x3u8(cv::InputArray _src, cv::OutputArray _dst, cv::OutputArray _dsty = noArray(), int ddepth = CV_8U, |
| * @param binary If 1, binary image (0x00-black, oxff-white); if 0, grayscale image | ||
| * @param _src Input image with type CV_8UC1, CV_32SC1, CV_32FC1 | ||
| * @param binary If true, assumes the image to be binary (0x00 for black, 0xff for white), otherwise assumes the image to be | ||
| * grayscale. |
There was a problem hiding this comment.
Please mention a difference with cv::Moments.
| * @param boundingBoxes Array containing bounding boxes of found contours | ||
| * @param contourData Array containing additional information about found contours | ||
| */ | ||
| CV_WRAP virtual void detect(InputArray src, std::vector<std::vector<Point>>& contours, std::vector<cv::Rect>& boundingBoxes, |
There was a problem hiding this comment.
Need to check bindings generation here
There was a problem hiding this comment.
How can I check bindings generation? Is there any guidance?
|
will add reference in the hpp file. |
modules/fastcv/src/moments.cpp
Outdated
| return m; | ||
|
|
||
| fcvMoments* mFCV = new fcvMoments(); | ||
| fcvMoments mFCV; |
There was a problem hiding this comment.
Since mFCV is not a pointer now, its usage should be changed:
- no need to call
delete mFCV - should be dereferenced as
mFCV.m00, notmFCV->m00
There was a problem hiding this comment.
these changes should be make in next PR, revert back to the original
modules/fastcv/test/test_moments.cpp
Outdated
| else | ||
| mean_val = cv::mean(src); | ||
|
|
||
| EXPECT_NEAR(mean_val[0], mean_val_fcv, 2); |
There was a problem hiding this comment.
These tests do not converge on my phone:
[ RUN ] fcv_momentsTest.accuracy/1, where GetParam() = (false, 640x480, 4)
/home/savuor/code/qc-fastcv-ext/opencv_contrib/modules/fastcv/test/test_moments.cpp:44: Failure
The difference between mean_val[0] and mean_val_fcv is 2642411.6411946616, which exceeds 2, where
mean_val[0] evaluates to -2660369.5142415366,
mean_val_fcv evaluates to -17957.873046875, and
2 evaluates to 2.
[ FAILED ] fcv_momentsTest.accuracy/1, where GetParam() = (false, 640x480, 4) (24 ms)
[ RUN ] fcv_momentsTest.accuracy/4, where GetParam() = (false, 1280x720, 4)
/home/savuor/code/qc-fastcv-ext/opencv_contrib/modules/fastcv/test/test_moments.cpp:44: Failure
The difference between mean_val[0] and mean_val_fcv is 246997.88133572048, which exceeds 2, where
mean_val[0] evaluates to 26830.587414279515,
mean_val_fcv evaluates to 273828.46875, and
2 evaluates to 2.
[ FAILED ] fcv_momentsTest.accuracy/4, where GetParam() = (false, 1280x720, 4) (72 ms)
[ RUN ] fcv_momentsTest.accuracy/7, where GetParam() = (false, 1920x1080, 4)
/home/savuor/code/qc-fastcv-ext/opencv_contrib/modules/fastcv/test/test_moments.cpp:44: Failure
The difference between mean_val[0] and mean_val_fcv is 530242.66986786271, which exceeds 2, where
mean_val[0] evaluates to -360915.18549286266,
mean_val_fcv evaluates to 169327.484375, and
2 evaluates to 2.
[ FAILED ] fcv_momentsTest.accuracy/7, where GetParam() = (false, 1920x1080, 4) (161 ms)
[ RUN ] fcv_momentsTest.accuracy/10, where GetParam() = (false, 127x61, 4)
/home/savuor/code/qc-fastcv-ext/opencv_contrib/modules/fastcv/test/test_moments.cpp:44: Failure
The difference between mean_val[0] and mean_val_fcv is 5544038.4969020262, which exceeds 2, where
mean_val[0] evaluates to -11985612.996902026,
mean_val_fcv evaluates to -6441574.5, and
2 evaluates to 2.
[ FAILED ] fcv_momentsTest.accuracy/10, where GetParam() = (false, 127x61, 4) (1 ms)
|
I am checking the reason, will update ASAP.
Best Regards
Xue Zhang
…________________________________
From: Alexander Smorkalov ***@***.***>
Sent: Tuesday, December 17, 2024 15:09
To: opencv/opencv_contrib ***@***.***>
Cc: xue zhang (QUIC) ***@***.***>; Mention ***@***.***>
Subject: Re: [opencv/opencv_contrib] FastCV Extension code for OpenCV 2ndpost-1 (PR #3844)
WARNING: This email originated from outside of Qualcomm. Please be wary of any links or attachments, and do not enable macros.
I tried to test the last version with Android and build is broken. @quic-xuezha<https://github.com/quic-xuezha> Could you take a look:
[2188/2664] Building CXX object modules/fastcv/CMakeFiles/opencv_fastcv.dir/src/blur.cpp.o
FAILED: modules/fastcv/CMakeFiles/opencv_fastcv.dir/src/blur.cpp.o
/usr/bin/ccache /mnt/Projects/Android/Sdk/ndk/28.0.12433566/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=aarch64-none-linux-android21 --sysroot=/mnt/Projects/Android/Sdk/ndk/28.0.12433566/toolchains/llvm/prebuilt/linux-x86_64/sysroot -DCVAPI_EXPORTS -DHAVE_FASTCV=1 -D_USE_MATH_DEFINES -D__OPENCV_BUILD=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/mnt/Projects/Projects/opencv/3rdparty/fastcv/include -I/mnt/Projects/Projects/opencv_contrib-build/3rdparty/kleidicv/kleidicv-0.3.0/kleidicv_thread/include -I/mnt/Projects/Projects/opencv_contrib-build/3rdparty/kleidicv/kleidicv-0.3.0/kleidicv/include -I/mnt/Projects/Projects/opencv_contrib-build/3rdparty/kleidicv/include -I/mnt/Projects/Projects/opencv_contrib/modules/fastcv/include -I/mnt/Projects/Projects/opencv_contrib-build/modules/fastcv -I/mnt/Projects/Projects/opencv/modules/core/include -I/mnt/Projects/Projects/opencv/modules/flann/include -I/mnt/Projects/Projects/opencv/modules/imgproc/include -I/mnt/Projects/Projects/opencv/modules/dnn/include -I/mnt/Projects/Projects/opencv/modules/features2d/include -I/mnt/Projects/Projects/opencv/modules/calib3d/include -I/mnt/Projects/Projects/opencv/modules/video/include -I/mnt/Projects/Projects/opencv_contrib-build/3rdparty/fastcv/inc -isystem /mnt/Projects/Projects/opencv_contrib-build -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Qunused-arguments -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG -std=c++11 -fPIC -MD -MT modules/fastcv/CMakeFiles/opencv_fastcv.dir/src/blur.cpp.o -MF modules/fastcv/CMakeFiles/opencv_fastcv.dir/src/blur.cpp.o.d -o modules/fastcv/CMakeFiles/opencv_fastcv.dir/src/blur.cpp.o -c /mnt/Projects/Projects/opencv_contrib/modules/fastcv/src/blur.cpp
/mnt/Projects/Projects/opencv_contrib/modules/fastcv/src/blur.cpp:49:13: error: use of undeclared identifier 'fcvFilterGaussian5x5s16_v3'; did you mean 'fcvFilterGaussian5x5u8_v3'?
49 | fcvFilterGaussian5x5s16_v3((int16_t*)srcPadded.data, width, paddedHeight, srcPadded.step, (int16_t*)dstPadded.data,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
| fcvFilterGaussian5x5u8_v3
/mnt/Projects/Projects/opencv_contrib-build/3rdparty/fastcv/inc/fastcv.h:35272:1: note: 'fcvFilterGaussian5x5u8_v3' declared here
35272 | fcvFilterGaussian5x5u8_v3(const uint8_t* __restrict src,
| ^
/mnt/Projects/Projects/opencv_contrib/modules/fastcv/src/blur.cpp:49:40: error: cannot initialize a parameter of type 'const uint8_t *' (aka 'const unsigned char *') with an rvalue of type 'int16_t *' (aka 'short *')
49 | fcvFilterGaussian5x5s16_v3((int16_t*)srcPadded.data, width, paddedHeight, srcPadded.step, (int16_t*)dstPadded.data,
| ^~~~~~~~~~~~~~~~~~~~~~~~
/mnt/Projects/Projects/opencv_contrib-build/3rdparty/fastcv/inc/fastcv.h:35272:53: note: passing argument to parameter 'src' here
35272 | fcvFilterGaussian5x5u8_v3(const uint8_t* __restrict src,
| ^
/mnt/Projects/Projects/opencv_contrib/modules/fastcv/src/blur.cpp:52:13: error: use of undeclared identifier 'fcvFilterGaussian5x5s32_v3'; did you mean 'fcvFilterGaussian5x5u8_v3'?
52 | fcvFilterGaussian5x5s32_v3((int32_t*)srcPadded.data, width, paddedHeight, srcPadded.step, (int32_t*)dstPadded.data,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
| fcvFilterGaussian5x5u8_v3
/mnt/Projects/Projects/opencv_contrib-build/3rdparty/fastcv/inc/fastcv.h:35272:1: note: 'fcvFilterGaussian5x5u8_v3' declared here
35272 | fcvFilterGaussian5x5u8_v3(const uint8_t* __restrict src,
| ^
/mnt/Projects/Projects/opencv_contrib/modules/fastcv/src/blur.cpp:52:40: error: cannot initialize a parameter of type 'const uint8_t *' (aka 'const unsigned char *') with an rvalue of type 'int32_t *' (aka 'int *')
52 | fcvFilterGaussian5x5s32_v3((int32_t*)srcPadded.data, width, paddedHeight, srcPadded.step, (int32_t*)dstPadded.data,
| ^~~~~~~~~~~~~~~~~~~~~~~~
/mnt/Projects/Projects/opencv_contrib-build/3rdparty/fastcv/inc/fastcv.h:35272:53: note: passing argument to parameter 'src' here
35272 | fcvFilterGaussian5x5u8_v3(const uint8_t* __restrict src,
| ^
/mnt/Projects/Projects/opencv_contrib/modules/fastcv/src/blur.cpp:94:45: error: use of undeclared identifier 'FASTCV_BORDER_ZERO_PADDING'
94 | fcvBorderType fcvBorder = blur_border ? FASTCV_BORDER_ZERO_PADDING : FASTCV_BORDER_UNDEFINED;
| ^
5 errors generated.
[2193/2664] Building CXX object modules/fastcv/CMakeFiles/opencv_fastcv.dir/src/edges.cpp.o
FAILED: modules/fastcv/CMakeFiles/opencv_fastcv.dir/src/edges.cpp.o
/usr/bin/ccache /mnt/Projects/Android/Sdk/ndk/28.0.12433566/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=aarch64-none-linux-android21 --sysroot=/mnt/Projects/Android/Sdk/ndk/28.0.12433566/toolchains/llvm/prebuilt/linux-x86_64/sysroot -DCVAPI_EXPORTS -DHAVE_FASTCV=1 -D_USE_MATH_DEFINES -D__OPENCV_BUILD=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/mnt/Projects/Projects/opencv/3rdparty/fastcv/include -I/mnt/Projects/Projects/opencv_contrib-build/3rdparty/kleidicv/kleidicv-0.3.0/kleidicv_thread/include -I/mnt/Projects/Projects/opencv_contrib-build/3rdparty/kleidicv/kleidicv-0.3.0/kleidicv/include -I/mnt/Projects/Projects/opencv_contrib-build/3rdparty/kleidicv/include -I/mnt/Projects/Projects/opencv_contrib/modules/fastcv/include -I/mnt/Projects/Projects/opencv_contrib-build/modules/fastcv -I/mnt/Projects/Projects/opencv/modules/core/include -I/mnt/Projects/Projects/opencv/modules/flann/include -I/mnt/Projects/Projects/opencv/modules/imgproc/include -I/mnt/Projects/Projects/opencv/modules/dnn/include -I/mnt/Projects/Projects/opencv/modules/features2d/include -I/mnt/Projects/Projects/opencv/modules/calib3d/include -I/mnt/Projects/Projects/opencv/modules/video/include -I/mnt/Projects/Projects/opencv_contrib-build/3rdparty/fastcv/inc -isystem /mnt/Projects/Projects/opencv_contrib-build -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Qunused-arguments -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG -std=c++11 -fPIC -MD -MT modules/fastcv/CMakeFiles/opencv_fastcv.dir/src/edges.cpp.o -MF modules/fastcv/CMakeFiles/opencv_fastcv.dir/src/edges.cpp.o.d -o modules/fastcv/CMakeFiles/opencv_fastcv.dir/src/edges.cpp.o -c /mnt/Projects/Projects/opencv_contrib/modules/fastcv/src/edges.cpp
/mnt/Projects/Projects/opencv_contrib/modules/fastcv/src/edges.cpp:49:21: error: use of undeclared identifier 'fcvImageGradientSobelPlanarf32_v3'; did you mean 'fcvImageGradientSobelPlanarf32_v2'?
49 | fcvImageGradientSobelPlanarf32_v3(src.data, src.cols, src.rows, src.step, (float32_t*)dst.data,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| fcvImageGradientSobelPlanarf32_v2
/mnt/Projects/Projects/opencv_contrib-build/3rdparty/fastcv/inc/fastcv.h:13104:1: note: 'fcvImageGradientSobelPlanarf32_v2' declared here
13104 | fcvImageGradientSobelPlanarf32_v2( const uint8_t* __restrict src,
| ^
1 error generated.
[2205/2664] Building CXX object modules/fastcv/CMakeFiles/opencv_fastcv.dir/src/shift.cpp.o
ninja: build stopped: subcommand failed.
—
Reply to this email directly, view it on GitHub<#3844 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/BMXH7H5S6337YXMGGQRNOSL2F7E2RAVCNFSM6AAAAABTPCAS3WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNBXGY3DANBUGU>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
|
Linux version: |
|
The build issue was my fault. Android build is ok, but not Linux arm64. See the issue above. |
| Typical value range [0.1 1.0], typical value 0.2 | ||
| * @return Feature detector object ready for detection | ||
| */ | ||
| CV_WRAP static Ptr<MSER> create(cv::Size imgSize, |
There was a problem hiding this comment.
I recommend to change the interface as follows:
CV_WRAP static Ptr<fastcv::MSER> create(const cv::Size& imgSize,
Otherwise it leads to Java binding build issue (cv::MSER and cv::fastcv::MSER conflict).
|
I hacked the hash by myself and tried to build code with Jetson Orin (natively). Issues I see: Looks like some CMake options for PThreads are missing. Also |
|
checking the build issue
|
hi @asmorkalov did you try to build code with Jetson Orin for the 1stPost code changes as well? |
|
Yes, the same issue there. It's related to prebuilt binary in opencv_3rdparty, but not the PR itself. |
FastCV-based HAL for OpenCV acceleration 2ndpost-1 #26617 ### Detailed description: - Add parallel support for cv_hal_sobel - Add cv_hal_gaussianBlurBinomial and parallel support. - Add cv_hal_addWeighted8u and parallel support - Add cv_hal_warpPerspective and parallel support Requires binary from [opencv/opencv_3rdparty#90](opencv/opencv_3rdparty#90) Related patch to opencv_contrib: [opencv/opencv_contrib#3844](opencv/opencv_contrib#3844) ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [ ] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
|
updated the code. |
FastCV Extension code for OpenCV 2ndpost-2 #3845 ### Description: - Add support for cv::fastcv::calcHist Depends on: [#3844](#3844) Depends on: [opencv/opencv#26619](opencv/opencv#26619) Requires binary from: [opencv/opencv_3rdparty#90](opencv/opencv_3rdparty#90) ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [ ] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
FastCV-based HAL for OpenCV acceleration 2ndpost-1 opencv#26617 ### Detailed description: - Add parallel support for cv_hal_sobel - Add cv_hal_gaussianBlurBinomial and parallel support. - Add cv_hal_addWeighted8u and parallel support - Add cv_hal_warpPerspective and parallel support Requires binary from [opencv/opencv_3rdparty#90](opencv/opencv_3rdparty#90) Related patch to opencv_contrib: [opencv/opencv_contrib#3844](opencv/opencv_contrib#3844) ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [ ] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
FastCV-based HAL for OpenCV acceleration 2ndpost-1 opencv#26617 ### Detailed description: - Add parallel support for cv_hal_sobel - Add cv_hal_gaussianBlurBinomial and parallel support. - Add cv_hal_addWeighted8u and parallel support - Add cv_hal_warpPerspective and parallel support Requires binary from [opencv/opencv_3rdparty#90](opencv/opencv_3rdparty#90) Related patch to opencv_contrib: [opencv/opencv_contrib#3844](opencv/opencv_contrib#3844) ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [ ] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
Depends on: opencv/opencv#26617
Requires binary from opencv/opencv_3rdparty#90
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.