【问题标题】:Opencv munmap errorOpencv munmap 错误
【发布时间】:2012-06-25 16:45:42
【问题描述】:

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

#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)

但我遇到了某种 munmap 错误。谁能指出我的编码中可能出现的问题的方向?

mmap:参数无效 munmap:无效的参数 munmap:无效的参数 munmap:无效的参数 munmap:无效的参数 无法停止流。: 错误的文件描述符 munmap:无效的参数 munmap:无效的参数 munmap:无效的参数 munmap:参数无效

(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",

【问题讨论】:

  • 我记得收到带有错误的 Gtk 警告。您可以找到解决方案here (direct link)。如果那不能解决它(我想它不会),那么请告诉我您使用的是什么版本的 OpenCV。你可以使用新的 c++ 类型绑定(即import cv2)吗?

标签: python opencv


【解决方案1】:

您能否使用更新的界面尝试此代码,这样您就不必担心发布和可能的其他细节?我假设你有一个足够新的版本来使用 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")

【讨论】:

    【解决方案2】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-10
      • 2017-10-11
      • 2012-07-14
      • 2014-11-23
      • 2012-12-27
      • 2011-10-11
      • 2012-03-16
      • 2018-08-06
      相关资源
      最近更新 更多