[英]Camera brightness is changing automatically in opencv python
我正在处理一个 OpenCV 项目,我正在处理实时相机图像并与前一帧进行比较。 有一件事注意到相机的亮度随着时间的推移而不断变化。 示例:如果出现一些较暗的 object,它会自动增加背景的亮度。 对于明亮的物体,减少。 因此,我无法准确处理背景
有没有办法修复相机属性?
这将帮助您,然后您可以根据您的要求获取框架并对其进行处理。
import cv2
import numpy as np
import face_recognition
import time
def increase_brightness(img, value=30):
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
h, s, v = cv2.split(hsv)
lim = 255 - value
v[v > lim] = 255
v[v <= lim] += value
final_hsv = cv2.merge((h, s, v))
img = cv2.cvtColor(final_hsv, cv2.COLOR_HSV2BGR)
return img
# camera device can be different for your computer. Try to change 0 to 1 or other if you get some error
video=cv2.VideoCapture(0)
count=0
l=[]
while True:
ret, frame = video.read()
frame = increase_brightness(frame, value=100)#change the brighness as per your requiremens before only more the value more the brightness
cv2.imshow("frame",frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.