Ask Your Question
0

Build Opencv 3.1 + Contrib (face module) for Java

asked 2016-02-20 17:30:18 -0600

DavidCh gravatar image

Hi guys,

I'm looking to use in my Java application the face recognition features provided in the contrib modules but I'm facing a blocking issue : I can't manage to build the opencv_java310.dll.

I have read a lot and tried all that I could think about and today I'm requesting your help please.

In brief, the log file (opencv\build\modules\java\opencv_java.dir\Debug\opencv_java.log) after the build process fails show:

[...] face.cpp
1>C:\DEV\C\opencv\build\modules\java\face.cpp(1726): error C2664: 'bool cv::face::TopNPredictCollector::filter(int *,double *,const int)' : cannot convert argument 1 from 'jint *' to 'int *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

1>C:\DEV\C\opencv\build\modules\java\face.cpp(1961): error C2664: 'bool cv::face::PredictCollector::defaultFilter(int *,double *,const int)' : cannot convert argument 1 from 'jint *' to 'int *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

1>C:\DEV\C\opencv\build\modules\java\face.cpp(2032): error C2664: 'bool cv::face::PredictCollector::filter(int *,double *,const int)' : cannot convert argument 1 from 'jint *' to 'int *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

1>C:\DEV\C\opencv\build\modules\java\face.cpp(2504): error C2664: 'bool cv::face::MinDistancePredictCollector::filter(int *,double *,const int)' : cannot convert argument 1 from 'jint *' to 'int *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

1>Done Building Project "C:\DEV\C\opencv\build\modules\java\opencv_java.vcxproj" (Rebuild target(s)) -- FAILED.

My cmake log shows: -Python 3.4.4 64 bits -Ant 1.8.4 -Java jdk 1.7 64 bits

I'm building with Visual Studio 12 (2013)

Below are the changes I made in cmake:

  • BUILD_SHARED_LIBS:BOOL=0
  • BUILD_opencv_line_descriptor:BOOL=0
  • BUILD_opencv_bgsegm:BOOL=0
  • OPENCV_EXTRA_MODULES_PATH:PATH=C:/DEV/C/opencv_contrib-master/modules
  • BUILD_opencv_rgbd:BOOL=0
  • BUILD_opencv_stitching:BOOL=0
  • BUILD_TESTS:BOOL=0
  • BUILD_opencv_surface_matching:BOOL=0
  • BUILD_opencv_videostab:BOOL=0
  • BUILD_opencv_saliency:BOOL=0
  • BUILD_opencv_reg:BOOL=0
  • BUILD_opencv_bioinspired:BOOL=0
  • BUILD_opencv_calib3d:BOOL=0
  • BUILD_PERF_TESTS:BOOL=0
  • BUILD_opencv_datasets:BOOL=0
  • BUILD_opencv_features2d:BOOL=0
  • BUILD_DOCS:BOOL=0
  • BUILD_opencv_ccalib:BOOL=0
  • BUILD_opencv_optflow:BOOL=0

I have also tried to build contrib with the version 2.4.9 and 3.0 in case there was a compatibiliy issue but no luck.

Please let me know if you need any other information. That's my last hope I fear. Thanks.

edit retag flag offensive close merge delete

Comments

cc @comdiv

yea, that's broken. the script wrappers don't like raw pointers (those better be references)

berak gravatar imageberak ( 2016-02-21 00:10:03 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2016-02-21 02:27:37 -0600

berak gravatar image

updated 2016-02-21 02:29:19 -0600

indeed, the face module in contrib currently does not build for java.

a clumsy workaround (which will probably break the python bindings, but, so what) would be, to disable the java bindings for the newly added PredictCollector stuff:

  • change all occurrences of CV_EXPORTS_W back to CV_EXPORTS here

  • remove CV_WRAP here

  • rerun cmake && make && make install

edit flag offensive delete link more

Comments

OK, thanks I will try that tonight. I'm back to a full of hope state :)

DavidCh gravatar imageDavidCh ( 2016-02-21 09:48:04 -0600 )edit

you could try my small test demo

berak gravatar imageberak ( 2016-02-21 10:16:53 -0600 )edit

That was brillant, thanks Berak it worked ! I managed to generate the jar and the DLL. Thank you so much !

Unfortunately I'm now facing another sort of issue which is that the Imcodecs.imread() returns an empty Mat. It's the same with your very usefull sample you provided earlier. Mat m = Imgcodecs.imread(f.getAbsolutePath(), 0);

I know it's not the topic of this question but any thoughts on that ? I can create another question if you prefer. Thanks.

DavidCh gravatar imageDavidCh ( 2016-02-21 16:07:03 -0600 )edit

Actually, forget about it, my path contained an accentuated character which opencv seems to dislyke. Thanks again.

DavidCh gravatar imageDavidCh ( 2016-02-22 16:40:12 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-02-20 17:30:18 -0600

Seen: 2,259 times

Last updated: Feb 21 '16