Arraylist problem
in
Contributed Library Questions
•
5 months ago
Hello, I have a problem with displaying an object from an arraylist. I keep getting the error for line 57 "The constructor Bubble1() is undefined", I'm not too sure why. My code is below although I haven't included the code for the Bubble1 class as I know that this works, however if anyone could find my mistake I would be very grateful!
- import hypermedia.video.*; // Imports the OpenCV library
- import oscP5.*;
- import netP5.*;
- OscP5 oscP5;
- NetAddress myBroadcastLocation;
- OpenCV opencv; // Creates a new OpenCV object
- PImage movementImg; // Creates a new PImage to hold the movement image
- int poppedBubbles; // Creates a variable to hold the total number of destroyed bubbles
- float myProportion=0.011;
- //create initial color scheme for bubbles
- float r1 = 170;
- float g1 = 211;
- float b1 = 126;
- float r2 = 91;
- float g2 = 105;
- float b2 = 176;
- int a = 150; //alpha
- int maxRadius;
- float speed;
- float backbarYpos;
- ArrayList bubbles1; // Creates an ArrayList to hold the Bubble objects
- void setup()
- {
- size ( 800, 600 ); // Window size of 640 x 480
- oscP5 = new OscP5(this, 12000);
- opencv = new OpenCV( this ); // Initialises the OpenCV library
- opencv.capture( 800, 600 ); // Sets the capture size to 640 x 480
- movementImg = new PImage( 800, 600 ); // Initialises the PImage that holds the movement image
- poppedBubbles = 0;
- bubbles1 = new ArrayList();
- maxRadius = 20;
- speed = 1.0;
- backbarYpos = 0.9*height;
- for (int i=0;i<bubbles1.size();i++) {
- color colour = color(100, 10, 255);
- Bubble1 Ball = new Bubble1(random(width), 0, 10+random(maxRadius), colour);
- }
- smooth();
- myBroadcastLocation = new NetAddress("127.0.0.1", 57120);
- }
- void draw() {
- bubbles1.add(new Bubble1());
- opencv.read(); // Captures a frame from the camera
- opencv.flip(OpenCV.FLIP_HORIZONTAL); // Flips the image horizontally
- image( opencv.image(), 0, 0 ); // Draws the camera image to the screen
- opencv.absDiff(); // Creates a difference image
- opencv.convert(OpenCV.GRAY); // Converts to greyscale
- opencv.blur(OpenCV.BLUR, 3); // Blur to remove camera noise
- opencv.threshold(20); // Thresholds to convert to black and white
- movementImg = opencv.image(); // Puts the OpenCV buffer into an image object
- // BUBBLE 1
- for ( int i = 0; i < bubbles1.size(); i++ ){ // For every bubble in the bubbles array
- Bubble1 _bubble1 = (Bubble1) bubbles1.get(i); // Copies the current bubble into a temporary object
- bubbles1.add(new Bubble());
- println(bubbles1.size());
- if(_bubble1.update() == 1){ // If the bubble's update function returns '1'
- bubbles1.remove(i); // then remove the bubble from the array
- _bubble1 = null; // and make the temporary bubble object null
- i--; // subtract 1 from i, or we'll skip the next bubble
- }else{ // If the bubble's update function doesn't return '1'
- bubbles1.set(i, _bubble1); // Copys the updated temporary bubble object back into the array
- _bubble1 = null; // Makes the temporary bubble object null.
- }
- }
- opencv.remember(OpenCV.SOURCE, OpenCV.FLIP_HORIZONTAL); // Remembers the camera image so we can generate a difference image next frame.
- }
- void oscEvent(OscMessage theOscMessage) {
- /* get and print the address pattern and the typetag of the received OscMessage */
- println("### received an osc message with addrpattern "+theOscMessage.addrPattern()+" and typetag "+theOscMessage.typetag());
- theOscMessage.print();
- }
1