Giter VIP home page Giter VIP logo

Comments (7)

mhsmith avatar mhsmith commented on September 16, 2024

I gather from the ftrobopy examples that getCameraFrame returns a list of integers ranging from 0 to 255. Unfortunately, Java represents bytes using the range -128 to 127 instead.

You can work around this by replacing frame in the decodeByteArray call with:

[(x if x < 128 else x - 256) for x in frame]

Chaquopy should really be able to deal with this when converting a bytes or bytearray object to a Java byte[], so I'll make sure that's fixed in a future version. Then you'll be able to just do bytes(frame), which should have much better performance.

from chaquopy.

robbi-blechdose avatar robbi-blechdose commented on September 16, 2024

That fixed the error! Thanks so much for the quick answer!
By the way, I am now getting a black screen once camera data comes in. Any fix for that (I presume it has to do with my while true loop)?

from chaquopy.

mhsmith avatar mhsmith commented on September 16, 2024

Unfortunately I'm not familiar with either ftrobopy or BitmapFactory. But perhaps you could try narrowing the problem down by trying to load and display a known image from a file?

from chaquopy.

robbi-blechdose avatar robbi-blechdose commented on September 16, 2024

The problem is the loop IMO, is there a known way to do a "main loop" with chaquopy?
EDIT: Confirmed, it works with a normal image outside the loop, if I insert the "while true", I also get a black screen.

from chaquopy.

mhsmith avatar mhsmith commented on September 16, 2024

Oh right, I see what you mean. This issue isn't specific to Chaquopy, you've just got to fit into Android's event-driven model, and not block the main thread.

Try using Handler.postDelayed to schedule a callback. There's an example of how to create a Runnable in the Python API documentation. Then every time it calls you back, you can call it again to schedule the next update.

from chaquopy.

robbi-blechdose avatar robbi-blechdose commented on September 16, 2024

Works like a charm! Thanks!

from chaquopy.

mhsmith avatar mhsmith commented on September 16, 2024

Continued in #41.

from chaquopy.

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.