Ste*_*zzo 11
我已经改进了我之前的尝试(python):
import opencv
import opencv.highgui
import time
import commands
def get_image():
image = opencv.highgui.cvQueryFrame(camera)
return opencv.adaptors.Ipl2PIL(image)
camera = opencv.highgui.cvCreateCameraCapture(-1)
while 1:
image = get_image()
image.thumbnail((32, 24, ))
image = tuple(ord(i) for i in image.tostring())
x = int((int((max(image) / 256.0) * 10) + 1) ** 0.5 / 3 * 10)
cmd = ("sudo su -c 'echo " + str(x) +
" > /sys/devices/virtual/backlight/acpi_video0/brightness'")
status, output = commands.getstatusoutput(cmd)
assert status is 0
Run Code Online (Sandbox Code Playgroud)
这种方法有两个问题:显示器亮度,至少对于我的网络摄像头,永远不会低于四,因为相机在黑暗中不能很好地工作,它可能会在四到五之间跳过一点。反正,
这是如何使用它:
sudo apt-get install python-opencv~/test.pypython test.py而不是平均亮度,我现在得到一个小缩略图的最大亮度(这是为了避免坏点问题并使其更快)。至少在我的灯光和相机组合下,效果相当好!
试一试 (:
| 归档时间: |
|
| 查看次数: |
9676 次 |
| 最近记录: |