Git Product home page Git Product logo

Comments (3)

saudet avatar saudet commented on June 5, 2024

Sure, we can do that, and you're not going to get any memory exceptions. What is the issue?

from sample-projects.

avinashyerrala avatar avinashyerrala commented on June 5, 2024

I am wondering if there is any api that I can use to compress byte array in onPreviewFramecall back.
Right now I am compressing the Image using the below code.

ByteArrayOutputStream jpegByteArrayOutputStream = new ByteArrayOutputStream();
new YuvImage(bytes, 17, 1280, 720, null).compressToJpeg(new Rect(0, 0, 1280, 720), 10, jpegByteArrayOutputStream);

            Bitmap original = BitmapFactory.decodeByteArray(jpegByteArrayOutputStream.toByteArray(), 0, jpegByteArrayOutputStream.size());
            Bitmap resized = Bitmap.createScaledBitmap(original, 360, 240, true);

((ByteBuffer) yuvImage.image[0].position(0)).put(getNV21(imageWidth, imageHeight, resized));

As you can see the compression is taking time and I am wondering if there is any Api in the sdk which can compress the byte array from onPreviewFrame call back

from sample-projects.

saudet avatar saudet commented on June 5, 2024

So the issue is that it takes too much time to compress? Then you'll need to use hardware accelerators. We can usually access those through the Android API, as used in this sample, for example:
https://github.com/google/grafika/blob/master/app/src/main/java/com/android/grafika/ContinuousCaptureActivity.java
https://github.com/google/grafika/blob/master/app/src/main/java/com/android/grafika/CircularEncoder.java

from sample-projects.

Related Issues (20)

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.