Bekbol
Bekbol

Reputation: 21

OpenCV+Processing+Arduino (Face Tracking)

I am doing project Face Tracking using Processing, OpenCV and Arduino. I have faced some problems.

Here is the code:

import hypermedia.video.*;
import java.awt.Rectangle;
OpenCV opencv;

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



void setup() {

    size( 320, 240 );

    opencv = new OpenCV( this );
    opencv.capture( width, height );                   // open video stream
    opencv.cascade( OpenCV.CASCADE_FRONTALFACE_ALT2 );  // 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" );
}

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 );

    // display the image
    image( opencv.image(), 0, 0 );

    // draw 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 ); 
    }
}

And error is here:

[opencv fatal error] library not loaded !
THIS VERSION OF OPENCV LIBRARY REQUIRE ADDITIONAL DEPENDENCIES.
READ THE INSTALLATION INSTRUCTIONS AT http://ubaa.net/shared/processing/opencv/

Verify that the '\path\to\OpenCV\bin' exists in your system PATH and the java.library.path property is correctly.

error message: C:\Users\User\Documents\Processing\libraries\OpenCV\library\OpenCV.dll: Can't find dependent libraries

A library relies on native code that's not available.
Or only works properly when the sketch is run as a 64-bit  application.

I did proper installation, added to the path, I compiled it Processing 32 bit application and Processing 64 bit application same errors I got.

Upvotes: 0

Views: 1150

Answers (1)

Buddhika
Buddhika

Reputation: 325

Screenshot of the Code:

enter image description here

try that code :

import gab.opencv.*;
import processing.video.*;
import java.awt.*;

Capture video;
OpenCV opencv;

void setup() {
  size(640, 480);
  video = new Capture(this, 640/2, 480/2);
  opencv = new OpenCV(this, 640/2, 480/2);
  opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);  

  video.start();
}

void draw() {
  scale(2);
  opencv.loadImage(video);

  image(video, 0, 0 );

  noFill();
  stroke(0, 255, 0);
  strokeWeight(3);
  Rectangle[] faces = opencv.detect();
  println(faces.length);

  for (int i = 0; i < faces.length; i++) {
    println(faces[i].x + "," + faces[i].y);
    rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height);
  }
}

void captureEvent(Capture c) {
  c.read();
}

Note: using the processing for OpenCV and video libraries, you can achieve the face tracking using a webcam. this code is written to achieve that task.

Upvotes: 1

Related Questions