| | |
| | | |
| | | @Override |
| | | public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width, int height) { |
| | | // System.out.println("PreviewBase.onSurfaceTextureAvailable"); |
| | | // System1.out.println("PreviewBase.onSurfaceTextureAvailable"); |
| | | mFinished = false; |
| | | try { |
| | | mCamera = Camera.open(rgb_gray_camera); |
| | | Camera.Parameters parameters = mCamera.getParameters(); |
| | | parameters.setPreviewSize(640, 480); |
| | | if (null == mCamera) { |
| | | System.out.println("Preview.onSurfaceTextureAvailable no front facing camera "); |
| | | System1.out.println("Preview.onSurfaceTextureAvailable no front facing camera "); |
| | | } |
| | | /* |
| | | This doesn't work |
| | |
| | | /* Tell the camera to write onto our textureView mTextureView */ |
| | | mCamera.setPreviewTexture(surfaceTexture); |
| | | mCamera.setPreviewCallback((data, camera) -> { |
| | | // System.out.println("PreviewBase.onSurfaceTextureAvailable setPreviewCallback"); |
| | | // System1.out.println("PreviewBase.onSurfaceTextureAvailable setPreviewCallback"); |
| | | lastTimeOnPreviewFrame = System.currentTimeMillis(); |
| | | if (Constants.indoorOutdoorInOne) { |
| | | if (secondDisplayRunnable.isNotRunning()) { |
| | |
| | | try { |
| | | if (rgb_gray_camera == Constants.RGB_CAMERA) { |
| | | OutdoorGuestSocketServer.setCameraData(data); |
| | | // System.out.println("PreviewBase.onSurfaceTextureAvailable 0"); |
| | | // System1.out.println("PreviewBase.onSurfaceTextureAvailable 0"); |
| | | if (BaseApplication.getApplication().activity != null |
| | | && BaseApplication.getApplication().activity.shouldDetectFace()) { |
| | | // System.out.println("PreviewBase.onSurfaceTextureAvailable 1"); |
| | | // System1.out.println("PreviewBase.onSurfaceTextureAvailable 1"); |
| | | if (!((Preview) PreviewBase.this).rgbThread.isRunning) { |
| | | if (Constants.USE_GRAY_CAMERA) { |
| | | byte[] grayBgrData = ((Preview) PreviewBase.this).getMostMatchGrayBgrData(); |
| | | // System.out.println("PreviewBase.onSurfaceTextureAvailable 2 grayBgrData="+grayBgrData); |
| | | // System1.out.println("PreviewBase.onSurfaceTextureAvailable 2 grayBgrData="+grayBgrData); |
| | | if (grayBgrData != null) { |
| | | try { |
| | | ((Preview) PreviewBase.this).grayThread.onPreviewFrame(grayBgrData, camera, Constants.GRAY_CAMERA); |
| | |
| | | } |
| | | ((Preview) PreviewBase.this).rgbThread.isRunning = true; |
| | | ((Preview) PreviewBase.this).rgbThread.onPreviewFrame(data, camera, Constants.RGB_CAMERA); |
| | | // System.out.println("PreviewBase.onSurfaceTextureAvailable rgbExecutorService.execute(((Preview) PreviewBase.this).rgbThread)"); |
| | | // System1.out.println("PreviewBase.onSurfaceTextureAvailable rgbExecutorService.execute(((Preview) PreviewBase.this).rgbThread)"); |
| | | rgbExecutorService.execute(((Preview) PreviewBase.this).rgbThread); |
| | | } |
| | | } |
| | |
| | | mCamera.startPreview(); |
| | | } catch (IOException ioe) { |
| | | Log.e("camera-reverse", ioe.getMessage()); |
| | | mCamera = null; |
| | | mFinished = true; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int width, int height) { |
| | | // System.out.println("PreviewBase.onSurfaceTextureSizeChanged"); |
| | | // System1.out.println("PreviewBase.onSurfaceTextureSizeChanged"); |
| | | Matrix matrix = new Matrix(); |
| | | matrix.setScale(-1, 1); |
| | | //move it back to in view otherwise it'll be off to the left. |
| | |
| | | mCamera.setPreviewTexture(surfaceTexture); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | mCamera = null; |
| | | mFinished = true; |
| | | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) { |
| | | // System.out.println("PreviewBase.onSurfaceTextureDestroyed"); |
| | | // System1.out.println("PreviewBase.onSurfaceTextureDestroyed"); |
| | | mFinished = true; |
| | | if (null != mCamera) { |
| | | mCamera.stopPreview(); |
| | | mCamera.release(); |
| | | mCamera = null; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public void onSurfaceTextureUpdated(SurfaceTexture surface) { |
| | | // System.out.println("PreviewBase.onSurfaceTextureUpdated"); |
| | | // System1.out.println("PreviewBase.onSurfaceTextureUpdated"); |
| | | } |
| | | } |