Skip to content

Adding functions rbegin() and rend() functions to matrix class.#19967

Merged
alalek merged 5 commits intoopencv:masterfrom
HattrickGenerator:master
May 20, 2021
Merged

Adding functions rbegin() and rend() functions to matrix class.#19967
alalek merged 5 commits intoopencv:masterfrom
HattrickGenerator:master

Conversation

@HattrickGenerator
Copy link
Copy Markdown
Contributor

@HattrickGenerator HattrickGenerator commented Apr 23, 2021

This is important to be more standard compliant with C++ and an ever increasing number of people using standard algorithms for better code readability- and maintainability.

The functions are copy pasted from their counterparts (even though they should probably call the counterparts but this gave me some trouble).
They return iterators using std::reverse_iterators

Follow up of an open feature request:
#4641

Edit: Additionally there should be a test implemented for it. This still has to be done.

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 other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to 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
force_builders=linux,docs,Custom,Win64

build_image:Custom=centos:7
buildworker:Custom=linux-1,linux-4,linux-6

@vpisarev
Copy link
Copy Markdown
Contributor

@HattrickGenerator, thank you for the contribution! Please, add regression tests for this functionality.

@HattrickGenerator
Copy link
Copy Markdown
Contributor Author

HattrickGenerator commented May 2, 2021

@vpisarev, thanks for your comment. A contributor wrote a test for it and I merged it. Do I open a new PR in order to re-run the jenkins builds + tests?

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

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

Well done 👍

@alalek
Copy link
Copy Markdown
Member

alalek commented May 18, 2021

Please:

  • fix warnings from Windows builders
  • resolve conflicts (merge upstream code and resolve issues)

HattrickGenerator and others added 5 commits May 20, 2021 13:03
This is important to be more standard compliant with C++ and an ever increasing number of people using standard algorithms for better code readability- and maintainability.

The functions are copy pated from their counterparts (even though they should probably call the counterparts but this gave me some troube).
They return iterators using std::reverse_iterators

Follow up of an open feature request:
opencv#4641
…don't need to repeat the template argument.

An instantiating cv::Mat_<int> for example can call it's rbegin() function and doesn't need rbegin<int>() with this convience addition.

Follows what is done for forward iterators
@HattrickGenerator
Copy link
Copy Markdown
Contributor Author

Fixed the warning under windows and rebased my branch on master to keep a linear history.

@alalek alalek merged commit 115e471 into opencv:master May 20, 2021
@alalek alalek mentioned this pull request Jun 4, 2021
a-sajjad72 pushed a commit to a-sajjad72/opencv that referenced this pull request Mar 30, 2023
* Adding functions rbegin() and rend() functions to matrix class.
This is important to be more standard compliant with C++ and an ever increasing number of people using standard algorithms for better code readability- and maintainability.

The functions are copy pated from their counterparts (even though they should probably call the counterparts but this gave me some troube).
They return iterators using std::reverse_iterators

Follow up of an open feature request:
opencv#4641

* Fix rbegin() and rend() and provide tests for them

* Removing unnecessary whitespaces

* Adding rbegin and rend to Mat_ class with the right parameters so we don't need to repeat the template argument.
An instantiating cv::Mat_<int> for example can call it's rbegin() function and doesn't need rbegin<int>() with this convience addition.

Follows what is done for forward iterators

* static cast the vector size (return size_t) to an int (that is required for opencv mat constructor)

Co-authored-by: Stefan <stefan.gerl@tum.de>
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