Processing and OpenCV / Class don't match

edited July 17 in Kinect

hi,

I am a noob of java and one error i don't understand is java.awt.Rectangle[]" does not match with "Rectangle[]"

my all code is here :

import hypermedia.video.*;

OpenCV opencv;

void setup() {

    size( 320, 240 );

    opencv = new OpenCV(this);
    opencv.capture( width, height );
    opencv.cascade( OpenCV.CASCADE_FRONTALFACE_ALT );   // load the FRONTALFACE description fil

}

void draw() {
     class Rectangle {
        };

    opencv.read();
    image( opencv.image(), 0, 0 );

    // detect anything ressembling a FRONTALFACE
    Rectangle[] faces = opencv.detect();

    // draw detected face area(s)
    noFill();
    stroke(255,0,0);
    for( int i=0; i<faces.length; i++ ) {
        rect( faces[i].x, faces[i].y, faces[i].width, faces[i].height ); 
    }
}

I want include why don't match.

Answers

  • Get rid of lines 16 and 17

    import java.awt.Rectangle
    
  • edited July 17
    • All Java classes have their own full path name package.
    • OpenCV::detect() method returns a Rectangle[] from package java.awt:
      http://Docs.Oracle.com/javase/8/docs/api/java/awt/Rectangle.html
    • However, you're trying to assign it to your own "fake" Rectangle[] faces variable, which has a datatype w/ a diff. path name package from your local class inside draw()! :-&
    • We can't fool Java type system, use the real import java.awt.Rectangle; datatype! >:)
Sign In or Register to comment.