Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void takePicture() {
- Log.i(CaptureActivity.TAG, "MyCameraView, takePicture()");
- // Postview and jpeg are sent in the same buffers if the queue is not empty when performing a capture.
- // Clear up buffers to avoid mCamera.takePicture to be stuck because of a memory issue
- mCamera.setPreviewCallback(null);
- // PictureTakenListener is implemented by the current class
- mCamera.takePicture(null, null, this);
- }
- @Override
- public void onPictureTaken(byte[] bytes, Camera camera) {
- // The camera preview was automatically stopped. Start it again.
- mCamera.startPreview();
- mCamera.setPreviewCallback(this);
- Mat mat = Imgcodecs.imdecode(new MatOfByte(bytes), Imgcodecs.CV_LOAD_IMAGE_UNCHANGED);
- Log.d(CaptureActivity.TAG, mat.toString());
- //an interface method to be implemented by CaptureActivity
- if (mPictureTakenListener != null)
- mPictureTakenListener.receivePicture(mat);
- }
- @Override
- public void receivePicture(Mat mat) {
- File path = new File(Environment.getExternalStorageDirectory() + "/myCamera/");
- path.mkdirs();
- File file = new File(path, System.currentTimeMillis() + "recieved" + ".png");
- String filename = file.toString();
- Log.d(CaptureActivity.TAG, "was imwrite a success? "
- + Imgcodecs.imwrite(filename, mat));
- }
- public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
- Log.d(TAG, "frame info " + frame.toString());
- return frame;
- }
Add Comment
Please, Sign In to add comment