We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › cannot find a class or type named "rectangle"
Page Index Toggle Pages: 1
cannot find a class or type named "rectangle" (Read 4392 times)
cannot find a class or type named "rectangle"
Mar 12th, 2010, 8:27am
 
I am very new to Processing software, this programme has been given as an example and supposedly should work, yet I always get the error message.

cannot find a class or type named "rectangle"


Anyone have any idea?

code up-to the error:

import oscP5.*;
import netP5.*;
import hypermedia.video.*;

OscP5 oscP5;

NetAddress myRemoteLocation;




OpenCV opencv;

// contrast/brightness values
int contrast_value    = 0;
int brightness_value  = 0;



void setup() {

   size( 320, 240 );
 oscP5 = new OscP5(this, 12000);
 myRemoteLocation = new NetAddress("127.0.0.1", 12000);
   opencv = new OpenCV( this );
   opencv.capture( width, height );                   // open video stream
   opencv.cascade( OpenCV.CASCADE_FRONTALFACE_ALT );  // load detection description, here-> front face detection : "haarcascade_frontalface_alt.xml"


   // print usage
   println( "Drag mouse on X-axis inside this sketch window to change contrast" );
   println( "Drag mouse on Y-axis inside this sketch window to change brightness" );

}


public void stop() {
   opencv.stop();
   super.stop();
}



void draw() {

   // grab a new frame
   // and convert to gray
   opencv.read();
   opencv.convert( GRAY );
   opencv.contrast( contrast_value );
   opencv.brightness( brightness_value );

   // proceed detection
   Rectangle[] faces = opencv.detect( 1.2, 2, OpenCV.HAAR_DO_CANNY_PRUNING, 40, 40 );

-----------

Thanks....... :)
Re: cannot find a class or type named "rectangle"
Reply #1 - Mar 12th, 2010, 8:42am
 
Quote:

cannot find a class or type named "rectangle"


Anyone have any idea?

   Rectangle[] faces = opencv.detect( 1.2, 2, OpenCV.HAAR_DO_CANNY_PRUNING, 40, 40 );

Yes.
The error probably reported Rectangle, BTW, not rectangle. Capitals are... capital!
It seems that opencv.detect() returns an array of Rectangle objects. You probably need to import the Rectangle type from whatever library defining OpenCV and Rectangle.
Perhaps something like import hypermedia.video.geometry.*;
(fictitious example as I don't know the library, consult its doc).
Re: cannot find a class or type named "rectangle"
Reply #2 - Mar 12th, 2010, 10:19am
 
first i thought, What?! new to processing. but yep, sojamo != sojomo

Re: cannot find a class or type named "rectangle"
Reply #3 - Mar 17th, 2010, 8:33pm
 
I have had this problem also, under Processing v1.1. After trying v1.0.9 (10/20/2009) I don't get the same error, and all of the OpenCV examples that I have tried seem to work OK. Try downloading v1.0.9 from the download page.
Re: cannot find a class or type named "rectangle"
Reply #4 - Mar 18th, 2010, 1:21am
 
Aha, in this case, it should be java.awt.Rectangle!
AWT packages are no longer imported by default in Processing 1.1. But you can still import them manually.
Re: cannot find a class or type named "rectangle"
Reply #5 - Mar 23rd, 2010, 5:28pm
 
for those who come after. Adding this

Quote:
import java.awt.Rectangle;


to the top is all you need.
Page Index Toggle Pages: 1