How to set up a camera on Android with OpenCV + Qt5

There are many questions here, such as Qt sites and OpenCV sites, but none of them are relevant to my case. (And still did not answer.)

I use OpenCV for Android 2.4.6 (a preliminary version downloaded from the official site) to create a native Android application (4.1.2) on Samsung Galaxy Note 2 with Qt 5.0.1 for Android (using QtCreator 2.7.2) on a Linux host x86_64.

I am linked to the libraries in the .. / sdk / native / libs / armeabi -v7a folder. (I did not create OpenCV from the source code, I just use what was in the downloaded package). This includes the libopencv_androidcam.a library. (And I also tried libnative_camera_r4.1.1.so shared lib.) I also downloaded the Market app "OpenCV Manager".

The .apks samples from the samples directory work on my phone, but I did not try to create them myself, since I do not have the Java development environment installed.

Launching my application containing the instruction cv::VideoCapture inputCapture(CV_CAM_ANDROID); , I get the following error without entering the camera:

 E/OpenCV::camera(15299): CameraWrapperConnector::connectToLib ERROR: cannot dlopen camera wrapper library E/OpenCV::camera(15299): Native_camera returned opening error: 4 

My questions:

  • Should this work? I have seen a lot of bug reports, but all with older versions of OpenCV and older / older Android versions. Bonus points, if it was seen working on this phone model.
  • Should this work out of the box with the OpenCV Android SDK loaded? Or do I need to create OpenCV from a source with some special options? (What kind?)
  • Do I need special library versions on the phone itself? Do I need root access to the device to work?
  • Are there any β€œknown for work" Andoid examples using native code instead of Java?

Thanks for the help!

+4
source share
1 answer

I will repeat the answer I received from @Moster at http://answers.opencv.org here:

Copy the libnative_camera_r4.1.1.so file from the / sdk / native / libs / armeabi -v7a folder to your Qt / Android / LIES / armeabi-v7a project folder. Make sure you also enable the camera in android_manifest in the Qt creator. Maybe all this helps

It really works. Although I already mentioned camera permissions in Manifest.xml (or rather the Qt project settings), copying the shared library to the project directory did the trick.

It looks like it was found and linked during assembly, but was not copied to the device from its original location. Could β€œCopy local Qt libs to the device” fail into the deployment parameters (only Qt libs?) Or the OpenCV Manager application (loads only the necessary libs when called directly from Java code?).

+1
source

Source: https://habr.com/ru/post/1495779/


All Articles