4

Is it possible to broadcast the android camera preview into 2 different SurfaceView controls at the same time? I have seen some apps that show effects into different previews in real-time, how do they achieve that? I read about the TextureView, is this the view to use? where can I find examples of multiple simultaneous camera previews?

Thanks

ligi
  • 39,001
  • 44
  • 144
  • 244
PerracoLabs
  • 16,449
  • 15
  • 74
  • 127
  • See a very similar [question](http://stackoverflow.com/questions/26336495/how-to-show-2-camera-preview-side-by-sidefor-cardboard-apps) which got an [answer](http://stackoverflow.com/a/28661929/192373) with [code on GitHub](https://github.com/Sveder/CardboardPassthrough). – Alex Cohn Mar 22 '15 at 15:57

2 Answers2

4

Well, as they answered in this question, I downloaded the grafika project and revised the "texture from camera" example.

In the RenderThread is a Sprite2d atribute called mRect. I just make another instance called mRect2, and configuired it with the same parameters that mRect has, except the rotation, I put it to the double:

mRect.setRotation(rotAngle); mRect2.setRotation(rotAngle*2);

This is the result

There is still a lot of code to understand, but it works and seems a very promising path to continue by.

Community
  • 1
  • 1
  • your code is made really helpful for me...also i want a more camera preview into single activity. i implement as you said in your above answer.but i need 1 help. in grafika project i see the Texture Preview shown in Rotate mode. But i need that in Origional camera mode.[Means 90 degree]. i already vote up your answer Please help me Bro. – Sagar Aghara Jan 09 '17 at 11:07
  • also....one problem is our face [means view] is rotate whenever my device rotate....how can i stop this issue. – Sagar Aghara Jan 10 '17 at 04:32
0

I don't think that it is possible to independently open 2 camera previews at the same time, as the camera is treated as a shared resource. However, it will be possible to draw to multiple SurfaceViews which is what the apps you describe do.

Dororo
  • 3,420
  • 2
  • 30
  • 46
  • This is what I am trying to achieve, to draw the camera preview into multiple surfaceviews, at the same time, so in both appears the exact same image in preview mode. But no luck trying to find an example – PerracoLabs Jun 20 '13 at 21:32
  • 1
    You want to use `setPreviewCallbackWithBuffer` or `setPreviewCallback` and then in your callback `public void onPreviewFrame(byte[] buffer, Camera camera)` you can pass the buffer to multiple `SurfaceViews` for rendering. – Dororo Jun 20 '13 at 21:41
  • @Dororo Can you elaborate on how to do this? How do you pass the buffer to the SurfaceViews? – David Doria Oct 18 '13 at 14:57
  • Hey @Dororo...i am developing an CustomCaemra App. i had same Problem.i also want multiple camera Preview into single Activity [Like in GridView].Please help me How can i achive this..i already asked question but nobody gave me answer....Here is my Question Link.......http://stackoverflow.com/questions/41392791/how-to-apply-custom-filters-in-a-camera-surfaceview-preview – Sagar Aghara Jan 28 '17 at 11:34
  • i googled it and tried more tutorial's,libraries [grafica too].but i did not achive this type of Preview [Multiple Cmaera Preview]. i found more problem's same as my problem in Stackoverflow.but same as my Question no one gave answer's.Please see this Link i want this type of View......http://i.stack.imgur.com/WYHuj.jpg – Sagar Aghara Jan 28 '17 at 11:36
  • Please @Dororo.....Please,Please help me if you know .when You will be free..God Bless You...Thanks – Sagar Aghara Jan 28 '17 at 11:37