Skip to content
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

possible unnecessary copy in aruco · charuco.cpp · detectCharucoDiamond #2781

Closed
esopalumpa opened this issue Dec 9, 2020 · 4 comments
Closed

Comments

@esopalumpa
Copy link
Contributor

esopalumpa commented Dec 9, 2020

in charuco.cpp in the aruco module there seems to be an unnecessary explicit copy of an image.

void detectCharucoDiamond(InputArray _image, InputArrayOfArrays _markerCorners,…

    // convert input image to grey
    Mat grey;
    if(_image.type() == CV_8UC3)
        cvtColor(_image, grey, COLOR_BGR2GRAY);
    else
	    _image.copyTo(grey);

If the image already is a grayscale-image it is explicitly copied. grey = _image.getMat(); should do.

EDIT:
same in _selectAndRefineChessboardCorners()

@alalek
Copy link
Member

alalek commented Dec 9, 2020

grey = _image.getMat()

doesn't copy buffer contents.

@esopalumpa
Copy link
Contributor Author

grey = _image.getMat()

doesn't copy buffer contents.

Yes. The image is an InputArray and it is not necessary to copy the data here.

@alalek
Copy link
Member

alalek commented Dec 9, 2020

Agreed.
Implementation doesn't modify data from gray Mat.

Feel free to propose PR (preferable to 3.4 branch).

@esopalumpa
Copy link
Contributor Author

PR #2785 against 3.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants