【问题标题】:OpenCV+Processing+Arduino (Face Tracking)OpenCV+Processing+Arduino(人脸追踪)
【发布时间】:2018-04-10 20:03:27
【问题描述】:

我正在使用 Processing、OpenCV 和 Arduino 进行人脸跟踪项目。我遇到了一些问题。

代码如下:

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

错误就在这里:

[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.

我做了正确的安装,添加到路径,我编译它处理 32 位应用程序和处理 64 位应用程序相同的错误。

【问题讨论】:

    标签: opencv processing


    【解决方案1】:

    代码截图:

    试试那个代码:

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

    注意:使用 OpenCV 和视频库的处理,您可以使用网络摄像头实现人脸跟踪。编写此代码是为了完成该任务。

    【讨论】:

    • 使用OpenCV和视频库的处理,可以通过网络摄像头实现人脸跟踪。编写此代码是为了完成该任务。
    猜你喜欢
    • 2017-10-05
    • 2014-10-07
    • 1970-01-01
    • 1970-01-01
    • 2020-04-07
    • 1970-01-01
    • 1970-01-01
    • 2021-05-15
    • 2011-09-15
    相关资源
    最近更新 更多