Ask Your Question
1

How can I view 2 camera views simultaneously?

asked 2013-02-21 14:02:48 -0600

klimbot gravatar image

I'm trying to get the output of both front and rear cameras of my Android phone at the same time.

The only way I have been able to get images from both cameras is to define both front and rear camera surfaces and switch between the two, but this is not what I want. From my limited knowledge I can tell that if I enable both cameras on start up onCameraFrame() only returns one of the camera images. Any ideas?

thanks.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2013-02-22 12:18:41 -0600

In most cases application uses only one camera in the same time. So all OpenCV examples added only one view in the window layout and CvCameraViewListener/CvCameraViewListener2 interface implementation to Activity class. It simplifies examples and helps most developers to start easier.

In your case you need to add two views to application layout (vertical or horizontal, as you want) and add two fields to Activity, that implements CvCameraViewListener/CvCameraViewListener2 for both cameras. Separate view components in layout, separate CvCameraViewListener/CvCameraViewListener2 objects for view events handling.

edit flag offensive delete link more
1

answered 2013-02-22 00:27:40 -0600

You need to create layout with two JavaCameraViews with different camera indices and call setCvCameraViewListener to both of them. I recommend you to use two separate CvCameraViewListener/CvCameraViewListener2 implementations for cameras to eliminate conflicts. Also, The opportunity to work with both cameras in the same time depends on Android camera hardware and software stack. I do not sure that it works with all double-camera devices.

edit flag offensive delete link more

Comments

Thanks for the suggestion Alexander.

I have been able to successfully change camera views by switching between two JavaCameraViews that are set to front and rear cameras, but I'm having some trouble with the implementation of CvCameraViewListener2. I tried to re-implement all CameraBridgeViewBase methods with a CameraBridgeViewBase2 equivalent (all within the CameraBridgeViewBase class) but didn't have any luck. I wasn't able to successfully bind to the onCameraViewStarted2() method. My coding skills aren't the greatest so I'm not 100% sure of my implementation. Is this the was you were suggesting Alexander? Or were you suggesting I create an entire new class called CameraBridgeViewBase2?

Thanks for the help

klimbot gravatar imageklimbot ( 2013-02-22 05:32:59 -0600 )edit

Question Tools

Stats

Asked: 2013-02-21 14:02:48 -0600

Seen: 2,517 times

Last updated: Feb 22 '13