如何正确设置相机取景器的帧频?

时间:2018-11-08 07:15:16

标签: python pyside2

我需要获取相机的内容并将其以一定的帧频显示在屏幕上。

这是我的测试代码:

# -*- coding: utf-8 -*-
import sys
from PySide2.QtGui import *
from PySide2.QtCore import *
from PySide2.QtWidgets import *
from PySide2.QtMultimedia import *
from PySide2.QtMultimediaWidgets import *

class demo_Wdiget(QWidget):
    def __init__(self):
        super(demo_Wdiget, self).__init__()
        self.__ui__()

    def __ui__(self):
        t_lay_parent = QHBoxLayout()

        self.camera = QCamera(QCameraInfo.defaultCamera())
        viewfinder = QCameraViewfinder()
        self.camera.setViewfinder(viewfinder)
        self.camera.setCaptureMode(QCamera.CaptureStillImage)

        t_lay_parent.addWidget(viewfinder)
        self.setLayout(t_lay_parent)

        viewfinder.show()
        self.camera.start()
        viewfinderSettings = QCameraViewfinderSettings()
        viewfinderSettings.setMinimumFrameRate(29.0)
        viewfinderSettings.setMaximumFrameRate(9.0)
        self.camera.setViewfinderSettings(viewfinderSettings)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    win = demo_Wdiget()
    win.show()
    sys.exit(app.exec_())

设置ViewfinderSettings后,相机将不再工作。添加注释后,相机将恢复工作。

0 个答案:

没有答案