Comments (7)
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.
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.
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.
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.
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.
Works like a charm! Thanks!
from chaquopy.
Continued in #41.
from chaquopy.
Related Issues (20)
- FCWT wheel build issue HOT 2
- torch / pytorch for Python 3.9 or later HOT 5
- I want to use chaquopy to make an aar package to run python scripts. But it seems that the imported third-party library cannot run. This aar package can only run ordinary python code HOT 2
- Could not find matching constructors for com.androidmgradle.internal.api.Default.... HOT 3
- Install package at app runtime HOT 2
- Module not found when running Python code with runpy.run_path HOT 2
- An exception occurred applying plugin request [id: 'com.chaquo.python'] HOT 1
- How can I cache python library with Chaquopy and Github Actions? HOT 4
- OSError: Can't get source for <function swish_jit at 0x72d59118b0>. TorchScript requires source access in order to carry out compilation, make sure original .py files are available. HOT 2
- Could not resolve all artifacts for configuration ':classpath'. HOT 1
- Add support for Android Gradle plugin 8.6 HOT 1
- Remove support for buildPython version 3.8
- will u please to add duckdb,netcdf4,xarray packages? HOT 1
- Install of openai is failing with some issues related to jiter HOT 4
- Unable to install opencv-contrib-python HOT 1
- TomlError when building with pybase64 HOT 1
- jpype HOT 4
- Hope to support the following libraries HOT 7
- Compile Err when installing prophet HOT 2
- Failed to install pyzstd HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chaquopy.