-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Add warpAffine and resizeDown APIs in FastCV Extension #3936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
quic-apreetam
wants to merge
3
commits into
opencv:4.x
Choose a base branch
from
CodeLinaro:apreetam_6thPost
base: 4.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (c) 2025 Qualcomm Innovation Center, Inc. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include "perf_precomp.hpp" | ||
|
||
namespace opencv_test { | ||
|
||
typedef perf::TestBaseWithParam<std::tuple<Size, int>> ResizePerfTest; | ||
|
||
PERF_TEST_P(ResizePerfTest, run, ::testing::Combine( | ||
::testing::Values(perf::szVGA, perf::sz720p, perf::sz1080p), // image size | ||
::testing::Values(2, 4) // resize factor | ||
)) | ||
{ | ||
Size size = std::get<0>(GetParam()); | ||
int factor = std::get<1>(GetParam()); | ||
|
||
cv::Mat inputImage(size, CV_8UC1); | ||
cv::randu(inputImage, cv::Scalar::all(0), cv::Scalar::all(255)); | ||
|
||
cv::Mat resized_image; | ||
Size dsize(inputImage.cols / factor, inputImage.rows / factor); | ||
|
||
while (next()) | ||
{ | ||
startTimer(); | ||
cv::fastcv::resizeDown(inputImage, resized_image, dsize, 0, 0); | ||
stopTimer(); | ||
} | ||
|
||
SANITY_CHECK_NOTHING(); | ||
} | ||
|
||
typedef perf::TestBaseWithParam<std::tuple<Size, double, double, int>> ResizeByMnPerfTest; | ||
|
||
PERF_TEST_P(ResizeByMnPerfTest, run, ::testing::Combine( | ||
::testing::Values(perf::szVGA, perf::sz720p, perf::sz1080p), // image size | ||
::testing::Values(0.35, 0.65), // inv_scale_x | ||
::testing::Values(0.35, 0.65), // inv_scale_y | ||
::testing::Values(CV_8UC1, CV_8UC2) // data type | ||
)) | ||
{ | ||
Size size = std::get<0>(GetParam()); | ||
double inv_scale_x = std::get<1>(GetParam()); | ||
double inv_scale_y = std::get<2>(GetParam()); | ||
int type = std::get<3>(GetParam()); | ||
|
||
cv::Mat inputImage(size, type); | ||
cv::randu(inputImage, cv::Scalar::all(0), cv::Scalar::all(255)); | ||
|
||
Size dsize; | ||
cv::Mat resized_image; | ||
|
||
while (next()) | ||
{ | ||
startTimer(); | ||
cv::fastcv::resizeDown(inputImage, resized_image, dsize, inv_scale_x, inv_scale_y); | ||
stopTimer(); | ||
} | ||
|
||
SANITY_CHECK_NOTHING(); | ||
} | ||
|
||
} // namespace |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, the API is redundant. OpenCV cv::Mat has locateRoi method that may extract details of the original matrix, if roi is provided as a parameter. You can just handle the case in existing warpAffine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in warpAffineROI, we use fcvTransformAffineu8_v2 which uses 2x2 Affine transformation and also uses fixed point precision, that's why it was added separately