Opencv蒙图

2024-09-27 19:25:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试实现以下代码:

#coding=utf8

from opencv.cv import *
from opencv.highgui import *

# Avame kaamera
capture = cvCreateCameraCapture(0)

while True:
    frame = cvQueryFrame(capture)
    cvShowImage("Aken", frame)
    char = cvWaitKey(33)

但我得到了某种蒙图错误。有人能告诉我代码中可能出现的问题的方向吗?在

mmap: Invalid argument munmap: Invalid argument munmap: Invalid argument munmap: Invalid argument munmap: Invalid argument Unable to stop the stream.: Bad file descriptor munmap: Invalid argument munmap: Invalid argument munmap: Invalid argument munmap: Invalid argument

(Aken:2782): Gtk-WARNING **: Unable to locate theme engine in module_path: "pixmap",

(Aken:2782): Gtk-WARNING **: Unable to locate theme engine in module_path: "pixmap",

(Aken:2782): Gtk-WARNING **: Unable to locate theme engine in module_path: "pixmap",

(Aken:2782): Gtk-WARNING **: Unable to locate theme engine in module_path: "pixmap",


Tags: topathingtkargumentthemeenginelocate
2条回答

你能用更新的接口来试试这段代码吗?这样你就不用担心发布和其他细节了吗?我假设你有足够新的版本来使用cv2。下面的代码来自another SO answer I made。在

import cv2

capture = cv2.VideoCapture()
cv2.namedWindow("Aken",1)
capture.open(0)
while True:
    frame = capture.read()[1]
    cv2.imshow("Aken", frame)
    if cv2.waitKey(30) == 27: break #`escape` key to stop capture
cv2.destroyWindow("Aken")

捕获过程可能失败,因此最好检查调用的返回:

capture = cvCreateCameraCapture(0)
if not capture :
    print "Error loading camera"
    # Should exit the application

相关问题 更多 >

    热门问题