Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我能';虽然我已经导入了所需的jar和dll文件,但我没有初始化openCV数据类型_Java_Opencv - Fatal编程技术网

Java 我能';虽然我已经导入了所需的jar和dll文件,但我没有初始化openCV数据类型

Java 我能';虽然我已经导入了所需的jar和dll文件,但我没有初始化openCV数据类型,java,opencv,Java,Opencv,我使用opencv 2.4.4,我想用java检测和跟踪人脸。我在网上找到了如下例子 范例 import hypermedia.video.*; import java.awt.Rectangle; float last = millis(); float interval = 100; int startTime; int noFaces = 0; int noFacesPrev = 0; int dx = 0; int dy = 0; int dwidth = 400; int dheig

我使用opencv 2.4.4,我想用java检测和跟踪人脸。我在网上找到了如下例子

范例

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

float last = millis();
float interval = 100;
int startTime;
int noFaces = 0;
int noFacesPrev = 0;
int dx = 0;
int dy = 0;
int dwidth = 400;
int dheight = 400;

OpenCV opencv;

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



void setup() {

    size( 800,800 );

    opencv = new OpenCV( this );
    opencv.movie( "egypt.mov", 320, 240 );          // load movie file
    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" );

}

void stop() {
    opencv.stop();
    super.stop();
}

void draw() {

    // grab a new frame
    opencv.read();
    opencv.contrast( contrast_value );
    opencv.brightness( brightness_value );

    // proceed detection
    Rectangle[] faces = opencv.detect( 1.2, 2, OpenCV.HAAR_DO_CANNY_PRUNING, 40, 40 ); // 40,40 is the smallest size its looking for

 // draw face area(s)
  noFaces = faces.length;

  if (faces.length >=1 && noFaces > noFacesPrev) {
    startTime = millis();
    println(startTime);
    println(noFaces);
    println(noFacesPrev);
    noFacesPrev = noFaces;
  }
  if (faces.length == 0) {  // if there is no face, start over
    println("no face");
    startTime = 0;
    noFacesPrev = 0;
  }

 if (startTime > 0) {
    println("started");
    if(millis() - startTime >interval && (faces.length >=1)) {
      for ( int i = 0; i= 800){
      dy = dy+400;
      dx = 0;
      }
      if (dy >= 800){
      dy = 0;
      dx = 0; 
      }
      }
      startTime=0;
      println ("clock reset");
      noFacesPrev=0;
    }
  }
}

// Changes contrast/brigthness values

void mouseDragged() {
    contrast_value   = (int) map( mouseX, 0, width, -128, 128 );
    brightness_value = (int) map( mouseY, 0, width, -128, 128 );
}

void keyPressed()
{

  if (key == 's') {
    opencv.stop(); 
    super.stop();
  }
}

当我想在我的项目中尝试此代码时,我无法初始化“
OpenCV OpenCV;
”!!此外,我无法导入“hypermedia.video”

OPENCV不是数据类型。如果要检测图像中的面,可以在代码中导入OpenCV库

在调用任何opencv方法之前,在main方法中调用System.loadLibrary(“opencv_java244”)

您可以在第页找到代码和文档

你能发一个链接到你在互联网上找到这个例子的地方吗?您是否确保
超媒体.视频
在您的类路径中?Java如何知道要实例化的
OpenCV
类?