CV_EXPORTS_W, namespaces and java
Hello,
having functions with indentical signature in different namespaces is no problem in C++. If taged with CV_EXPORTS_W
this works in python to, but not in java (at least not here).It gives a name-collision.
Is there a way to make this work? For example by mapping namespaces to packages?
(org.opencv.aruco
and org.opencv.aruco.fisheye
?)
Edit:
For example: I added (cloned) a function into an namespace:
cv::fisheye::getOptimalNewCameraMatrix (InputArray cameraMatrix, InputArray distCoeffs, Size imgSize, double alpha, Size newImgSize=Size(), Rect *validPixROI=0, bool centerPrincipalPoint=false)
which already exists with same signature in namespace cv::
The automatic generated python bindings get cv2.getOptimalNewCameraMatrix()
and cv2.fisheye.getOptimalNewCameraMatrix()
, but the automatic generated java binding got a name collision when I build opencv+contrib for android.
Edit2:
Error messages:
FAILED: cd /home/mabe7492/software/opencv/test/o4a/android_sdk && /usr/bin/ant -q -noinput -k debug -Djava.target=1.6 -Djava.source=1.6 && /usr/bin/cmake -E touch /home/mabe7492/software/opencv/test/o4a/CMakeFiles/dephelper/opencv_java_android
[subant] No sub-builds to iterate on
…
[javac] …/test/o4a/android_sdk/src/org/opencv/calib3d/Calib3d.java:314: error: method getOptimalNewCameraMatrix(Mat,Mat,Size,double,Size,Rect,boolean) is already defined in class Calib3d
[javac] public static Mat getOptimalNewCameraMatrix(Mat cameraMatrix, Mat distCoeffs, Size imgSize, double alpha, Size newImgSize, Rect validPixROI, boolean centerPrincipalPoint)
[javac] ^
[javac] …/o4a/android_sdk/src/org/opencv/calib3d/Calib3d.java:323: error: method getOptimalNewCameraMatrix(Mat,Mat,Size,double) is already defined in class Calib3d
[javac] public static Mat getOptimalNewCameraMatrix(Mat cameraMatrix, Mat distCoeffs, Size imgSize, double alpha)
[javac] ^
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
can you be a bit more detailled about the resp. functions, so we can try to look it up ? what exactly works in pyton, but not in java ?
I added functions. p.e.
cv::fisheye::getOptimalNewCameraMatrix (InputArray cameraMatrix, InputArray distCoeffs, Size imgSize, double alpha, Size newImgSize=Size(), Rect *validPixROI=0, bool centerPrincipalPoint=false)
which already exists with same signature in namespace cv:: The automatic generated python bindings get cv2.getOptimalNewCameraMatrix() and cv2.fisheye.getOptimalNewCameraMatrix(), but the automatic generated java binding got a name collision when I build opencv+contrib for android
https://github.com/opencv/opencv/issu...
in other words, unless that gets repaired, you have to be extra careful to pick the method with the correct set of params
Rect *validPixROI=0,
-- oh, you cannot have raw pointers in wrapper interfaces. this probably gets rejected from the generator scriptThe android build failed (and probably all java builds will fail). I have to change the signature or do not export them (
CV_EXPORTS_W
→CV_EXPORTS
) at all.I added the error-messages to the OP.
take a look at build/modules/java_generator , there should be txt/log files for the modules, there'S probably an explanation there
ah, build failed, different story then.
but again, we need more details, about what you did. try to edit your question, and append there.
the java wrappers do not respect c++ namespaces properly, so you cannot use the same names or exact same function signatures