Friday, January 2, 2015

OpenCV vs Android vs UE4

Here goes another combination of system.
OpenCV provides native camera access for android, which is great for UE4. It came with two set of libraries .a and .so.  The .a libraries simply added to UE4 build system without any problems (in .build.cs, insert PublicAdditionalLibraries.Add(...) )
.so is a more tricky. In order to get camera preview, libnative_camera_r???.so has to be packed into the android apk (opencv will look for one on opening a VideoCapture). To add that .so, I use a hacked approach, I insert the following line into CopySTL in UEDeployAndroid.cs of the UnrealBuildTool:
File.Copy("[CVAndroidSDKPath]/sdk/native/libs/armeabi-v7a/libnative_camera_r4.4.0.so", UE4BuildPath + "/libs/" + Arch + "/libnative_camera_r4.4.0.so");

And that is it...