php人脸评分,face_compare.php

人脸对比

body {

font-size: 12px;

margin: 0px;

text-align:center;

vertical-align:middle;

overflow-y: auto;

}

require_once 'config/rain_function.php';

$function = new rain_function();

$use_num = $function->use_num('2');?>

人脸识别---人脸对比功能

对比两张人脸的相似度,并给出相似度评分,从而判断是否同一个人

(今日剩余使用次数<?php echo $use_num;?>)

今日次数以及使用完毕,请明日再来

选择要上传的文件

已选择

选择要上传的文件

已选择

提交

if(!empty($_FILES['image1'])){

$file1 = $_FILES['image1'];

$file2 = $_FILES['image2'];

// echo "321342314123";

// $data['g_addtime'] = date("Y-m-d");

// οnchange="document.getElementById('myform').submit();" echo date("Y-m-d");

$image_src1 = $function->upload_file($file1);

$image_src2 = $function->upload_file($file2);

if ($image_src1=='0'||$image_src2=='0'){?>

上传文件格式不对!

$result = $function->face($image_src1,$image_src2,1);

$use_num = $function->use_num('2');

// var_dump($result);

?>

相似指数<?php echo $result['result'][0]['score'];?>

<?php%20echo%20%24image_src1;?>

<?php%20echo%20%24image_src2;?>

}}else{

?> <?php

}

?>

一键复制

编辑

Web IDE

原始数据

按行查看

历史

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
import cv2 import face_recognition import numpy as np from PIL import Image, ImageDraw,ImageFont video_capture = cv2.VideoCapture(r'C:/Users/ALIENWARE/123.mp4')#如果输入是(0)为摄像头输入 #现输入为MP4进行识别检测人脸 first_image = face_recognition.load_image_file("1.jpg") first_face_encoding = face_recognition.face_encodings(first_image)[0] Second_image = face_recognition.load_image_file("2.jpg") Second_face_encoding = face_recognition.face_encodings(Second_image)[0] third_image = face_recognition.load_image_file("3.jpg") third_face_encoding = face_recognition.face_encodings(third_image)[0] inside_face_encodings = [first_face_encoding,Second_face_encoding,third_face_encoding] inside_face_names = ['A','B','C'] face_locations = [] face_encodings = [] face_names = [] process_this_frame = True while True: ret, frame = video_capture.read() small_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25) rgb_small_frame = small_frame[:, :, ::-1] if process_this_frame: face_locations = face_recognition.face_locations(rgb_small_frame) face_encodings = face_recognition.face_encodings(rgb_small_frame, face_locations) face_names = [] for face_encoding in face_encodings: matches = face_recognition.compare_faces(inside_face_encodings, face_encoding) name = '未录入人脸' if True in matches: first_match_index = matches.index(True) name = inside_face_names[first_match_index] face_names.append(name) process_this_frame = not process_this_frame for (top, right, bottom, left), name in zip(face_locations, face_names): top *= 4 right *= 4 bottom *= 4 left *= 4 cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2) img_pil = Image.fromarray(frame) draw = ImageDraw.Draw(img_pil) fontStyle = ImageFont.truetype("C:/Windows/Fonts/simsun.ttc", 32, encoding="utf-8") draw.text((left + 6, bottom - 6), name, (0, 200, 0), font=fontStyle) frame = np.asarray(np.array(img_pil)) cv2.imshow('face_out', frame) if cv2.waitKey(1) & 0xFF == ord('q'): #退出需要按下Q键否则内核会崩溃 break video_capture.release() cv2.destroyAllWindows()
最新发布
06-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值