QVideoFilterRunnable导致PySide2出现分段错误

2024-09-30 16:26:28 发布

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

我试图在用OpenCV处理图像时显示一个视频提要。我已经有了一个使用OpenCV和Python进行图像处理的脚本,但是尝试向VideoOutput添加任何过滤器都会导致分割错误。documentation只有C++的例子,但我尝试用Python来复制它。在

这是我的Python文件(示例.py)公司名称:

from PySide2.QtWidgets import QApplication
from PySide2.QtQml import qmlRegisterType
from PySide2.QtQuick import QQuickView
from PySide2.QtMultimedia import QAbstractVideoFilter, QVideoFilterRunnable
from PySide2.QtCore import QUrl

class ExampleFilterRunnable(QVideoFilterRunnable):
    def run(self, frame, surfaceFormat, flags):
        return frame

class ExampleFilter(QAbstractVideoFilter):
    def createFilterRunnable(self):
        return ExampleFilterRunnable()


app = QApplication([])
qmlRegisterType(ExampleFilter, "ExampleFilter", 1, 0, "ExampleFilter")
view = QQuickView()
url = QUrl("example.qml")

view.setSource(url)
view.setResizeMode(view.SizeRootObjectToView)
view.show()
app.exec_()

以及QML(示例.qml)公司名称:

^{pr2}$

我添加了调试输出,试图了解发生了什么,因为“分段错误(核心转储)”旁边没有错误。分段错误发生在ExampleFilterRunnablecreateFilterRunnable中实例化之后,在调用ExampleFilterRunnable::run之前。在

我用不同的显卡在不同的电脑上运行,使用不同类型的视频和摄像头,结果是一样的。如果我注释掉filters: [filter]中的filters: [filter]行,视频就会播放。在


Tags: fromimport名称view示例视频错误公司