我使用命令 $ sudo apt-get install python-opencv
在Python中安装了OpenCV,并且安装成功。但是当我运行以下代码时:
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
获取以下错误:
$ python bright.py
Traceback (most recent call last):
File "bright.py", line 1, in <module>
import opencv
ImportError: No module named opencv
你能帮我一下吗?