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
Open
@xiaojigugu

Description

@xiaojigugu
        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);
}

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0