CV_EXPORTS_W, namespaces and java

asked 2018-04-25 09:39:42 -0600

esopaLoompa gravatar image

updated 2018-04-25 10:38:10 -0600

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.
edit retag flag offensive close merge delete

Comments

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 ?

berak gravatar imageberak ( 2018-04-25 09:45:07 -0600 )edit

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

esopaLoompa gravatar imageesopaLoompa ( 2018-04-25 10:17:55 -0600 )edit

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

berak gravatar imageberak ( 2018-04-25 10:22:25 -0600 )edit

Rect *validPixROI=0, -- oh, you cannot have raw pointers in wrapper interfaces. this probably gets rejected from the generator script

berak gravatar imageberak ( 2018-04-25 10:25:35 -0600 )edit

The android build failed (and probably all java builds will fail). I have to change the signature or do not export them (CV_EXPORTS_WCV_EXPORTS) at all.

I added the error-messages to the OP.

esopaLoompa gravatar imageesopaLoompa ( 2018-04-25 10:27:17 -0600 )edit

take a look at build/modules/java_generator , there should be txt/log files for the modules, there'S probably an explanation there

berak gravatar imageberak ( 2018-04-25 10:29:05 -0600 )edit

ah, build failed, different story then.

but again, we need more details, about what you did. try to edit your question, and append there.

berak gravatar imageberak ( 2018-04-25 10:29:57 -0600 )edit

the java wrappers do not respect c++ namespaces properly, so you cannot use the same names or exact same function signatures

berak gravatar imageberak ( 2018-04-26 01:09:48 -0600 )edit