Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@asmorkalov
Copy link
Contributor

@asmorkalov asmorkalov commented May 8, 2024

Address comments in #25553

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • 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

@asmorkalov asmorkalov added this to the 4.10.0 milestone May 8, 2024
@asmorkalov asmorkalov changed the title Transform offset to indeces for minMaxIdx HAL Transform offset to indeces for MatND in minMaxIdx HAL May 8, 2024
@asmorkalov
Copy link
Contributor Author

@mplatings please take a look.

Co-authored-by: Michael Platings <[email protected]>
Copy link

@mplatings mplatings left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@asmorkalov asmorkalov merged commit 1f1ba7e into opencv:4.x May 8, 2024
@opencv-alalek opencv-alalek removed their request for review May 9, 2024 10:11
klatism pushed a commit to klatism/opencv that referenced this pull request May 17, 2024
Transform offset to indeces for MatND in minMaxIdx HAL opencv#25563

Address comments in opencv#25553

### 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
- [x] The PR is proposed to the proper branch
- [x] 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
if (res == CV_HAL_ERROR_OK)
{
if (minIdx)
ofs2idx(src, minIdx[0], minIdx);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asmorkalov I've done some more testing and I believe it should be minIdx[1] and maxIdx[1]. I thought that minIdx[0] would correspond to the X direction, but it seems that in OpenCV it corresponds to the row. According do the docs:

single-row matrix is 1xN matrix (and therefore minIdx/maxIdx will be (0,j1)/(0,j2))

If I change these indices from 0 to 1 then my tests pass.

Copy link
Contributor

@savuor savuor May 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mplatings It's not clear from the docs if minIdx and maxIdx should contain pointers to an offset to convert it to array indices or to indices themselves.
In the first case (which is how OpenCV tab functions from getMinmaxTab() actually work) there should be 0th index and no such thing as minIdx[i] or maxIdx[i] is ever possible for every i > 0.
In the second case you're right since HAL call gets 1-dimensional array and puts Y index to minIdx[0] and X to minIdx[1] (the same for maxIdx). Since it's just one dimensional, Y index should always be zero which looks impractical to me but looks like this is how it is implemented now.
I think we should choose between these two options first.

By the way, can you tell me what tests are failing? Looks like OpenCV tests do not cover that case.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KleidiCV's tests fail with the head of the OpenCV 4.x branch. Specifically this: https://gitlab.arm.com/kleidi/kleidicv/-/blob/main/conformity/opencv/test_min_max.cpp?ref_type=heads#L59

In KleidiCV 0.1.0 we did not enable minmax in the HAL so from our point of view it's fine for us to change how the HAL should work. If the HAL code should return an offset instead of 2-dimensional indices then that makes KleidiCV's code simpler.

So I'm happy to either change these indices from 0 to 1, or to require that the HAL returns an offset and we will change KleidiCV to match.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, let's do like this so that HAL should return offset.
I'll prepare PR to OpenCV which documents such behaviour.

@savuor savuor mentioned this pull request May 29, 2024
6 tasks
@mshabunin mshabunin mentioned this pull request Jun 14, 2024
savuor pushed a commit to savuor/opencv that referenced this pull request Nov 5, 2024
Transform offset to indeces for MatND in minMaxIdx HAL opencv#25563

Address comments in opencv#25553

### 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
- [x] The PR is proposed to the proper branch
- [x] 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
savuor pushed a commit to savuor/opencv that referenced this pull request Nov 8, 2024
Transform offset to indeces for MatND in minMaxIdx HAL opencv#25563

Address comments in opencv#25553

### 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
- [x] The PR is proposed to the proper branch
- [x] 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
savuor pushed a commit to savuor/opencv that referenced this pull request Nov 21, 2024
Transform offset to indeces for MatND in minMaxIdx HAL opencv#25563

Address comments in opencv#25553

### 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
- [x] The PR is proposed to the proper branch
- [x] 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants