I run this without the code to communicate with arduino and it works perfectly fine, but as soon as I tried to implement the code to communicate with arduino I ran into a lot of problems. this is just the latest, and I can't seem to work my way through it. Please Please help. The highlighted area is where Processing is telling me there is a NullPointerException. Thank you!
//This code was inspired by Tom Carden's metropopDenim
//Alexander Braden Feb 2012
import processing.serial.*;
int SPRITE_SIZE = 8;
int NUM_PARTICLES = 10000;
int NUM_ATTRACTORS = 7;
float life = 200;
Particle[] particle;
Attractor[] attractor;
Serial arduinoPort;
String myString;
void setup() {
size(1500, 1000);
background(0);
smooth();
arduinoPort = new Serial(this, Serial.list()[0], 9600);
attractor = new Attractor[NUM_ATTRACTORS];
particle = new Particle[NUM_PARTICLES];
//scatter();
// attractor[0] = new Attractor(934.49005, 755.15497);
// attractor[1] = new Attractor(705.3572, 203.30354);
// attractor[2] = new Attractor(691.54987, 729.0818);
// attractor[3] = new Attractor(412.42975, 323.84244);
// attractor[4] = new Attractor(518.8423, 395.56848);
// attractor[5] = new Attractor(687.9407, 268.94116);
}
void draw() {
if (lifeOut()) {
// move and draw particles
//fill(0, 2);
// rect(0 , 0, width, height);
stroke(255, 25);
//stroke(random(245, 255), random(200, 215), random(0,10), 200); // use lower alpha for finer detail
I'm having serious issues setting up the communication between arduino and processing. All Im trying to do is communicate a simple switch from arduino to processing. Ive used the examples but when i try and implement them onto my code it give me an "error inside Serial<init>0" and highlight this line arduinoPort = new Serial(this, Serial.list()[0], 9600); which is the line inside setup()
I am trying to create a type of xRay flashlight experience using computer vision. My code isn't broken at the moment and its very close to what I am looking for I just can't figure out how to get rid of the dark around the image, at the moment I believe I am just using brightness. I've found some code that dealt with this using PGraphics and JAVA2D I just can't seem to transfer it over to PImages. I apologize if my code is messy. Thanks for your help!
import processing.video.*;
Capture video;
//PImage wall;
PImage sky;
void setup() {
size(1500, 997);
sky = loadImage("sky1_HDR2.png");
//wall = loadImage("wall.jpg");
//brightness tracking
video = new Capture(this, width, height, 30);
noStroke();
smooth();
}
void draw() {
//tint(255, 0);
//image(sky,0,0);
//background (255);
loadPixels();
//tint(255, 0);
//image(sky, 0, 0);
//brightness tracking
if(video.available())
{
video.read();
//image(video, 0, 0, width, height); // Draw the webcam video onto the screen
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
// Search for the brightest pixel: For each row of pixels in the video image and
// for each pixel in the yth row, compute each pixel's index in the video
video.loadPixels();
int index = 0;
for(int y = 0; y < video.height; y++)
{
for(int x = 0; x < video.width; x++)
{
// Get the color stored in the pixel
int pixelValue = video.pixels[index];
// Determine the brightness of the pixel
float pixelBrightness = brightness(pixelValue);
// If the 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