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].grab();
readers[1].grab();
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