This is driving me crazy. I'm writing a simple sketch to save RGB values to an xml file. I am using the proxml library. I have searched the forums and found several posts but none of them seem to have any code that I can use as a template. I have looked at the proxml site and it's not clear to me how to save to a web server. The file saves in my Data folder perfectly but as an applet nothing happens.
I have my folder permissions set to 777 and I have emptied the java cache. Not sure what I'm doing wrong. As usual, I'm sure it's something really silly.
Maybe I'm formatting the URL incorrectly?
Here is my code:
import proxml.*;
PImage img;
PFont f;
void setup() {
//set these to the size of the image
size(500,650);
f = loadFont("ArialMT-12.vlw");
textFont(f,12);
//this is the name of your image file saved in the data folder in your
//processing folder see processing.org for help
img = loadImage("RGBColormap.jpg");
background(255);
image(img,0,0);
img.loadPixels();
}
void draw() {
fill(0);
text("Click Anywhere In The Color Image Above",150,530);
if (mousePressed) {
mousePress();
}
}
void mousePress() {
float r = (red(img.pixels[mouseX+mouseY*img.width]));
float g = (green(img.pixels[mouseX+mouseY*img.width]));
float b = (blue(img.pixels[mouseX+mouseY*img.width]));
stroke(0);
fill (r,g,b);
rect (0,550,500,80);
fill(0);
text("This Is Your Color",200,595);
// create the root element be specific where the class is
proxml.XMLElement file = new proxml.XMLElement("root");
// create the color element
proxml.XMLElement col = new proxml.XMLElement("color");
// add some attributes to it.
col.addAttribute("r",(r));
col.addAttribute("g",(g));
col.addAttribute("b",(b));
// make the color element a child of the root element
file.addChild(col);
// create an XMLInOut object to format the elements
I am trying to compare two consecutive values in order to figure out if there has been in a change in the two.
Specifically, I am using blob detection to count blobs. I only want to act on the count if there has been a change in the count. I am using key press as the action so I don't want hundreds of key presses, just one when the blob count changes.
I'm assuming that I need an array and a way to compare each consecutive reading but I'm not sure how to plug the count into the array.
Does anyone have a method they could suggest? I've searched but have not found a lot. Maybe I'm searching for the wrong things?
I'm new to Processing and I have been struggling with this for several days. I want to create a program that reads a pixel color from my display and then does something according to what color(pixel) is returned. I have tried many iterations of this, seemingly, simple program and I cannot make it work. Sometimes it compiles without error and does not work and sometimes it throws errors. I was able to easily get keyPress and keyRelease (also part of Robot class) to work but this command is killing me.
My thought process is that this command (getPixelColor) returns a color so the information should be in the form of an RGB value, correct? So, I assumed I needed to create an int array to handle this color information. However, when I try to assign an int to the color value returned by the command (getPixelColor) I get an error - cannot assign a color to an int.
int [] pixelColor = new int [3];
For example, pixelColor = PixelBot.getPixelColor(100,100), throws an error.
I have also tried using this method:
color (int p){
int r =(int)red(p);
int g =(int)green(p);
int b =(int)blue(p);
println("r."+r+"g."+g+"b."+b);
return color(r,g,b);
}
The second portion of my code uses if and else if statements to use the returned color information.
I would post the entire code but it's very broken. I am just looking for the correct methodology to follow in order to use this command: getPixelColor. If I know the right path I can figure it out myself. At the moment I am on a very wild goose chase and it's driving me crazy.
Any help or suggestions would be greatly appreciated. Sorry if this question is ridiculous. I'm very new at this. : )
This is hard to word properly. I would like to monitor a specific section of a digital display to note whether the pixels change colors. In effect, if the pixels are red, Processing returns this info and does something. If the pixels are green, Processing does something else, etc. So far, I know that Processing can parse data as it is loaded into a sketch but I would like for it to just "oversee" what is being displayed onto the screen. Is this possible? Maybe the sketch could mirror that section of display and then parse from there, so all of the data does not have to be loaded?
I feel like my description is terrible but if anyone has any info that would be great.
I have recently been trying to get UDK to "talk" to Processing in order to cause events to occur in the game(UT). I have been able to make Arduino communicate by using AACKeys software (it's a hack, I know), but I have not been able to figure out a way to communicate the other way (UDK -> Processing -> Arduino). This seems like it would be somewhat doable but I can't figure out the best way to make it happen. Any ideas?
I know a little bit of UnrealScript, but not a ton.
I have used Unity to do the same exact thing but I prefer UDK for the project I am working on now.
Does anyone have any experience with this sort of thing?