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

Super confusing Scalar constructors #1224

Closed
b005t3r opened this issue Jun 7, 2019 · 1 comment
Closed

Super confusing Scalar constructors #1224

b005t3r opened this issue Jun 7, 2019 · 1 comment

Comments

@b005t3r
Copy link

b005t3r commented Jun 7, 2019

There are two, very easily to confuse, constructors in org.bytedeco.opencv.opencv_core.Scalar:

    /** Native array allocator. Access with {@link Pointer#position(long)}. */
    public Scalar(long size) { super((Pointer)null); allocateArray(size); }

and

    public Scalar(double v0) { super((Pointer)null); allocate(v0); }

I wasted some time yesterday trying to figure out why my code does not draw the right shapes and finally noticed that I was creating white color using new Scalar(255) instead of new Scalar(255.0).

I'd suggest making the public Scalar(long size) constructor private and replacing it with a static factory method to avoid this madness I had to go through.

saudet added a commit to bytedeco/javacpp that referenced this issue Jun 14, 2019
…, `float`, or `double` constructor already exists (issue bytedeco/javacv#1224)
@saudet
Copy link
Member

saudet commented Jul 10, 2019

These constructors are now all gone with version 1.5.1. There doesn't appear to be any classes in all the presets that are both meant to be used as part of arrays and have constructors with a single real value. Thanks for the suggestion!

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