当前位置:网站首页>Mosaic the face part of the picture
Mosaic the face part of the picture
2022-07-23 11:47:00 【mandala -chen】
Premise
install face_recognition library May refer to here
opencv 4.2
numpy
# Mosaic the picture
import cv2
import numpy as np
import pandas as pd
import os
from matplotlib import pyplot as plt
import face_recognition
img2=cv2.imread("3333.jpg")
img=cv2.imread("9k_.jpg")
# Convert to grayscale
img2_gray = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY)
img2_face=face_recognition.face_locations(img2,number_of_times_to_upsample = 0,model ='cnn')
for (top,right,bottom,left) in img2_face:
# Mark the position of the eyes with a rectangular box Detecting multiscale images , The return value is a list of facial region information (x,y, wide , high )
# cv2.rectangle(img2,(left,top),(right,bottom),(255,0,0),2)
roi_gray = img2_gray[top:bottom, left:right]
roi_color= img2[top:bottom, left:right]
img2=img2[top:bottom, left:right]
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces=face_recognition.face_locations(img,number_of_times_to_upsample = 0,model ='cnn')
#x left y top x+w right y+h bottom
for (top,right,bottom,left) in faces:
# Mark the position of the eyes with a rectangular box Detecting multiscale images , The return value is a list of facial region information (x,y, wide , high )
# cv2.rectangle(img,(left,top),(right,bottom),(255,0,0),2)
height,width =[bottom-top,right-left]
img2 = cv2.resize(img2,(height , width),interpolation=cv2.INTER_AREA)
roi_gray = gray[top:bottom, left:right]
roi_color = img[top:bottom, left:right]
img[top:bottom, left:right]=img2
cv2.imshow('img',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
The effect is as follows :
边栏推荐
- mysql修改函数权限未生效
- The difference between slice() and slice()
- MySQL sorts by Chinese field initials
- NepCTF2022 Writeup
- User defined MVC usage & addition, deletion, modification and query
- Es operation command
- NFT digital collection platform development and construction, source code development digital collection
- Typescript introduction
- [untitled]
- Window runs gradle build ----- stacktrace. Exception occurs when the file framework-4.3.0.build-snapshot-schema.zip is not found
猜你喜欢

Sqli lab pass 17-22 notes

upload-lab第1~4关
![[system problems] Net Framework 3.5 installation error](/img/a1/f5410e954b607d5c0549051bd68aa1.png)
[system problems] Net Framework 3.5 installation error

MySQL add, delete, modify, query & advanced query statements

文件上传漏洞常见绕过方式

数仓4.0笔记——用户行为数据采集四

Preliminary study on DC-1 shooting range

Vite x sigma creates designer specific I18N plug-ins
![[literature research] search PubMed for papers in journals with specific impact factors](/img/5e/ea762830e73eee2700402d70ba5c43.png)
[literature research] search PubMed for papers in journals with specific impact factors

NFT digital collection platform development and construction, source code development digital collection
随机推荐
upload-lab第1~4关
数仓4.0笔记——业务数据采集——Sqoop
Php+ code cloud code hook automatically updates online code
用户连续登陆(允许中断)查询sql
[literature research] search PubMed for papers in journals with specific impact factors
mysql根据中文字段首字母排序
利用动态规划解决最长增长子序列问题
phxpaxos安装编译流程
数仓4.0笔记——业务数据采集
MySQL tree structure recursive query
Digital collection development / meta universe digital collection development
[radiology] bugfix: when GLCM features: indexerror: arrays used as indexes must be of integer (or Boolean) type
mysql免密登录设置
Data warehouse 4.0 notes - Data Warehouse Modeling
mysql树形结构递归查询
Installation and process creation of activiti app used by activiti workflow
美联储理事沃勒:去中心化金融最终可能会改变传统金融市场
mysqldump批量导出mysql建表语句
Typescript advanced type
[uiautomation] key instructions (and three call methods) + common mouse actions +sendkeys+inspect learning