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

Skip to content

Conversation

@srinath2468
Copy link

@srinath2468 srinath2468 commented May 28, 2024

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

@opencv-alalek
Copy link
Contributor

Need to completely remove commits with submodules from the PR.

@srinath2468
Copy link
Author

@opencv-alalek I have removed the commits with submodules

@asmorkalov
Copy link
Contributor

What issue do you try to solve? The PR does not contain enough add value to be merged.

@asmorkalov asmorkalov closed this May 31, 2024
@srinath2468
Copy link
Author

@asmorkalov The PR does not solve any issue. It is just an added feature. PtrStepSz seems to not give us access to size but rather cols and rows. To check for size, we need to construct using these parameters. It would be helpful if the type gave us access to size directly to use in custom functions.

@pasbi
Copy link
Contributor

pasbi commented Jun 26, 2024

@asmorkalov I vote to open this PR again.

Having a handy way to access the size rather than just rows and cols would make our code more terse and avoids the pitfall of confusing rows and cols (you know, OpenCV is a bit... peculiar in this regard).

However, I'd add size as a function which assembles a cv::Size from rows and cols just like cv::Mat does, except that I'd add decorators to make it accessible from kernels and device functions.

@srinath2468
Copy link
Author

@asmorkalov thanks for reopening. Do you think the current proposal makes sense? Or should we construct cv::Size in gpu code with a getter method. This will keep the overhead of PtrStepSz.. the same.

@asmorkalov
Copy link
Contributor

The PR was discussed on the Core team meeting and decided to reject it. The PR makes the structure 2 times fatter and values duplication. Closed.

@asmorkalov asmorkalov closed this Jul 5, 2024

int cols;
int rows;
Size size;
Copy link
Contributor

Choose a reason for hiding this comment

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

  __CV_CUDA_HOST_DEVICE__ [[nodiscard]] cv::Size size() const
  {
    return cv::Size{cols, rows};
  }


template <typename U>
explicit PtrStepSz(const PtrStepSz<U>& d) : PtrStep<T>((T*)d.data, d.step), cols(d.cols), rows(d.rows){}
explicit PtrStepSz(const PtrStepSz<U>& d) : PtrStep<T>((T*)d.data, d.step), cols(d.cols), rows(d.rows), size(d.cols,d.rows) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

explicit PtrStepSz(const PtrStepSz<U>& d) : PtrStep<T>((T*)d.data, d.step), cols(d.cols), rows(d.rows) {}

@pasbi
Copy link
Contributor

pasbi commented Jul 5, 2024

@asmorkalov I totally understand your decision.

However, what about my proposal: having a function size() instead? It wouldn't increase the size of the struct and avoid value duplication.

@srinath2468 maybe you could update your pull request?

Please consider to merge this PR with my proposed changed.

@asmorkalov
Copy link
Contributor

size() makes sense then, if it's used.

@pasbi pasbi mentioned this pull request Aug 18, 2024
6 tasks
asmorkalov pushed a commit that referenced this pull request Sep 9, 2024
Add size() to CUDA PtrStepSz #26042

According to [cppreference.com compiler support table](https://en.cppreference.com/w/cpp/compiler_support/17), `nvcc` supports `[[nodiscard]]` from version 11.

### 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
- [ ] 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

Related: #25659
thewoz pushed a commit to CobbsLab/OPENCV that referenced this pull request Feb 13, 2025
Add size() to CUDA PtrStepSz opencv#26042

According to [cppreference.com compiler support table](https://en.cppreference.com/w/cpp/compiler_support/17), `nvcc` supports `[[nodiscard]]` from version 11.

### 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
- [ ] 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

Related: opencv#25659
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants