简体   繁体   中英

include nonfree to opencv4android

I'm trying to add the nonfree function to my android application in order to use SurfFeatureDetector and SurfDescritorExtractor.

For that I followed this tutorial but I first had the following error /libnonfree/jni/precomp.hpp:46:30: fatal error: opencv2/cvconfig.h: No such file or directory which can be resolved by commenting the include line.

But now I've got this error /libnonfree/jni/precomp.hpp:66:42: fatal error: opencv2/ocl/private/util.hpp: No such file or directory

So I copied the C:\\opencv\\sources\\modules\\ocl\\include\\opencv2\\ocl\\private and C:\\opencv\\sources\\modules\\ocl\\include\\opencv2\\ocl\\cl_runtime folders to C:\\OpenCV-android-sdk\\sdk\\native\\jni\\include\\opencv2\\ocl\\

But now I get those errors :

/include/opencv2/ocl/private/util.hpp:65:8: error: 'cl_device_id' does not name a type
/include/opencv2/ocl/private/util.hpp:70:8: error: 'cl_context' does not name a type
/include/opencv2/ocl/private/util.hpp:75:8: error: 'cl_command_queue' does not name a type
... and so on

I am using cygwin to build the libnonfree and use it on adroid studio here is my Android.mk :

LOCAL_PATH  := $(call my-dir)

include $(CLEAR_VARS)
OPENCV_INSTALL_MODULES := on
OPENCV_CAMERA_MODULES  := off
include C:\OpenCV-android-sdk\sdk\native\jni\OpenCV.mk

LOCAL_C_INCLUDE := C:\OpenCV-android-sdk\sdk\native\jni\include

LOCAL_SRC_FILES := nonfree_init.cpp sift.cpp surf.cpp

LOCAL_MODULE := nonfree
LOCAL_CFLAGS := -Werror -O3 -ffast-math
LOCAL_LDLIBS := -llog -ldl

include $(BUILD_SHARED_LIBRARY)

Can someone explain me what am I doing wrong ? Thanks

I solved this issue as below:

  • delete or comment out these lines in precomp.hpp

//#include "cvconfig.h"

and

//#ifdef HAVE_OPENCV_OCL

....

//#endif

  • in nonfree_init.cpp, delete lines:

//#ifdef HAVE_OPENCV_OCL

...

//#endif

finally, you can build nonfree modules without copying ocl private folder.

Cheers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM