【问题标题】:Why is face_detection processing example not working?为什么 face_detection 处理示例不起作用?
【发布时间】:2015-08-22 15:40:11
【问题描述】:

我目前正在尝试关注this 人脸检测教程。 据我所知,我确信我的 opencv 依赖项是正确的。 当我从 opencv 处理示例运行 face_detection 示例时,我收到以下错误消息:

Display -1 does not exist, using the default display instead.
Exception in thread "Animation Thread" java.lang.NoSuchMethodError: processing.core.PApplet.registerMethod(Ljava/lang/String;Ljava/lang/Object;)V
at hypermedia.video.OpenCV.<init>(OpenCV.java:297)
at face_detection.setup(face_detection.java:39)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:662)

这只是我的网络摄像头没有被识别吗?我不明白错误信息,几个小时试图落后于它并没有让我走得太远。 我正在使用 opencv 1.0 和处理 1.5.1。

这里是 face_detection 示例代码:

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

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



/**
 * Changes contrast/brigthness values
 */
void mouseDragged() {
    contrast_value   = (int) map( mouseX, 0, width, -128, 128 );
    brightness_value = (int) map( mouseY, 0, width, -128, 128 );
}

【问题讨论】:

  • 能否请您编辑您的问题并添加部分代码,包括错误所在的第 39 行。

标签: java opencv arduino processing


【解决方案1】:

让我们从错误开始:

线程“动画线程”java.lang.NoSuchMethodError 中的异常: processing.core.PApplet.registerMethod(Ljava/lang/String;Ljava/lang/Object;)V 在 hypermedia.video.OpenCV.(OpenCV.java:297)

看起来这个 OpenCV 处理包装器正在调用处理的registerMethod(),而核心库没有它。这可能是您正在使用的处理版本和超媒体 OpenCV 包装器的不兼容问题。请记住,这个包装器现在已经很老了。

我推荐使用Greg Borenstein's OpenCV Processing library,您可以通过Sketch > Import Library... > Add Library... 轻松安装到Processing 2+ 中并搜索OpenCV for Processing强>。 库安装完成后,您应该能够运行 FaceDetection 示例。

【讨论】:

  • 酷!如果有帮助,请随意投票和/或接受答案:)
猜你喜欢
  • 2018-11-14
  • 2014-09-05
  • 2016-02-18
  • 1970-01-01
  • 2011-06-06
  • 2020-02-18
  • 1970-01-01
  • 2011-04-10
  • 1970-01-01
相关资源
最近更新 更多