Hello is there anyway how can i make animation faster? Its the only thing thats lagging on my phone when running the project... In function i have 3 states (walk,left,right).. Every state has different image..i think thats the only thing thats lagging..thank
Thread use for animation in android mode
Sound player compactible with processing 3.x
I was using apwidget music player but it doesnt work anymore..Any sugestions?
Lagging video: CameraGettingStarted example
Hi
I was working with an android sample code accessing the camera and I notice it is lagging. Is that normal? I am using 5.0.1. and processing 3.0.2 on a Galaxy VI (no emulator). I am hopping to quantify color segments in the screen but the videos seems to skip frames. It feels like is playing one frame every 2 or 3 seconds instead of the desirable 30 fps that you get running in java mode (using an external camera - and not this specific example). Is there anything I could do to have better video rates?
Cheers,
Kf
import android.os.Environment;
import ketai.camera.*;
KetaiCamera cam;
void settings() {
fullScreen();
}
void setup() {
orientation(LANDSCAPE);
imageMode(CENTER);
textSize(45);
}
void draw() {
if(cam != null && cam.isStarted()){
image(cam, width/2, height/2, width, height);
text("Number of cams \n" +
cam.getNumberOfCameras(), 0, 0, width/2-100, height/2);
cam.loadPixels();
int brightestX = 0; // X-coordinate of the brightest video pixel
int brightestY = 0; // Y-coordinate of the brightest video pixel
float brightestValue = 0; // Brightness of the brightest video pixel
int index = 0;
for (int y = 0; y < cam.height; y++) {
for (int x = 0; x < cam.width; x++) {
// Get the color stored in the pixel
int pixelValue = cam.pixels[index];
// Determine the brightness of the pixel
float pixelBrightness = brightness(pixelValue);
// If that value is brighter than any previous, then store the
// brightness of that pixel, as well as its (x,y) location
if (pixelBrightness > brightestValue) {
brightestValue = pixelBrightness;
brightestY = y;
brightestX = x;
}
index++;
}
}
// Draw a large, yellow circle at the brightest pixel
fill(255, 204, 0, 128);
ellipse(brightestX, brightestY, 200, 200);
}
else
{
background(128);
text("Waiting for camera....touch to activate", 100, height/2);
}
}
void onCameraPreviewEvent()
{
cam.read();
}
// start/stop camera preview by tapping the screen
void mousePressed()
{
//HACK: Instantiate camera once we are in the sketch itself
if(cam == null)
cam = new KetaiCamera(this, 640, 480, 24);
if (cam.isStarted())
{
cam.stop();
}
else
cam.start();
}
void keyPressed() {
if(cam == null)
return;
if (key == CODED) {
if (keyCode == MENU) {
if (cam.isFlashEnabled())
cam.disableFlash();
else
cam.enableFlash();
}
}
}
Exported Android app shows only grey screen
Hello everyone. In the past I've had success using the Processing Android mode on my Samsung Galaxy S3, but I'm having issues with my new LG G4. I'm using Windows 10 and Processing 3.0.2, my LG G4 is running Marshmallow. I can export sketches to my phone without issues, but as soon as I open the app on my phone, I'm faced with an empty grey screen. This happens with any Processing sketch (including the example ones). Does anyone know what the issue is? Thank you.
Face Recognition Library
Hello I Have found this library for processing: https://code.google.com/archive/p/p-eigenface/
With this sample : https://github.com/atduskgreg/Processing-Eigenfaces
for face recognition. Work fine for processing in java mode.
I will to use it in android mode Can please someone tell me if this is possible ? Thanks
Latest update (3.0) not working - Android Mode
After updating Android Mode in Processing for windows, running sketches on device does not work properly regardless of the sketch. On the phone, a white screen appears.
The console does not display any errors (the last thing it displays is "debug:"). The console also does not display anything in println in the sketch, whether it is in setup() or draw(). I tried deleting the Android Mode folders and reinstalling it to no avail. Suggestions?
Thank you in advance.
Any idea why recent Android Mode versions are slower than older ones?
I did a basic test to compare the versions for which PApplet extends Fragment against versions for which PApplet extends Activity. in terms of frame rates.
My test consisted of displaying lots of ellipses, with background() being called at each frame.
As seen in the above pictures, the older version (Release 0239) had as much as 72% more frames than the newer one (Release 0249) for a dot count of 500.
I used the following code:
ArrayList<Dot> dots = new ArrayList<Dot>();
@ Override
public void settings() {
//Call size/fullscreen from here
fullScreen(PConstants.P3D);
}
@ Override
public void setup() {
textSize(displayWidth/20);
}
@ Override
public void draw() {
background(0);
for (Dot dot : dots){
dot.move();
dot.display();
}
noStroke();
fill(150,0,0);
rect(0,0,displayWidth, displayHeight/10);
fill(255);
text("Release 0249: #dots: " + dots.size() + ", frameRate: " + (int)(frameRate), 0, displayHeight/20);
}
@ Override
public void mouseDragged(){
dots.add(new Dot());
}
@ Override
public void mousePressed(){
if (mouseY <= displayHeight/10){
dots.clear();
}else{
dots.add(new Dot(true));
}
}
class Dot {
float x, y;
float speedX, speedY;
int r = MainActivity.randInt(0 , 255);
int g = MainActivity.randInt(0 , 255);
int b = MainActivity.randInt(0 , 255);
Dot(){
x = mouseX;
y = mouseY;
speedX = (mouseX - pmouseX)/5;
speedY = (mouseY - pmouseY)/5;
}
Dot(boolean mousePressed){
x = mouseX;
y = mouseY;
}
void display(){
fill(r,g,b);
ellipse(x, y, displayWidth/30, displayWidth/30);
}
void move(){
accelerate();
checkBounds();
x += speedX;
y += speedY;
}
void checkBounds(){
if (x <= 0){
speedX *= -1;
x = 0;
}else if (x >= displayWidth){
speedX *= -1;
x = displayWidth;
}
if (y <= 0){
speedY *= -1;
y = 0;
}else if (y >= displayHeight){
speedY *= -1;
y = displayHeight;
}
}
void accelerate(){
speedX += MainActivity.randInt(-displayWidth/800, displayWidth/800);
speedY += MainActivity.randInt(-displayWidth/800, displayWidth/800);
}
}
Hopefully the code is formatted well...
Press or drag to create dots. Touch red area to reset. Read red area info to draw conclusions. The same code was used for both versions apart from sketchRenderer() instead of settings() - shouldn't make a difference.
The test above uses dots. But it would be great to test other stuff, like images, lines, pshapes etc. and under different cases (different renderers etc.) It would be great if you could emulate the test and confirm if you reach the same conclusion. Different releases are here:
https://github.com/processing/processing-android/releases
So, assuming my results are correct, my main question is: why are newer releases slower than older ones? Is this related to the fact that older ones extend Activity and newer ones extend Fragment?
Any thoughts appreciated.
Image width and height cannot be larger than 8064 with this graphics card
Hi,
I am getting the following error on some low-end to middle-range devices, such as Galaxy Core Prime, Galaxy Grand Prime and Galaxy Ace:
Image width and height cannot be larger than 8064 with this graphics card
Example stack trace:
processing.opengl.Texture.setSize (Texture.java:1159) processing.opengl.Texture.init (Texture.java:203) processing.opengl.Texture. (Texture.java:149) processing.opengl.FontTexture.addTexture (FontTexture.java:126) processing.opengl.FontTexture.initTexture (FontTexture.java:94) processing.opengl.FontTexture. (FontTexture.java:70) processing.opengl.PGraphicsOpenGL.textLineImpl (PGraphicsOpenGL.java:3281) processing.core.PGraphics.textLineAlignImpl (PGraphics.java:3514) processing.core.PGraphics.text (PGraphics.java:3355) processing.core.PApplet.text (PApplet.java:8631)
Looking into processing.opengl.Texture.setSize:
protected void setSize(int w, int h) {
width = w;
height = h;
if (PGraphicsOpenGL.npotTexSupported) {
glWidth = w;
glHeight = h;
} else {
glWidth = PGL.nextPowerOfTwo(w);
glHeight = PGL.nextPowerOfTwo(h);
}
if (glWidth > PGraphicsOpenGL.maxTextureSize ||
glHeight > PGraphicsOpenGL.maxTextureSize) {
glWidth = glHeight = 0;
throw new RuntimeException("Image width and height cannot be" +
" larger than " +
PGraphicsOpenGL.maxTextureSize +
" with this graphics card.");
}
// If non-power-of-two textures are not supported, and the specified width
// or height is non-power-of-two, then glWidth (glHeight) will be greater
// than w (h) because it is chosen to be the next power of two, and this
// quotient will give the appropriate maximum texture coordinate value given
// this situation.
maxTexcoordU = (float)width / glWidth;
maxTexcoordV = (float)height / glHeight;
}
it can be concluded that the error comes from the fact that either glWidth or glHeight is greater than PGraphicsOpenGL.maxTextureSize.
I was wondering if you know what glWidth, glHeight and PGraphicsOpenGL.maxTextureSize mean?
I would guess that PGraphicsOpenGL.maxTextureSize represents the maximum size of the width or height of a texture expressed in pixels. However, if that is the case, I do not understand why the error occurs, since I am definitely not loading any textures that have such a size (at least smaller by a factor of 10). But maybe PGraphicsOpenGL.maxTextureSize means something different?
Also interesting is the fact that PGraphicsOpenGL.maxTextureSize is equal to 8064 on the low-end devices that produce the bug but on better devices it is sometimes twice smaller (4096 on a Nexus 7, for instance), which is counterintuitive (firstly because better devices should be able to process bigger textures and secondly because the exception is thrown for devices whose maxTextureSize is bigger than maxTextureSize of the devices which dont throw the exception bearing in mind that the exception should be less likely to be thrown for devices with higher maxTextureSize, as determined by the if clause preceding the exception throw).
Incidentally, out of 5 devices I have tested (wide range of "quality"), all had a maxTextureSize of 4096. By the way, this number is a power of 2 (2^12), whereas 8064 is not a power of 2 (It happens to be 2^13-2^7, if that even matters).
Any thoughts appreciated!
How do i get sound to play on the phone
The code below works fine in java mode, but it doesn't work in Android mode. I just want a simple code that will play a mp3 file when clicked. I'm pretty sure the problem is in the import of Minim, I'm guessing it doesn't work for Android. If that is the case what do I need to use?
import ddf.minim.*;
AudioPlayer player;
Minim minim;
void setup(){minim = new Minim(this);}
void draw(){}
void mousePressed() {
player = minim.loadFile("sin1.mp3" );
player.play();
}
void stop()
{
player.close();
minim.stop();
super.stop();
}
Converting string to integer
Hi,
recently i stumbled into an odd problem. The fact is, that i'm not able to convert a number (string) (sent from an arduino like device) to android using Bluetooth. However the same procedure works great when send the same string to a PC using serial port.
So the code on my mbed side is just:
bt.printf("%i\r\n",Tobj1);
where Tobj1 is an integer number varying from 20000 to 100000 (it's a thermopile temp. sensor)
and on the android side I use:
String info2 = trim(info); Tobj = int(info2);
where info is the result from onBluetoothDataEvent
If i use text and try to put the value on screen I can see the results, so this is working fine, but if I want to put on the screen the Tobj variable, it's always 0. So the conversion Tobj = int(info2) does not work. I tried with several methods, using splitTokens, but as far I saw, the lenghth is verying so the app crashes immediatly.
Is there any other way to convert a string into an integer ?
Get Processing mode from inside code
Hi,
I'm wondering if there is a way to know from the code the mode that it's being currently used. I plan to maintain a code project that would be valid both for java and android modes. For that, I would like to have kind of compiler variables, for example: if (MODE_JAVA) { } else if (MODE_ANDROID) { }
Thank you very much.
Andres
Bluetooth Apps using Ketai White Screen
Everything was working great up until 2 days ago loading and using the bluetooth ketai cursors app. Now whenever i try to use my Windows 7 desktop they just load and start up a white screen. i've played around with bluetooth permissions and that isn't the problem. i cleared my temp app data folder. i reinstalled processing 3.02. they still run fine on my Asus tablet. I don't know what the problem is I need help. my tablet is too small to be productive on!
SuperCollider - Android - Processing
Hello guys,
I'm creating an application for an Android device to control SuperCollider via a Processing sketch: I'm doing it right now with the OscP5 library only but that's a little bit painful, I wanted to use the SuperCollider library but I can't change the default server to a custom server to fit my addresses.
Does anyone have any experience with this library and with this subject? The documentation is a little bit scarce with examples, it only uses the default server and the local machine.
Thank you very much, Stefano.
Modify onBluetoothDataEvent() function execution?
Hi!! Actually, I'm working with communication between a GY-80 IMU and Android APP via Bluetooth. The communication its correct, using 115200 bauds in the two bluetooth. The problem it's when I'm using the onBluetoothDataEvent() function to read data of the bluetooth, the string return me a lot of lines of the Arduino port serial .
import android.content.Intent; import android.os.Bundle; import ketai.net.bluetooth.*; import ketai.ui.*; import ketai.net.*;
void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
bt = new KetaiBluetooth(this);
}
void onActivityResult(int requestCode, int resultCode, Intent data) {
bt.onActivityResult(requestCode, resultCode, data); contador+=1;
}
void setup() {
bt.start(); bt.getPairedDeviceNames(); bt.connectToDeviceByName("HC-06");} //Function to take bytes data from bluetooth this function is executed 1 time every 0.1 seconds
void onBluetoothDataEvent(String who, byte[] data) {
//Transform data to string
info = new String(data); //}
Investigating, I saw that the function it's executed 10 times in 1 second, and this cause to accumulate data on the temporal string variable "info", because Arduino it's sending 100 times per secon (0.01 delay), and the function onBluetoothDataEvent() it's reading bytes variable at 1 time every 0,1 second (checked with a simple counter inside the function). Using other App of Android, I received 1:1 transmissions and data view, discarding to be a problem bluetooth mobile.
Any possibility to change the execution of the function onBluetoothDataEvent() to read at real time bluetooth data?
Thanks and sorry for my poor English!
Sending Pictures from multiple phones to tablet.
Hello, My name is Mathijs van Nieuwenhuijsen and I'm studying Industrial Design at the Technical University of Eindhoven. Me, and 2 other squad-members, are working on a social photo frame that will reconnect neglected elderly with their family. I really don't want to ask you guys to do all the work, but sure I could use some help with the technological part.
Here are the 3 steps I need to achieve in my process. Step 1 is my priority at the moment. This because it is the most complex part of coding (I guess). Step 2 is my least important priority. Mostly because I have the feeling I can figure this out myself. Step 3 is somewhere in the middle. It is really important and I could really use some help, but it seems like to much work to ask.
Details: - Both Tablet and Phone are in the same room. - LED strips are connected to arduino in the device. - It doesn't need to be perfect. Just as it works in a short presentation. (Things like photo storage and removing photos after a while to keep the device storage from getting full isn't an issue.)
Deadline is in 4 weeks (beginning june). I'm really looking forward to your reactions/feedback.
Can't delete entries in a Ketai SQLite database
Hello,
I'm working on some Android app in which I'm using a Ketai SQLite database. Basically that's working nicely but I'm stuck on a problem which is really driving me nuts: I cannot delete my entries using a DELETE query:
boolean success = db.query("DELETE FROM my_table");
if (success) {
println("done deleting");
}
... I'm getting the success message but in my app I can see nothing has been deleted.
What's wrong with my approach? Or is this maybe a bug? Any ideas?
Thanks, Stefan
Navigation bar cannot be locked in fullScreen mode in Android
I have updated to latest processing. I know i have to use the fullscreen option to avoid white screen problem. My code works properly in phones which has a hardware navigation bar like this
But when i run it in phones having virtual navigation bar like

