opencv-android icon indicating copy to clipboard operation
opencv-android copied to clipboard

Is it possible to use this project with c++/JNI openCV code?

Open StainlessStlRat opened this issue 3 years ago • 4 comments

I just found this project, and it would be a huge boon to me to be able to use this instead of openCV4AndroidSDK

However, most of my openCV code is c++. Is it possible to use this project for that?

StainlessStlRat avatar Dec 22 '22 03:12 StainlessStlRat

Hey @StainlessStlRat , did you manage to use C++ for this?

skizzo avatar Jun 10 '24 13:06 skizzo

@skizzo i just used the tried and true method of bringing in the project as a module

StainlessStlRat avatar Jun 11 '24 05:06 StainlessStlRat

@skizzo i just used the tried and true method of bringing in the project as a module

Could you share a code example?

skizzo avatar Jun 11 '24 05:06 skizzo

@skizzo I only just realized this was on a non opencv forum. Go to openCV forum, download the openCV4AndroidSDK, follow their instructions for adding it as a module. That'll get you access to the Java part.

For c++ dev, you need to get a reference to the SDK/Libs. Assuming you know how to use CMake, here's what I do to get the reference. Note that ~/dev/OpenCV-... is where my sdk copy is.

set(OpenCVAndroidSDKLocation "~/dev/OpenCV-android-sdk") set(OpenCV_DIR "${OpenCVAndroidSDKLocation}/sdk/native/jni/") message(STATUS "Searching for openCV libs at: ${OpenCV_DIR}") find_package(OpenCV REQUIRED java) message(STATUS "opencv found: ${OpenCV_LIBS}")

Then you can add it to a target like this:

target_link_libraries(OpenCVUtil ${OpenCV_LIBS} )

Hope that helps

StainlessStlRat avatar Jun 15 '24 03:06 StainlessStlRat