8000 摄像头预览时调用findQRCodeBounding导致OOM · Issue #25 · imageprocessor/cv4j · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

摄像头预览时调用findQRCodeBounding导致OOM #25

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

Open
xiaojigugu opened this issue Jun 10, 2020 · 1 comment
Open

摄像头预览时调用findQRCodeBounding导致OOM #25

xiaojigugu opened this issue Jun 10, 2020 · 1 comment

Comments

@xiaojigugu
Copy link
        public void onPreviewFrame(final byte[] data, final int width, final int height) {
            super.onPreviewFrame(data, width, height);
            threadPoolManager.addTask(new Runnable() {
                @Override
                public void run() {
                    findQRCode(data, width, height);
                }
            });
        }

private void findQRCode(byte[] data, int width, int height) {
    YuvImage img = new YuvImage(data, ImageFormat.NV21, width, height, null);
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    img.compressToJpeg(new android.graphics.Rect(0, 0, width, height), 100, stream);
    Bitmap bitmap = BitmapFactory.decodeByteArray(stream.toByteArray(), 0, stream.size());

    CV4JImage cv4JImage = new CV4JImage(bitmap);
    QRCodeScanner qrCodeScanner = new QRCodeScanner();
   //这一行会导致OOM
    Rect qrCodeBounding = qrCodeScanner.findQRCodeBounding(cv4JImage.getProcessor(), width, height);
    bitmap.recycle();
    Log.i(getClass().getSimpleName(), "findQRCode: width" + qrCodeBounding.width + ",height:" + qrCodeBounding.height);
}

请问还有什么别的方法能找寻二维码区域吗

@cyzaoj
Copy link
cyzaoj commented Jun 24, 2021

+1

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
0