System.out.println("slots used = " + slotCounter);
System.out.println("red used = " + greenCounter);
System.out.println("green used = " + redCounter);
}
}
as you can see, it simply runs through a Pixel array taken from a picture and identifies, 42 pts of interest on the array. It then checks to see if those points are red or green. Being very new to programming it is probably unnecessarily long winded and convoluted but it served its purpose! I am now trying to convert that code to a language I know less of(javaCV) here is what I have so far
I am attempting to capture an image with my webcam at a regular interval of maybe five seconds. However I don't seem to have download the libraries with the rest of the stuff , I'm getting the error
java.lang.Error: Unresolved compilation problem:
The import processing.video cannot be resolved
any ideas why this might be happening and where can i download the Camera libraries/jars ??
I am working on a project on eclipse that requires separating out two colours Red and Green from a connect4 board. I was hoping to use those colours to determine what move has been made. I layed a grid over the board to isolate where the tiles will be , and used colorMode()s get() to return the colours found at those locations. However the PrintStatment is telling me that the numbers at those spots are 1) in the minus and 2) it sometimes returns the same value for red and green i.e -16777216. Below is the java code I am currently working on , ... if anyone has any ideas or impute, I would appreciate it
import processing.core.*;
public class ColourTrackingExample extends PApplet
{
//load an instance of image
PImage img = loadImage("BoardPieces.jpg");
//open an instance of setup
public void setup()
{
//set window size to be that of the pic
size(320, 240)
;
//draw a grid around it so we know the location of desired pixels
image(img,0,0);
//horizontal lines
line(290, 15, 25, 15);
line(290, 55, 25, 55);
line(290, 95, 25, 95);
line(290, 135, 25, 135);
line(290, 175, 25, 175);
line(290, 215, 25, 215);
//vertical lines
line(290, 15, 290, 215);
line(240, 15, 240, 215);
line(200, 15, 200, 215);
line(160, 15, 160, 215);
line(115, 15, 115, 215);
line(70, 15, 70, 215);
line(25, 15, 25, 215);
//get the colour o coordinates (290, 15)
int p = get(290, 15);
int p1 = get(290, 55);
int p2 = get(290, 95);
int p3 = get(290, 135);
int p4 = get(290, 175);
int p5 = get(290, 215);
System.out.println("(290, 15)g = " + p);
System.out.println("(290, 55)r = " + p1);
System.out.println("(290, 95)g = " + p2);
System.out.println("(290, 135)r = " + p3);
System.out.println("(290, 175)r = " + p4);
System.out.println("(290, 215)g = " + p5);
System.out.println("------------------");
int p6 = get(240, 15);
int p7 = get(200, 15);
System.out.println("(240, 15)r = " + p6);
System.out.println("(200, 15)g = " + p7);
}
}
(--------------------------------------------------- AND OUT PUT -------------------------------)
I'm new to Processing , and am still fumbling around with the various functions. Can someone tell me how the resize function in PImage works ?? I cannot seem to get it to resize my image for setting in the background !? Here is the code
public class tutorial1 extends PApplet
{
//laod an instance of PImage
PImage img;
public void setup()
{
size(400, 400);
//populate an instance of PIMage
img= loadImage("Conn4Board.jpg");
img.resize(400, 400);
}
public void draw()
{
background(img);
//draw an image on the screen at coordinates 0
//image (img, 0, 0);
}
}
I have tried assigning "img.resize(400, 400);" to a new variable img2 but no joy ? I know that if I put
"image (img, 0, 0, 400, 400 );" It'll fit, but I would like to know what part of the img.resize I am doing wrong :/
I have been working my way through the tutorials with Eclipse. My compiler has thrown this error up -->>
Exception in thread "Animation Thread" java.lang.NullPointerException
at tutorial2.draw(tutorial2.java:36)
at processing.core.PApplet.handleDraw(PApplet.java:2142)
at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:193)
at processing.core.PApplet.run(PApplet.java:2020)
at java.lang.Thread.run(Unknown Source)
I reckon the problem is pretty straight forward and that I am missing something obvious , Bellow is the code ..... has anyone come across this already ??
Would appreciate anyhelp
thanks
Steve.
import java.awt.color.ColorSpace;
import processing.core.*;
public class tutorial2 extends PApplet
{
PImage img = loadImage("Picture1.jpg");
public void setup()
{
//load the image and put it in a 400*400 box.
size(400,400);
}
public void draw()
{
//computer i would like to talk to the pixels
img.loadPixels();
//run through the picture Identifyign the RED : Green : Blue colours