参考代码:https://www.cnblogs.com/lee-li/p/10765822.html
import cv2
import dlib
import os
import random
"""改变图片的相关参数:亮度与对比度"""
def img_change(img, light=1, bias=0):
width = img.shape[1]
height = img.shape[0]
for i in range(0, width):
for j in range(0, height):
for k in range(3):
tmp = int(img[j, i, k]*light + bias)#线性调整 light表示对比度,bias代表亮度偏置
if tmp > 255:
tmp = 255
elif tmp < 0:
tmp = 0
img[j,i,k] = tmp
return img
num=1
cap=cv2.VideoCapture(r"G:\迅雷下载\JSC.mkv")
faces_my_path='G:/PythonN/Graduation/faces_my'
detector = dlib.g