The navigation bar hides automatically and pop up again when screen is touched. This makes the app to behave abnormally as the screen width and height is changed each time the navigation bar appears and disappears.
So pls help me to lock the navigation bar permanently in its place.
save images in specific folders(Android)
Good evening,
I made a program for downloading images, the problem is I can not save them in an orderly way. when I have an image is no problem with the order, but my idea is to deal with over 300 different images and I want a quick program.
I want to create folders with different categories.
However although I get to do what I want in java, I fail in android.
What I can do?
this code work:
PImage a;
void setup(){ a = loadImage("http://img110.xooimage.com/files/4/5/b/mini-robot-4a0c8b8.png");
if(a != null){a.loadPixels();
a.save("aadfg.png");
}}
void draw(){if(a != null){a.loadPixels();image(a,20,20);}}
but, this code don´t work:
PImage a;
void setup(){ a = loadImage("http://img110.xooimage.com/files/4/5/b/mini-robot-4a0c8b8.png");
if(a != null){a.loadPixels();
a.save("folder/aadfg.png");
}}
void draw(){if(a != null){a.loadPixels();image(a,20,20);}}
this is the difference:
a.save("aadfg.png");
**||**
a.save("folder/aadfg.png");
regards and thanks in advance.
Picture Server/Sender
For my design project I need to make an application that can make pictures and from there send them to a server (a map or something on a computer). From there it needs to be** sended to a tablet** that displays all the pictures that are stored in the server in a** slideshow**. I'm not even sure if this is possible in processing. I can really use some of your guys help.
Thanks!
APwidget is not working with processing 3.x?
Hi, The sketch crashes, when I run it on processing 3.0.1. It used to perfectly work with processing 2.2.1. So is it due to processing 3? Thanks in advance. Help/comment appreciated.
