Skip to content

Instantly share code, notes, and snippets.

/gist.rbx Secret

Created October 6, 2016 16:25
Show Gist options
  • Save anonymous/e50639738d97d4e6b1cd551cb3ce1fc6 to your computer and use it in GitHub Desktop.
Save anonymous/e50639738d97d4e6b1cd551cb3ce1fc6 to your computer and use it in GitHub Desktop.
%typemap(jstype) cv::Rect "org.opencv.core.Rect" // C++ cv::Rect corresponds to JAVA org.opencv.core.Rect (any input parameter or return value will be mapped to org.opencv.rect in the created JAVA classes)
%typemap(jtype) cv::Rect "org.opencv.core.Rect" // C++ cv::Rect corresponds to the JAVA intermediary type org.opencv.Rect in the generated JNI class (any input parameter or return value will be mapped to org.opencv.rect in the JNI classes)
%typemap(jni) cv::Rect "jobject" // C++ cv::Rect is treated as a jobject in the C++ part of the JNI code
%typemap(javaout) cv::Rect {
return $jnicall;
} // the JAVA implementation returning a cv::Rect just returns the result of the jni call
%typemap(out) cv::Rect{ // the C++ JNI implementation. This tells SWIG how to return a cv::Rect to JAVA via JNI
jclass jRectClass = jenv->FindClass("org/opencv/core/Rect");
jmethodID jRectConstructor = jenv->GetMethodID(jRectClass, "<init>", "(IIII)V");
jobject jRect = jenv->NewObject(jRectClass, jRectConstructor, $1.x, $1.y, $1.width, $1.height);
$result = jRect;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment