真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

java代碼人臉屬性 java實(shí)現(xiàn)人臉識(shí)別

java 人臉識(shí)別 問題!

no jniopencv_objdetect in java.library.path

創(chuàng)新互聯(lián)建站專注于博羅網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠為您提供博羅營銷型網(wǎng)站建設(shè),博羅網(wǎng)站制作、博羅網(wǎng)頁設(shè)計(jì)、博羅網(wǎng)站官網(wǎng)定制、小程序定制開發(fā)服務(wù),打造博羅網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供博羅網(wǎng)站排名全網(wǎng)營銷落地服務(wù)。

opencv的相應(yīng)的dll,沒有放到環(huán)境變量PATH 所指的目錄

用Java畫人臉

完整代碼如下:

import java.awt.Dimension;

import java.awt.Graphics;

import java.awt.Toolkit;

import javax.swing.JFrame;

public class Face extends JFrame ?{

/**

*

*/

private static final long serialVersionUID = 1L;

public Face(){

setSize(500, 500);

setResizable(false);

setDefaultCloseOperation(EXIT_ON_CLOSE);

Dimension screenSize = Toolkit.getDefaultToolkit()

.getScreenSize();

Dimension frameSize = getSize();

setLocation((screenSize.width - frameSize.width) / 2,

(screenSize.height - frameSize.height) / 2);

setVisible(true);

}

//下面的是關(guān)鍵的繪圖代碼

public void paint(Graphics g){

//畫頭

g.drawOval(100, 50, 300, 400);

//畫眼睛

g.drawOval(140, 150, 100, 50);

g.drawOval(260, 150, 100, 50);

//畫鼻子

g.drawArc(140, 150, 100, 150, -90, 90);

g.drawArc(260, 150, 100, 150, 180, 90);

//畫嘴巴

g.drawOval(170, 320, 150, 50);

}

public static void main(String args[]){

new Face();

}

}

主要是用了幾個(gè)java的畫圖函數(shù),如果有用的話,希望采納

如何開發(fā)Java動(dòng)態(tài)人臉識(shí)別

1.環(huán)境搭建

整個(gè)項(xiàng)目的結(jié)構(gòu)圖

2.編寫DetectFaceDemo.java,代碼如下:

[java] view plaincopy

package com.njupt.zhb.test;

import org.opencv.core.Core;

import org.opencv.core.Mat;

import org.opencv.core.MatOfRect;

import org.opencv.core.Point;

import org.opencv.core.Rect;

import org.opencv.core.Scalar;

import org.opencv.highgui.Highgui;

import org.opencv.objdetect.CascadeClassifier;

//

// Detects faces in an image, draws boxes around them, and writes the results

// to "faceDetection.png".

//

public class DetectFaceDemo {

public void run() {

System.out.println("\nRunning DetectFaceDemo");

System.out.println(getClass().getResource("lbpcascade_frontalface.xml").getPath());

// Create a face detector from the cascade file in the resources

// directory.

//CascadeClassifier faceDetector = new CascadeClassifier(getClass().getResource("lbpcascade_frontalface.xml").getPath());

//Mat image = Highgui.imread(getClass().getResource("lena.png").getPath());

//注意:源程序的路徑會(huì)多打印一個(gè)‘/’,因此總是出現(xiàn)如下錯(cuò)誤

/*

* Detected 0 faces Writing faceDetection.png libpng warning: Image

* width is zero in IHDR libpng warning: Image height is zero in IHDR

* libpng error: Invalid IHDR data

*/

//因此,我們將第一個(gè)字符去掉

String xmlfilePath=getClass().getResource("lbpcascade_frontalface.xml").getPath().substring(1);

CascadeClassifier faceDetector = new CascadeClassifier(xmlfilePath);

Mat image = Highgui.imread(getClass().getResource("we.jpg").getPath().substring(1));

// Detect faces in the image.

// MatOfRect is a special container class for Rect.

MatOfRect faceDetections = new MatOfRect();

faceDetector.detectMultiScale(image, faceDetections);

System.out.println(String.format("Detected %s faces", faceDetections.toArray().length));

// Draw a bounding box around each face.

for (Rect rect : faceDetections.toArray()) {

Core.rectangle(image, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height), new Scalar(0, 255, 0));

}

// Save the visualized detection.

String filename = "faceDetection.png";

System.out.println(String.format("Writing %s", filename));

Highgui.imwrite(filename, image);

}

}

3.編寫測(cè)試類:

[java] view plaincopy

package com.njupt.zhb.test;

public class TestMain {

public static void main(String[] args) {

System.out.println("Hello, OpenCV");

// Load the native library.

System.loadLibrary("opencv_java246");

new DetectFaceDemo().run();

}

}

//運(yùn)行結(jié)果:

//Hello, OpenCV

//

//Running DetectFaceDemo

///E:/eclipse_Jee/workspace/JavaOpenCV246/bin/com/njupt/zhb/test/lbpcascade_frontalface.xml

//Detected 8 faces

//Writing faceDetection.png


網(wǎng)站名稱:java代碼人臉屬性 java實(shí)現(xiàn)人臉識(shí)別
文章鏈接:http://weahome.cn/article/dodsoji.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部