Coder Social home page Coder Social logo

android-barcode-decode-video's Introduction

Real-time barcode scanning from Android camera stream

How to build a simple Android barcode scanning app with Android camera API and Dynamsoft Barcode Reader.

Learn more about Dynamsoft Barcode Reader SDK >

What You Should Know

Resources

Barcode scanning from Android camera stream

Call startDecodingFrame() to initialize the environment and call appendFrame() repeatedly to add the preview images.

cameraView.addFrameProcessor(new FrameProcessor() {
            @SuppressLint("NewApi")
            @Override
            public void process(@NonNull final Frame frame) {
                try {
                    if (isDetected && isCameraOpen) {
                        YuvImage yuvImage = new YuvImage(frame.getData(), ImageFormat.NV21,
                                frame.getSize().getWidth(), frame.getSize().getHeight(), null);
                        if (width == 0) {
                            width = yuvImage.getWidth();
                            height = yuvImage.getHeight();
                            stride = yuvImage.getStrides()[0];
                            reader.setErrorCallback(errorCallback, null);
                            reader.setTextResultCallback(textResultCallback, null);
                            reader.setIntermediateResultCallback(intermediateResultCallback, null);
                            // start a new thread to decode barcodes
                            reader.startFrameDecoding(10, 10, width, height, stride, EnumImagePixelFormat.IPF_NV21, "");
                        } else {
                            PublicRuntimeSettings s  = reader.getRuntimeSettings();
                            // add new image frames for barcode scanning
                            int frameid = reader.appendFrame(yuvImage.getYuvData());
                            Log.i("FrameId", frameid + "");
                        }
                        if (bUpateDrawBox) {
                            bUpateDrawBox = false;
                            Message message = handler.obtainMessage();
                            Rect imageRect = new Rect(0, 0, width, height);
                            message.obj = imageRect;
                            message.what = 0x001;
                            handler.sendMessage(message);
                        }
                        isDetected = true;
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

android-barcode-decode-video's People

Contributors

lybiu avatar rachyj avatar yushulx avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

lybiu rachyj

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.