Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

怎样使用摄像头拍照功能 #18

Closed
790396054 opened this issue Dec 26, 2017 · 5 comments
Closed

怎样使用摄像头拍照功能 #18

790396054 opened this issue Dec 26, 2017 · 5 comments

Comments

@790396054
Copy link

就是如何用它进行拍照操作。

@kongqw
Copy link
Owner

kongqw commented Dec 26, 2017

@790396054 抓取一帧,将Mat转成Bitmap可否满足你的需求?

@790396054
Copy link
Author

1.如何抓取一帧?
2.抓取一帧后可以保证摄像头预览画面还是实时预览么?

@790396054
Copy link
Author

mCamera.takePicture(null, null, new Camera.PictureCallback() {
@OverRide
public void onPictureTaken(byte[] data, Camera camera) {
if (callBack != null) {
callBack.hasTakePicture(data);
}
}
});

我用 takePicture 方法,抓取照片后,摄像头不预览了,调用 mCamera.startPreview(); 还是不能预览

@kongqw
Copy link
Owner

kongqw commented Dec 26, 2017

    @Override
    public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
        // 子线程(非UI线程)
        mRgba = inputFrame.rgba();

        // TODO 抓取 mRgba  转 Bitmap

        return mRgba;
    }

Mat 转 Bitmap

Bitmap bitmap = Bitmap.createBitmap(mat.width(), mat.height(), Bitmap.Config.ARGB_8888);
Utils.matToBitmap(mat, bitmap);

@kongqw kongqw closed this as completed Dec 26, 2017
@790396054
Copy link
Author

解决了,十分感谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants