0

I'm currently working on an android application. On java side I pass a List<KeyPoint> objectKeypoints to native Code. But how can I convert this jobject on native side to Vector<Keypoint> objectKeypoints for further processing.

Exaample: Java Side my calling method:

List<KeyPoint> objKeypoints;
Mat mGrayMat = ;// is not empty;
FeatureDetector featureDetector = FeatureDetector.create(FeatureDetector.SURF);
featureDetector.detect(obj_keypoints, mGrayMat);

FindObject(objKeypoints,mGrayMat );

Native Side C++ Code;

JNIEXPORT void JNICALL Java_my_app_AndroidAppView_FindObject(JNIEnv* env, jobject obj, jobject obj_keypoints, jlong matAddrObjGray){
// How to convert obj_keypoints to Vector<KeyPoint>?
Vector<KeyPoint> objectKeypoints = ....;
Next Step is calculating the descriptors for the Keypoints.
}
UniQ
  • 1
  • 1

1 Answers1

0

You can't, unless it really is a Vector. If the interface just specifies List you should process it as a List. If you need a Vector, change the interface to require Vector.

You could also build a new Vector from the List, but it seems pointlessly expensive.

user207421
  • 305,947
  • 44
  • 307
  • 483
  • Thanks for the response. On Java side I can change the first Line: "List objKeypoints;" To "Vector objKeypoints;" Generally I don't know how to cast jobject on native side to Vector – UniQ May 08 '12 at 23:30
  • @Uniq If you can change the interface you don't have to do any casting at all. In fact there is no such thing as a cast in JNI. You just lookup the methods you want to call from the class they are declared in, and call them. If the object isn't of that class you will get an exception. – user207421 May 09 '12 at 10:35