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

OpenCV Vec4iVector should be built on IntPointer #717

Closed
jpsacha opened this issue Apr 19, 2019 · 5 comments
Closed

OpenCV Vec4iVector should be built on IntPointer #717

jpsacha opened this issue Apr 19, 2019 · 5 comments
Labels

Comments

@jpsacha
Copy link
Member

jpsacha commented Apr 19, 2019

In C++ code Vec4i is defined as a vector of integers:

typedef Vec<int, 4> cv::Vec4i

In org.bytedeco.opencv.presets.opencv_imgproc (line 53) it is defined based on FloatPointer:

new Info(..., "cv::Vec4i", ...).cast().pointerTypes("FloatPointer"))

it should be rather:

new Info("cv::Vec4i").cast().pointerTypes("IntPointer"))

A problem with current implementation can be seen when using HoughLinesP. It will produce lines' coordinates as Vec4i. Those coordinates of lines cannot be correctly transferred from the C++ side.

@jpsacha jpsacha changed the title Vec4iVector should be built on IntPointer OpenCV Vec4iVector should be built on IntPointer Apr 19, 2019
jpsacha added a commit to jpsacha/javacpp-presets that referenced this issue Apr 19, 2019
@saudet
Copy link
Member

saudet commented Apr 20, 2019

Yes, that's an error that slipped there. In any case, to work around that with the current release, we can easily cast to IntPointer to access it properly.

@jpsacha
Copy link
Member Author

jpsacha commented Apr 20, 2019

Not clear how workaround with casting to IntPointer should be done.

Here is some sample code that is using HoughLinesP to get line fragments(lines):

Vec4iVector lines = new Vec4iVector()
HoughLinesP(binary, lines, deltaRho, deltaTheta, minVotes, minLength, minGap)
FloatPointer l = lines.get(i)
float x1 = l.get(0)

Due to the bug, the value of x1 is not extracted correctly. Where the casting to IntPointer should happen?

@saudet
Copy link
Member

saudet commented Apr 20, 2019

Something like this:

IntPointer l = new IntPointer(lines.get(i));
int x1 = l.get(0);

jpsacha added a commit to bytedeco/javacv-examples that referenced this issue Apr 20, 2019
@jpsacha
Copy link
Member Author

jpsacha commented Apr 20, 2019

The workaround works. I added it to the LineFinder example.

@saudet saudet added the bug label Apr 21, 2019
saudet added a commit that referenced this issue Apr 21, 2019
@saudet
Copy link
Member

saudet commented Jul 9, 2019

Fix included in version 1.5.1. Thanks for reporting!

@saudet saudet closed this as completed Jul 9, 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