ketai | Ketai sensor library | Camera library
kandi X-RAY | ketai Summary
kandi X-RAY | ketai Summary
The ketai library for Processing Android source.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of ketai
ketai Key Features
ketai Examples and Code Snippets
Community Discussions
Trending Discussions on ketai
QUESTION
I am making an android app, wherein there is a simple camera UI along with a filter list to manipulate pictures clicked by the camera. I am using the Processing library (https://processing.org/) in Java along with the Ketai library (http://ketai.org/) in the processing IDE.
Following is how my program primarily runs:
--- I have a camera object and an empty image object. The image object has the same resolution as that of the camera.
--- Reading from the camera also returns an image object. Lets call the image returned by the camera as cameraImage and the empty image as dummyImage.
--- At each frame, I read from the camera using the pixel array of the cameraImage, I copy each pixel individually to the dummyImage at the respective coordinate position.
--- It is at this point of copying from the cameraImage to the dummyImage that I manipulate the pixels according to the options selected by the user.
--- I take the red, green and blue values of each pixel while copying it using bit shifting (to gain maximum efficiency) and then manipulate it.
--- After copying to the dummyImage is done, I display the dummyImage to the screen as a normal Image.
Now the thing is the when I display the cameraImage directly, I am easily able to get around 50 to 60 fps. But when I display the dummyImage after copying, I get approximately 1.5 fps.
The following code demonstrates how I am copying from cameraImage to dummyImage. It doesn't have any filters but would take as much time as with any filters.
...ANSWER
Answered 2020-Oct-24 at 22:25A few possible optimisations:
Replace
= color(r, g, b)
with= 0xff000000 | ((int) (r) << 16 | (int) (g) << 8 | (int) (b))
.You can't rasterize graphics in Processing in parallel but you can read/write to the
pixels[]
array in parallel (thenupdatePixels()
afterwards), so usethread()
to split pixel iteration over multiple CPU threads.Rather than calling
image(dummyImage)
, which involves a second pass over the pixels to copy them into thePApplet
, write into the PApplet directly within the loop (remove all references todummyImage
and usepixels[index] = ...
instead).As pixel-by-pixel computation is embarrassingly parallel, you could even consider writing a glsl shader (there's lots of Processing examples of this) or use Aparapi, which converts Java code to GPU-ready OpenCL (I've had success using this with Processing).
QUESTION
Hello I am using processing 3.0 with ketai library and I am trying to save an image but for some reason it does not work. Each button has its own listener in order to identify if it was pressed. The camera opens normally but when Save button is pressed nothing happens. an error message is displayed in the processing console. The message that is displayed in the console is:
failed to create directory to save photo: /storage/emulated/0/Pictures/testing6
testing6 is the .pde file that I am working on. Also, I am testing the application on a android emulator and not on an android device. I want to be able to save an image and create a folder that contains images. For instance, one folder will have animal photos, other folder will have landscape, etc. Create any number of folders and photos. I saw the documentation on Ketai library and on GitHub but I could not find a solution.
...ANSWER
Answered 2018-Dec-09 at 21:09Newer versions of Android ask the user for permission to access sensitive resources at runtime, not during installation. So you need to prompt the user to give your app permission to write to the file system, before you invoke KetaiCamera::savePhoto()
.
From the Processing for Android documentation:
QUESTION
Doing an example from Sylvain Ratabouil Android NDK (2nd Edition) that gets image previews from the camera and processes it natively, converting from YUV to RGB and applying a color filter to it.
The code is very simple and the issue occurs in the filter that is passed to this function:
...ANSWER
Answered 2017-Aug-08 at 21:31Your decode()
function is hardcoded for NV21 video format, but the camera could be set for YV12. This could account for color 'swap'. Note that for some resolutions, YV12 can have line padding (NV21 is guaranteed to be 'fully packed').
PS it may be significantly faster to generate the three planes in one run and it is not clear if integer operations are really faster than float on the modern CPUs.
If the resolution is high, and the processing time is important, consider using renderscript.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ketai
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page