4

I want to show filtered camera preview in my application.

I'm using Camera.setPreviewCallback() for this. I managed to process callback data and show filtered image in OpenGL view but I have no idea how to hide original camera preview and still receive preview callbacks. Making surface view "gone" or "invisible" doesn't work, making it small enough (10x10) to hide behind GUI doesn't work either. It just stops sending callbacks with preview data.

Can you share some workaround on this? I'm testing using Galaxy S2.

Thank you in advance.

menjaraz
  • 7,551
  • 4
  • 41
  • 81
Dmitry Ryadnenko
  • 22,222
  • 4
  • 42
  • 56
  • Hey...@Dmitry Ryadnenko...Please help me if you know....i am developing an CustomCaemra App. i had same Problem.i 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 25 '17 at 10:38
  • i want this type of Preview.....Please see.and Help me...http://i.stack.imgur.com/WYHuj.jpg – Sagar Aghara Jan 25 '17 at 10:40

2 Answers2

2

A solution is to even though set the Preview Size to be as the actual screen, in the onMeasure of the Preview SurfaceView make it smaller, that works for me:

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{  
   this.setMeasuredDimension(2, 2);  
}
PerracoLabs
  • 16,449
  • 15
  • 74
  • 127
  • 2
    This doesn't work on some devices because some devices require the preview size to have certain constraints. e.g. Nexus S requires preview width to be a multiple of 8 and minimum height 16. – bleater May 30 '12 at 02:10
  • Hey...@PerracoLabs...Please help me if you know....i am developing an CustomCaemra App. i had same Problem.i 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 25 '17 at 10:43
  • i want this type of Preview.....Please see.and Help me...http://i.stack.imgur.com/WYHuj.jpg – Sagar Aghara Jan 25 '17 at 10:44
1

Create a simple View with a black background color. Position the view at the same position as the camera's SurfaceView. The camera's preview will be effectively hidden.

Ivan
  • 134
  • 8