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

HoughLinesP - java.lang.NullPointerException: Attempt to invoke virtual method 'org.bytedeco.javacpp.BytePointer org.bytedeco.javacpp.BytePointer.capacity(long)' on a null object reference #1146

Closed
nicemanis opened this issue Mar 2, 2019 · 6 comments
Labels

Comments

@nicemanis
Copy link

Hello,
I'm trying to use HoughLinesP method as follows:

Mat lines = new Mat();
HoughLinesP(mat_points, lines, 1, CV_PI / 180, 50);
IntRawIndexer linesIdx = lines.createIndexer();
for (long i = 0; i < linesIdx.rows(); i++) {
    int x0 = linesIdx.get(i, 0, 0);
    int y0 = linesIdx.get(i, 0, 1);
    int x1 = linesIdx.get(i, 0, 2);
    int y1 = linesIdx.get(i, 0, 3);
    line(roi, new Point(x0, y0), new Point(x1, y1), Scalar.GREEN);
}

However, it throws the following error on this (IntRawIndexer linesIdx = lines.createIndexer();) line:

java.lang.NullPointerException: Attempt to invoke virtual method 'org.bytedeco.javacpp.BytePointer org.bytedeco.javacpp.BytePointer.capacity(long)' on a null object reference
        at org.bytedeco.javacpp.helper.opencv_core$AbstractMat.createIndexer(opencv_core.java:1881)
        at org.bytedeco.javacpp.helper.opencv_core$AbstractArray.createIndexer(opencv_core.java:147)

Is it a bug in the library or am I using it wrong? I tried checking if lines object is null, but it is not.

@saudet
Copy link
Member

saudet commented Mar 3, 2019 via email

@nicemanis
Copy link
Author

How can I check if it succeeds? Lines object won't be null since I initialized it.
I managed to recreate it with cvHoughLines2 following this example. What are the differences between both of these and which method is preferred?

@saudet saudet added the bug label Mar 3, 2019
saudet added a commit to bytedeco/javacpp-presets that referenced this issue Mar 3, 2019
@saudet
Copy link
Member

saudet commented Mar 3, 2019

Actually, it looks like those functions don't accept a Mat for their outputs. I've fixed that in commit bytedeco/javacpp-presets@e1d516d. Please give it a try with 1.4.5-SNAPSHOT in a few hours when the builds are ready: http://bytedeco.org/builds/

@nicemanis
Copy link
Author

How can I load the snapshot version with Gradle?
If I use:
implementation group: 'org.bytedeco.javacpp-presets', name: 'opencv-platform', version: '4.0.1-1.4.5-SNAPSHOT'
It returns
ERROR: Failed to resolve: org.bytedeco.javacpp-presets:opencv-platform:4.0.1-1.4.5-SNAPSHOT

@saudet
Copy link
Member

saudet commented Mar 7, 2019

The instructions for that are on the page:
http://bytedeco.org/builds/

@saudet
Copy link
Member

saudet commented Apr 11, 2019

The fixes are now included in JavaCV 1.5. Thanks for reporting and enjoy!

@saudet saudet closed this as completed Apr 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants