Ask Your Question

Can I open 2 android cameras concurrently

asked 2013-03-01 17:35:01 -0500

xaffeine gravatar image

When using a personal computer, the code below works well for getting frames concurrently from two video cameras. On Android, so far, it is not working for me.

    std::vector< cv::VideoCapture > readers( 2 );

    for( int camID = 0; camID < 2; ++camID )
        TRACE("opening camera %d", CV_CAP_ANDROID + camID );
        readers[camID].open( CV_CAP_ANDROID + camID );

    while( !stopRequested() )
        std::vector< cv::Mat > frames( 2 );
        TRACE("reading frames");
        readers[0].retrieve( frames[0] );
        readers[1].retrieve( frames[1] );
            // do something with the frames

The first VideoCapture opens fine, but the second open causes log output as shown below. Frames from the first VideoCapture object are good, whereas those from the second are not. Both cameras work fine when accessed individually; only when opened for simultaneous access do they fail. Is this supposed to work? This is all happening on a Nexus 10.

03-01 15:11:58.275: W/ADNC(1216): opening camera 1001
03-01 15:11:58.275: D/OpenCV::camera(1216): CvCapture_Android::CvCapture_Android(1)
03-01 15:11:58.275: D/OpenCV_NativeCamera(1216): CameraHandler::initCameraConnect(0x7288a8c9, 1, 0x70c9fdf8, 0x0)
03-01 15:11:58.275: D/OpenCV_NativeCamera(1216): Connecting to CameraService v 2.3
03-01 15:11:58.275: E/OpenCV_NativeCamera(1216): initCameraConnect: Unable to connect to CameraService
03-01 15:11:58.275: E/OpenCV::camera(1216): CameraWrapperConnector::connectWrapper ERROR: the initializing function returned false
03-01 15:11:58.275: E/OpenCV::camera(1216): Native_camera returned opening error: 6
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-03-01 22:57:46 -0500

cv::VideoCapture class implementation for Android does not support several cameras in the same time. I recommend you to try the same with standard Java camera.

edit flag offensive delete link more


Thanks for the information, Alex. You'll probably notice another camera question from me!

xaffeine gravatar imagexaffeine ( 2013-03-04 15:24:54 -0500 )edit

I investigate the problem. Android Camera API does not support cocurrent camera usage. So It is impossible both for Android camera API and cv::VideoCapture (Highgui.VideoCapture in Java).

Alexander Smorkalov gravatar imageAlexander Smorkalov ( 2013-04-12 09:12:51 -0500 )edit

Question Tools


Asked: 2013-03-01 17:35:01 -0500

Seen: 2,603 times

Last updated: Mar 01 '13