I'm wondering if its posible to use the OpenGL library of processing to capture the sreen and store the pixels in the java buffered image object. I only need to sreenshot of what's currently displayed on the sreen.
Till now i've been doing it with java robot class works fine but too slow. I'm trying to get it to like 30 sreenshots/s.
Any ideas on how and if it can be done? Maybe some code examples.
Hello,
I've written a simpe arduino program that listens to serial port and waits for data.
The data is a 9 digit number, each 3 digits are one of the RGB values to color the LED's acordingly.
When i upload the code to arduino and test it via serial monitor it works like a charm.
Now i'm trying to pass the data from a processing code instead of serial monitor.
And all i get is my led's flashing for a milisecond and nothing else.
Any ideas what i'm doing wrong here?
Arduino code
int analogPinR = 9; int analogPinG = 10; int analogPinB = 11; //the buffer int RGB[9]; //VALUES OF Red green and blue int R=0; int G=0; int B=0;
void setup() {
Serial.begin(9600); }
void loop(){ if(Serial.available()==9){ for(int i =0;i<9;i++){ RGB[i]=Serial.read() - '0'; } //get the data from the integer array R= RGB[0]*100+RGB[1]*10+RGB[2]; G= RGB[3]*100+RGB[4]*10+RGB[5]; B= RGB[6]*100+RGB[7]*10+RGB[8];
Hi,
I wrote a prgram that was suposed to take sreenshots and get the avrage RGB value of each shot on the fly.
The sreenshot taking is done in jave and the image loading and RGB calculations in processing.
The RGB calculation is not actualy implemented yet but i have two loops that go trugh the image and get the RGB colors.
I'm stuck at the image loading part.
I got my sreenshot taking set up so the images have names 1,2,3 and so on depending on the seqence they are taken
now the processing code takes the images on by one.
The code works for the first image. it runs perfectly and loads 1.jpg and gets the RGB values.
On the next loop it throws and exeption that 2.jpg is not there or something like that.
But looking at the folder i actualy see the 2.jpg there and i can open it and its fine realy..
Sine the program should be sequential running line after line i don't think i'm trying to load the image before i reated one.
But it seems to happen anyway.
Any ideas why and how to solve it ?
Thanks
code
PImage img; void setup() {
size(900, 500); int r=0; int g=0; int b=0; int height=700; int width=500;
//Trying to take 5 sreenshots and calculate the RGB. (5 for testing, it will be a while(true) later) for(int k =1; k< 5; k++) { try { //the code that takes the sreenshot and puts it in the folder naming it k.jpg Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Rectangle screenRectangle = new Rectangle(screenSize); Robot robot = new Robot(); BufferedImage image = robot.createScreenCapture(screenRectangle); ImageIO.write(image, "jpg", new File("D:/Processing Projects/Img_workout/"+k+".jpg")); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); }
img = loadImage(k+".jpg"); img.loadPixels(); /*the part where the program throws an exception saying it can't read the sorce or the data is not valid. I presume that the image was sucesfuly loaded since the ode above was procesed */ //going trugh the image loaded (every 20 pixels otherwise it takes too much time) for (int y = 0; y < height; y=y+20) { for(int x = 0; x <width; x=x+20) {
//will later calculate the avrage RGB value of the image int col = img.pixels[y*width+x]; r = (col >> 16)&0xff; g = (col >> 8) &0xff; b = (col)&0xff; } } System.out.println("RED: "+r+" GREEN "+g+" BLUE "+b); System.out.println("done!"); } }
Hello,
Im new to processing and i'm liking it. I got my self an arduino and im trying to make a project (ambient light) on my own.
My arduino is alrady set up.
I'm having more of an idea problem and a tech one at the same time.
I wan't to make an apliation that would get the currently viewing image of my PC and calculate the avrage RGB value and send it to arduino. I want it to work when i play games, watch movies, or doing whatever.
I figured that procesing the whole image can't be done on the fly so i was thinking of taking sreenshots as fast as posible but save them in a very low resolution and quality (i don't need the avrage RGB value to be that exact) so it dosen't eat all the CPU.
Any bright ideas how to get this working and not burning all the CPU's power just to get the damn RGB?
Now the second thing bugs me the most.
I was trying to get an example working, opening a simple jpg (just a blue sqare) and with 2 for loops going trugh every pixel and printing its value. I read that the img.get() function returns the RGB value of the pixel if provided the x and y cordinates of the pixel as parameters.
I've done this example but it just prints a bunch of negative numbers i can't make any sence of :(