Ask Your Question
2

Confusion between OpenCv4Android and C++ data types

asked 2013-04-08 09:03:47 -0600

utkarshmankad gravatar image

updated 2013-04-09 06:44:25 -0600

Andrey Pavlenko gravatar image

I am trying to write some applications using OpenCv4Android for Android devices. Earlier, i was using Android NDK and C++ native codes. But that technique wasn't much lucid. So i switched over to latest Java API coming along with OpenCV 2.4.4 version.

I was able to write simple programs and run samples. But, while i tried to write some codes for advanced problems like - Model POSE estimation, Camera calibration routines etc, I came across this very strange confusion. Some of the data types whose names are very intuitive in C++ API doesn't really fit in in their Java counterpart. Hence, I am facing terrible difficulty to port my functionality from C++ to Java. I am facing utter confusion in these functions

  • Point2f (in C++ ) - MatOfPoint2f (in Java)
  • Point3f (in C++) - MatOfPoint3f (in Java)
  • Point2 (in Java)
  • Point3 (in Java)

Please help me understand the terms used in OpenCV Java and its analogy with C++.

Also, please suggest me some reference where, clear and crisp description of these terms are given (i tried watching the help provided along, but it didn't help me much, as it was somewhat similar for both C++ and Java).

edit retag flag offensive close merge delete

Comments

just a guess in the blind (I haevn't used the java-api so far): does MatOfPoint2i and MatOfPoint3i work for Point2 and Point3, respectively?

Guanta gravatar imageGuanta ( 2013-04-08 15:35:36 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
8

answered 2013-04-09 06:42:00 -0600

Andrey Pavlenko gravatar image

As for the MatOfXxx types I'd suggest you read this answer

As for the C++ vs Java types correspondence:

vector<Point>    : MatOfPoint
vector<Point2f>  : MatOfPoint2f
vector<Point3i>  : MatOfPoint3
vector<Point3f>  : MatOfPoint3f
vector<KeyPoint> : MatOfKeyPoint
vector<DMatch>   : MatOfDMatch
vector<Rect>     : MatOfRect
vector<uchar>    : MatOfByte
vector<char>     : MatOfByte
vector<int>      : MatOfInt
vector<float>    : MatOfFloat
vector<double>   : MatOfDouble
vector<Vec4i>    : MatOfInt4
vector<Vec4f>    : MatOfFloat4
vector<Vec6f>    : MatOfFloat6
edit flag offensive delete link more

Comments

Thanks a lot, Andrey Pavlenko, this is exactly what I was looking for. Thank you very much

utkarshmankad gravatar imageutkarshmankad ( 2013-04-09 06:51:27 -0600 )edit
1

@Andrey , Hi this is very usefull. Thnx. But now I 'm struggling to Convert only Vec4i to Java type? Not the vector. Can you help me one this?

ssdehero gravatar imagessdehero ( 2013-10-28 06:32:44 -0600 )edit

And what is equivalent to vector<mat> in java?

14051598-023 gravatar image14051598-023 ( 2018-06-10 05:08:30 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2013-04-08 09:03:47 -0600

Seen: 8,654 times

Last updated: Apr 09 '13