当前位置:网站首页>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 :
边栏推荐
猜你喜欢

Data warehouse 4.0 notes - user behavior data collection III

Pywinauto+ an application (learn to lesson 9) -- blocked

利用动态规划解决最长增长子序列问题

NFT digital collection development /dapp development

Machine learning algorithm for large factory interview (5) recommendation system algorithm

NepCTF2022 Writeup

activiti7快速入门经验分享

NFT数字藏品平台开发搭建,源码开发数字藏品

ETH转账次数达到一个月高点

window下vmware使用无线网卡nat的方式上网
随机推荐
MySQL account management & four engines & database and table building
NFT digital collection system development: Xu Beihong Art Museum unveiled through the digital collection platform
按照日期进行累加sql
[monitoring deployment practice] display the charts of Prometheus and loki+promtail based on granfana
Fed Brad: last week's employment report showed that the U.S. economy is robust and can withstand higher interest rates
数字藏品系统开发:NFT的主要特点有哪些?
[uiautomation] key instructions (and three call methods) + common mouse actions +sendkeys+inspect learning
Customize foreach tags & select tags to echo data
Websocket long connection
[untitled]
Scala之一变量和数据类型
kubesphere HA install (二)
Scala之二流程控制
[pyrodiomics] the extracted image omics characteristic value is abnormal (many 0 and 1)
Data warehouse 4.0 notes - business data collection
Shell takes the month within a certain time range
[pyautogui learning] screen coordinates and mouse scrolling
第一个FLINK程序之WordCount
Two sorting and one random data fetching of stored procedures
MySQL tree structure recursive query