基于opencv的人脸检测的web应用
2014-06-13 17:08
543 查看
参考资料
https://github.com/bsdnoobz/web-based-face-detecthttp://opencv-code.com/projects/web-based-interface-for-face-detection-with-opencv/
/article/5730407.html
流程如下图
背景知识
php调用exe的返回
<html> <body> <?php system("F:\\xampp\\htdocs\\webcam2\\phptest.exe", $info); echo $info; ?> </body> </html>
在线人脸检测
使用web摄像头web-based-face-detect
目录结构
│ face-detect.exe │ haarcascade_frontalface_alt.xml │ shutter.mp3 │ test.html │ test.php │ testphp.php │ webcam.js │ webcam.swf │ └─out
test.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>JPEGCam Test Page</title> <meta name="generator" content="TextMate http://macromates.com/"> <meta name="author" content="Joseph Huckaby"> <!-- Date: 2008-03-15 --> </head> <body> <table><tr><td valign=top> <h1>JPEGCam Test Page</h1> <h3>Demonstrates a very simple, one-click capture & upload implementation</h3> <!-- First, include the JPEGCam JavaScript Library --> <script type="text/javascript" src="webcam.js"></script> <!-- Configure a few settings --> <script language="JavaScript"> webcam.set_api_url( 'test.php' ); webcam.set_quality( 90 ); // JPEG quality (1 - 100) webcam.set_shutter_sound( true ); // play shutter click sound </script> <!-- Next, write the movie to the page at 320x240 --> <script language="JavaScript"> document.write( webcam.get_html(320, 240) ); </script> <!-- Some buttons for controlling things --> <br/><form> <input type=button value="Configure..." onClick="webcam.configure()"> <input type=button value="Take Snapshot" onClick="webcam.snap()"> </form> <img id="resultimg" src="" /> <script language="JavaScript"> webcam.set_hook( 'onComplete', 'my_callback_function' ); function my_callback_function(response) { // alert("sucess " + response); document.getElementById("resultimg").src=""+response; webcam.reset(); } </script> </body> </html>
test.php
<?php /* JPEGCam Test Script */ /* Receives JPEG webcam submission and saves to local file. */ /* Make sure your directory has permission to write files as your web server user! */ $filename = date('YmdHis') . '.jpg'; $result = file_put_contents( $filename, file_get_contents('php://input') ); $cmd = 'F://xampp//htdocs//face//face-detect//face-detect.exe --input="'.$filename.'" --outdir=out"'; exec($cmd, $info); foreach ($info as $i => $line) { if (preg_match('/\d+,\s*([^\s]+)\s+\((\d+)x(\d+)\)/i', $line, $m)) { // print 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['REQUEST_URI'])."/".$m[1]; // echo "<br>"; // echo $m[2]; // echo $m[3]; } } $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI']) . '/' . $filename; print "$url\n";
实验结果
out目录里就有检测的脸了
source code download
http://pan.baidu.com/share/link?shareid=4035488383&uk=792406754修改人脸检测自带的php文件
<?php $file = 'uploads/'.date('YmdHis').'.jpg';; file_put_contents("$file", file_get_contents("php://input")); $cmd = 'F://xampp//htdocs//face//face-detect//face-detect.exe --input="'.$file.'" --outdir=uploads"'; // $cmd = 'F://xampp//htdocs//face//face-detect//face-detect.exe --input=uploads//1.jpg --outdir=uploads'; // $last = exec($cmd, &$out); $last = exec($cmd, $out); if (strpos($last, 'Error:') === false) { $res = array('success' => true); foreach ($out as $i => $line) { if (preg_match('/\d+,\s*([^\s]+)\s+\((\d+)x(\d+)\)/i', $line, $m)) $res['images'][] = array('src' => $m[1], 'width' => $m[2], 'height' => $m[3]); } } else $res = array('success' => false, 'msg' => $last); header('Content-Type: application/json'); echo json_encode($res);
效果
相关文章推荐
- Qt+Caffe+OpenCV——【一个基于VGG网络的人脸识别考勤系统】(一)人脸检测与识别模块
- 基于OpenCv的人脸检测、识别系统学习制作笔记之三
- 基于Python3+opencv 人脸检测代码
- 基于OpenCV读取摄像头进行人脸检测和人脸识别
- 基于OpenCV读取摄像头进行人脸检测和人脸识别
- 【AdaBoost算法】基于OpenCV实现人脸检测Demo
- 基于opencv的疲劳驾驶检测中人脸和人眼的检测
- Qt基于opencv的人脸检测及相关算法测试工具
- 基于opencv人脸检测原理及实现
- python 调用摄像头,基于opencv 的人脸检测实现
- 基于OpenCV的人脸检测总结
- Python基于OpenCV实现视频的人脸检测
- 基于opencv的人脸检测程序
- Linux系统下利用OpenCV实现人脸检测和基于LBPH算法的人脸识别
- 基于Python OpenCV 的视频人脸检测
- 基于opencv3的人脸检测
- 基于Jetsontk1和OpenCV下的人脸检测
- 基于QT和OpenCV的人脸检测识别系统(1)
- 基于opencv人脸检测原理及实现
- 基于iOS的OpenCV之人脸检测(二)