OpenCV and Processing 4 more

This example will demonstrate the use of the Rect class in OpenCV and compare it with the Rectangle class in Java. The Rect class will be useful when we work on the face detection example later. The detected faces will be returned as rectangles.

import org.opencv.core.Core;
import org.opencv.core.Rect;
import java.awt.Rectangle;
void setup() {
  size(640, 480);
void draw() {
  Rect r1 = new Rect(10, 20, 200, 100);
  Rectangle r2 = new Rectangle(10, 20, 200, 100);
  println("Area of the rectangle " + r1.area());
  println("Width is " + r2.getSize().width);
  println("Height is " + r2.getSize().height);

The example makes use of the area() method of the OpenCV class Rect.