Skip to content

core: add writeTo() for ROI operation #27318

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
wants to merge 2 commits into
base: 4.x
Choose a base branch
from
Open

Conversation

Kumataro
Copy link
Contributor

Close #27298

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


Mat dst = _dst.getMat();
CV_CheckTrue( !dst.empty(), "dst must not be empty" );
CV_CheckEQ(type(), dst.type(), "Make the type of dst the same as src");
Copy link
Contributor

Choose a reason for hiding this comment

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

CV_CheckTypeEQ

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your comment, I fixed it.

@sa copyTo

*/
void overwriteTo( OutputArray m ) const;
Copy link
Contributor

Choose a reason for hiding this comment

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

Just writeTo() ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your comment ! Naming functions is very difficult problem.

It is required to express the condition that src and dst must be of the same type and size.
For some verbs(writeTo, updateTo), I feel that the difference with copyTo() is hard to explain.

Below are some possible function names that I was considering:

(0) src.copyTo(roi); // currently
(1) src.updateTo(roi);.
(2) src.writeTo(roi);
(3) src.overwriteTo(roi);
(4) src.rewriteTo(roi);
(5) src.recopyTo(roi);
(6) src.copyToWithoutReallocation(roi); // too long.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I reconsidered it again., writeTo() naming is suitable for this purpose, thank you very much ! I fixed it.

  • src.writeTo(emptyMat) makes an exception -> natural.
  • src.writeTo(differentTypeMat) makes an exception -> natural
  • src.writeTo(differentSizeMat) makes an exception -> natural.

@Kumataro
Copy link
Contributor Author

Original #27298 has been closed with "wontfix" tag.
Should I abandon this pull request ?

@asmorkalov
Copy link
Contributor

No.
@vpisarev Please join the discussion.

@Kumataro
Copy link
Contributor Author

@asmorkalov Thank you for your reply.

If copyAt() function is introduced at #27320 , I think this PR will be unnessesary because thery has the same purpose.

@Kumataro Kumataro changed the title core: add overwriteTo() for ROI operation core: add writeTo() for ROI operation May 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mat::copyTo() fails without raising an exception
3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy