batuhk

Computer Vision Assignment 1

Jun 20th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. import gab.opencv.*;
  2. import processing.video.*;
  3. import java.awt.*;
  4.  
  5. Capture video;
  6. OpenCV opencv;
  7.  
  8. void setup() {
  9. size(640, 480);
  10. video = new Capture(this, 640/2, 480/2);
  11. opencv = new OpenCV(this, 640/2, 480/2);
  12. opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);
  13.  
  14. video.start();
  15. }
  16.  
  17. void draw() {
  18. scale(2);
  19. opencv.loadImage(video);
  20.  
  21. image(video, 0, 0 );
  22.  
  23. noFill();
  24. stroke(0, 255, 0);
  25. strokeWeight(3);
  26. Rectangle[] faces = opencv.detect();
  27. println(faces.length);
  28.  
  29. for (int i = 0; i < faces.length; i++) {
  30. println(faces[i].x + "," + faces[i].y);
  31. ellipseMode(CORNER);
  32. ellipse(faces[i].x, faces[i].y, faces[i].width, faces[i].height);
  33. }
  34. }
  35.  
  36. void captureEvent(Capture c) {
  37. c.read();
  38. }
Add Comment
Please, Sign In to add comment