android - Confusion between OpenCv4Android and C++ data types -


i trying write applications using opencv4android android devices. earlier, using android ndk , c++ native codes. technique wasn't lucid. switched on latest java api coming along opencv 2.4.4 version.

i able write simple programs , run samples. but, while tried write codes advanced problems - model pose estimation, camera calibration routines etc, came across strange confusion. of data types names intuitive in c++ api doesn't fit in in java counterpart. hence, facing terrible difficulty port functionality c++ java. 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 me understand terms used in opencv java , analogy c++.

also, please suggest me reference where, clear , crisp description of these terms given (i tried watching provided along, didn't me much, similar both c++ , java).

quoting andrey pavlenko:

matofxxx classes (e.g. matofpoint) introduced avoid redundant copying of intermediate data between java , native memory. e.g. can large set of points result of 1 opencv function , pass one.

in c++ use std::vector this. use of arraylist in java caused copying points data native opencv level java when returning these points , copying them when calling next opencv function using them. sake of efficiency switched use of matofpoint class in such cases kind of mat of 1n or n1 dimensions keeps point in each element (i.e. of type cv_32sc2 or cv_64fc2).

as may know, mat keeps data on native level, such objects can passed between opencv calls without data copying. if in java code @ point need direct access actual points data there toarray() , fromarray methods explicit transfer data to/from java.

for example, create matofpoint2f containing points corresponding ones existing matofkeypoint need:

  • load keypoints java via matofkeypoint.toarray()
  • iterate through keypoint[] , create corresponding point[] (all of cv::point, cv::point2f , cv::point2d represented org.opencv.core.point in java)
  • use matofpoint2f.fromarray() or c-tor matofpoint2f(point...pa)to put points native level

as 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 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -