title: Drawing on camera frame continuously by using camera2 api?
body: <p>I am trying to draw on the surface view using the Camera2 API sample code from Google. But for some reason, the drawing disappears after the camera preview starts. I am really confused as to why this is happening.</p>
  
  <pre><code>private void drawonSurfaceView(){
          Paint paint = new Paint();
          SurfaceHolder surfaceHolder= mOverlay.getHolder();
          if(surfaceHolder.getSurface().isValid()) {
              Canvas canvas = surfaceHolder.lockCanvas();
              //... actual drawing on canvas
  
              paint.setStyle(Paint.Style.FILL);
  
              int x = canvas.getWidth();
              int y = canvas.getHeight();
  
  
              paint.setColor(Color.GREEN);
              paint.setStyle(Paint.Style.STROKE);
              Rect rect = new Rect(50, 50, x-300, y-300);
              canvas.drawRect(rect, paint );
  
              surfaceHolder.unlockCanvasAndPost(canvas);
          }
  
  
      }
  </code></pre>
  
  <p>I Have placed the code inside the setUpCameraOutputs() method.</p>