为什么 face_detection 处理示例不起作用?
Why is face_detection processing example not working?
我目前正在尝试学习 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 );
}
让我们从错误开始:
Exception in thread "Animation Thread" java.lang.NoSuchMethodError:
processing.core.PApplet.registerMethod(Ljava/lang/String;Ljava/lang/Object;)V
at hypermedia.video.OpenCV.(OpenCV.java:297)
看起来这个 OpenCV Processing 包装器正在调用 Processing 的 registerMethod()
而核心库没有它。这可能是您正在使用的 Processing 版本和超媒体 OpenCV 包装器的不兼容问题。请记住,这个包装纸现在已经很旧了。
我推荐使用 Greg Borenstein's OpenCV Processing library,您可以通过 Sketch > Import Library... > Add Library... 轻松安装到 Processing 2+ 并搜索 用于处理的 OpenCV。
库完成安装后,您应该可以 运行 FaceDetection 示例。
我目前正在尝试学习 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 );
}
让我们从错误开始:
Exception in thread "Animation Thread" java.lang.NoSuchMethodError: processing.core.PApplet.registerMethod(Ljava/lang/String;Ljava/lang/Object;)V at hypermedia.video.OpenCV.(OpenCV.java:297)
看起来这个 OpenCV Processing 包装器正在调用 Processing 的 registerMethod()
而核心库没有它。这可能是您正在使用的 Processing 版本和超媒体 OpenCV 包装器的不兼容问题。请记住,这个包装纸现在已经很旧了。
我推荐使用 Greg Borenstein's OpenCV Processing library,您可以通过 Sketch > Import Library... > Add Library... 轻松安装到 Processing 2+ 并搜索 用于处理的 OpenCV。 库完成安装后,您应该可以 运行 FaceDetection 示例。