如何在Vigo Video Hypstar等摄像机上实时预览录像机

Arj*_*ini 15 camera android ffmpeg opengl-es chromakey

我想用Gif或图像像Vigo更改Surface预览底部叠加层

像这样

在此输入图像描述

请告诉我任何sdk或我用于此过滤器的内容

我可以使用此更改顶视图上的叠加层

这有帮助

 PictureCallback cameraPictureCallbackJpeg = new PictureCallback() 
  {  
    @Override
    public void onPictureTaken(byte[] data, Camera camera) 
    {
      // TODO Auto-generated method stub   
      Bitmap cameraBitmap = BitmapFactory.decodeByteArray
                                                                  (data, 0, data.length);

   int   wid = cameraBitmap.getWidth();
     int  hgt = cameraBitmap.getHeight();

    //  Toast.makeText(getApplicationContext(), wid+""+hgt, Toast.LENGTH_SHORT).show();
      Bitmap newImage = Bitmap.createBitmap
                                        (wid, hgt, Bitmap.Config.ARGB_8888);

      Canvas canvas = new Canvas(newImage);

      canvas.drawBitmap(cameraBitmap, 0f, 0f, null);

     Drawable drawable = getResources().getDrawable
                                                          (R.drawable.mark3);
      drawable.setBounds(20, 30, drawable.getIntrinsicWidth()+20, drawable.getIntrinsicHeight()+30);
    drawable.draw(canvas);



      File storagePath = new File(Environment.
                    getExternalStorageDirectory() + "/PhotoAR/"); 
      storagePath.mkdirs(); 

      File myImage = new File(storagePath,
                    Long.toString(System.currentTimeMillis()) + ".jpg");

      try
      {
        FileOutputStream out = new FileOutputStream(myImage);
        newImage.compress(Bitmap.CompressFormat.JPEG, 80, out);


        out.flush();
        out.close();
      }
      catch(FileNotFoundException e)
      {
        Log.d("In Saving File", e + "");    
      }
      catch(IOException e)
      {
        Log.d("In Saving File", e + "");
      }

      camera.startPreview();



      newImage.recycle();
      newImage = null;

      Intent intent = new Intent();
      intent.setAction(Intent.ACTION_VIEW);

      intent.setDataAndType(Uri.parse("file://" + myImage.getAbsolutePath()), "image/*");
      startActivity(intent);

    }
  };
Run Code Online (Sandbox Code Playgroud)

输出

在此输入图像描述

在此输入图像描述

Udi*_*jee 5

使用GLSurfaceView.基本思想是在GLSurfaceView中预览相机并绘制OpenGL渲染.
常见的方法是继承GLSurfaceView并实现GLSurfaceView.Renderer.渲染任务通过实现接口来执行.

public class CameraRenderer extends GLSurfaceView implements GLSurfaceView.Renderer, SurfaceTexture.OnFrameAvailableListener { 
    @Override
    public synchronized void onSurfaceCreated(GL10 gl, EGLConfig config) {
        ...
        //compile shader here
    }

    @Override
    public synchronized void onSurfaceChanged(GL10 gl, int width, int height) {
        ...
        //open camera and start preview here
    }

    @Override
    public synchronized void onDrawFrame(GL10 gl) {
        ...
        //draw frame as required
    }

}
Run Code Online (Sandbox Code Playgroud)

看看这个grafika项目,以获得一个更好的想法,这个项目接近你想要做的事情.


小智 2

为此,您需要使用外部库。

用于在相机中使用滤镜以及此类虚拟效果。

试试这个库:

1)相机滤镜

2)这是基本过滤器。

您可以在这里了解如何实现这个基本过滤器。

3)效果工厂

这是类似 Instagram 的效果。

3)脸部地标

这是类似 Snapchat 的效果,但为此,您需要从该 api 页面购买一个密钥才能使用它。