FAQ
Cover
\
Build
\
Source
\
Bugs
\
Reference
\
Libraries
\
Tools
The bugs database has moved
here
.
Bug 905 : expecting EOF, found 'void?
Last modified: 2008-09-18 16:39
P
roject:
processing
trash
Version:
unspecified
Co
m
ponent:
android
book
core
libraries
pde
reference
tools
web
Status:
RESOLVED
Resolution:
INVALID -
Pr
i
ority:
P2
Severity:
normal
Platform
All
O
S:
All
Windows
Mac OS
Linux
Other
Reporter:
sanspot
Assigned To:
fry
Attachment
Type
Created
Size
Actions
Description
: Opened: 2008-08-30 06:20
hello
I'm using Tom Igoe's sketch for color recongnition, but when i compile i
get this:
expecting EOF, found 'void
in the forum i found the same problem, but with older versions of
Processing (
http://dev.processing.org/bugs/show_bug.cgi?id=788#c0
).
I am using version 0148
here is the code:
import processing.video.*
//instance of the capture class
Capture myCamera;
void setup()
{
//window size
size(320, 240);
//list all available cameras
println(Capture.list());
//capture second device available
String myCam= Capture.list()[1];
myCamera = new Capture(this, myCam, width, height, 30);
}
void draw(){
image(myCamera, 0,0);
}
void captureEvent(Capture myCamera) {
myCamera.read();
}
Additional Comment
#1 From fry 2008-09-17 08:23
weird, i just fixed that recently, i wonder what regressed...
Additional Comment
#2 From sanspot 2008-09-17 10:29
I found on the internet another color tracker code and joining it with the Tom igoe's
code it finally work...
Can't tell why the changes made it work because i'm not that good yet...but here it is
the code:
import processing.video.*;
import processing.serial.*;
color targetColor = color(165,62,62);
int[] matchingPixel = new int[2];
Capture myCamera;
void setup() {
size(320, 240);
String []camList;
println(Capture.list());
String s = "Live! Cam Vista IM (VF0420) (VFW)-WDM";
myCamera = new Capture(this, width, height, s, 30);
}
void draw() {
image(myCamera, 0,0);
fill(targetColor);
ellipse(matchingPixel[0], matchingPixel[1], 10, 10);
}
void captureEvent(Capture myCamera) {
myCamera.read();
matchingPixel = findColor(targetColor);
}
void mouseRelease() {
targetColor = myCamera.pixels[mouseY*width+mouseX];
matchingPixel[0] = mouseX;
matchingPixel[1] = mouseY;
}
int[] findColor(color thisColor) {
int[] bestPixelYet = {
-1,-1 };
float smallestDifference = 1000.0;
for(int row=0; row<height; row++) {
for(int column=0; column<width; column++) {
color pixelColor = myCamera.pixels[row*width+column];
float diff = abs(red(targetColor) - red(pixelColor)) + abs(green(targetColor) -
green(pixelColor)) + abs(blue(targetColor) - blue(pixelColor))/3;
if (diff<= smallestDifference) {
smallestDifference = diff;
bestPixelYet [0] = row;
bestPixelYet[1] = column;
}
}
}
return bestPixelYet;
}
Additional Comment
#3 From fry 2008-09-18 16:39
there's a typo, that code is missing a semicolon:
import processing.video.*
should be
import processing.video.*;