我试图在用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}$我添加了调试输出,试图了解发生了什么,因为“分段错误(核心转储)”旁边没有错误。分段错误发生在ExampleFilterRunnable
在createFilterRunnable
中实例化之后,在调用ExampleFilterRunnable::run
之前。在
我用不同的显卡在不同的电脑上运行,使用不同类型的视频和摄像头,结果是一样的。如果我注释掉filters: [filter]
中的filters: [filter]
行,视频就会播放。在
看来这实际上可能是PySide2中的一个bug:https://bugreports.qt.io/browse/PYSIDE-785
相关问题 更多 >
编程相关推荐