I’m trying to use new OpenCV feature on Android: native camera access. According to this document, it’s quite easy, but I only get the error without success.
There is DDMS log:
08-26 03:28:56.825: DEBUG/CAMERA_ACTIVITY(12613): Library name: libopencv_java.so
08-26 03:28:56.825: DEBUG/CAMERA_ACTIVITY(12613): Library base address: 0x81800000
08-26 03:28:56.835: DEBUG/CAMERA_ACTIVITY(12613): Libraries folder found: /data/data/com.viactivity.ar/lib/
08-26 03:28:56.835: DEBUG/CAMERA_ACTIVITY(12613): CameraWrapperConnector::connectToLib: folderPath=/data/data/com.viactivity.ar/lib/
08-26 03:28:56.835: ERROR/CAMERA_ACTIVITY(12613): ||libnative_camera_r2.2.2.so
08-26 03:28:56.835: ERROR/CAMERA_ACTIVITY(12613): ||libnative_camera_r2.3.3.so
08-26 03:28:56.835: DEBUG/CAMERA_ACTIVITY(12613): try to load library ‘libnative_camera_r2.2.2.so’
08-26 03:28:56.835: DEBUG/CAMERA_ACTIVITY(12613): CameraWrapperConnector::connectToLib ERROR: cannot dlopen camera wrapper library /data/data/com.viactivity.ar/lib/libnative_camera_r2.2.2.so, dlerror=”Cannot load library: find_library[1223]: 11258 ‘libnative_camera_r2.2.2.so’ failed to load previously”
08-26 03:28:56.835: DEBUG/CAMERA_ACTIVITY(12613): try to load library ‘libnative_camera_r2.3.3.so’
08-26 03:28:56.835: DEBUG/CAMERA_ACTIVITY(12613): CameraWrapperConnector::connectToLib ERROR: cannot dlopen camera wrapper library /data/data/com.viactivity.ar/lib/libnative_camera_r2.3.3.so, dlerror=”Cannot load library: find_library[1223]: 11258 ‘libnative_camera_r2.3.3.so’ failed to load previously”
08-26 03:28:56.835: ERROR/CAMERA_ACTIVITY(12613): CameraWrapperConnector::connectToLib ERROR: cannot dlopen camera wrapper library
08-26 03:28:56.835: ERROR/CV_CAP(12613): Native_camera returned opening error: 4
08-26 03:28:56.835: ERROR/AR_code(12613): Capture Error!
There are two variants of code:
CvCapture* capture = cvCaptureFromCAM( CV_CAP_ANDROID + 0 );
IplImage* frame = cvQueryFrame( capture );
cvReleaseCapture(&capture);
.
cv::VideoCapture capture(CV_CAP_ANDROID + 0);
cv::Mat frame;
capture >> frame;
Both of them produce the same errors.
Does somebody was able to get native camera access on Android?
Thanks a lot!
UPD:
The story above is about Android 3.2. According to the words of Andrey Kamaev, Android 3.2 isn’t supported.
I tried to test the same code on HTC Wildfire, but got another error:
08-26 19:49:06.856: DEBUG/OpenCV_NativeCamera(1337):
CameraHandler::initCameraConnect(0x813e65a1, 0, 0x285a20, 0x0) 08-26
19:49:06.856: DEBUG/CameraService(72): CameraService::connect E (pid
1337, client 0x693d8) 08-26 19:49:06.856: DEBUG/CameraService(72):
CameraService::connect X (pid 1337, new client 0x693d8) rejected. (old
pid 1337, old client 0x18728) 08-26 19:49:06.856:
ERROR/OpenCV_NativeCamera(1337): initCameraConnect: Unable to connect
to CameraService 08-26 19:49:06.856: ERROR/CAMERA_ACTIVITY(1337):
CameraWrapperConnector::connectWrapper ERROR: the initializing
function returned false 08-26 19:49:06.856: ERROR/CV_CAP(1337):
Native_camera returned opening error: 6
Any ideas?
At the moment OpenCV native camera does not support Android 3.2 (because its sources are not publicly available.)
I’ll post an update as soon as version compatible with Android 3.2 become available.
Update:
OpenCV trunk already has solution for Android 3.x and 4.0.x. It will be included into the next major release of OpenCV.