Android draw on camera preview

后端 未结 4 1092
情歌与酒
情歌与酒 2020-12-07 21:50

I\'m making a virtual reality application where the camera should detect faces, locate them and show their location on the camera preview.

I know of 3 ways to do it,

4条回答
  •  一向
    一向 (楼主)
    2020-12-07 21:57

    I could said,

    It's not about a Thread.

    It not because of this line that make error either.

    canvas.drawPoint(leftEye.x, leftEye.y, red);
    

    It because of the canvas still using and can't lock it

    If you carefully check, you will see this canvas you get is == null

    canvas = canvasHolder.lockCanvas();
        if (canvas == null)  Log.i("Error", "Canvas == null!"); 
    

    You might have question then where is it already use?

    It already use to display to show what's going on to you! That is

    camera.setPreviewDisplay(previewHolder);
    

    So, I suggest, If you want to draw Point over your eye, you might need to have another SurfaceView / SurfaceHolder over you SurfaceView for preview camera :]

提交回复
热议问题