当前位置: 首页>>代码示例>>Python>>正文


Python Photo.take方法代码示例

本文整理汇总了Python中photo.Photo.take方法的典型用法代码示例。如果您正苦于以下问题:Python Photo.take方法的具体用法?Python Photo.take怎么用?Python Photo.take使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在photo.Photo的用法示例。


在下文中一共展示了Photo.take方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from photo import Photo [as 别名]
# 或者: from photo.Photo import take [as 别名]
class PyPhotoBooth:
    def __init__(self):
        self.photo = Photo()
        self.photo_live = True
        self.global_count = 0
        self.MainWindow = uic.loadUi('main.ui')
        self.webcam = cv.CreateCameraCapture(-1)
        self.timer = QtCore.QTimer(self.MainWindow)
        self.MainWindow.connect(
            self.timer, QtCore.SIGNAL('timeout()'), self.show_frame
        )
        self.MainWindow.connect(
            self.MainWindow.pushButton, QtCore.SIGNAL("clicked()"),
            self.take_photo
        )
        if AUTO_PRINT:
            self.MainWindow.pushButton_2.hide()
        else:
            self.MainWindow.connect(
                self.MainWindow.pushButton_2, QtCore.SIGNAL("clicked()"),
                self.print_photo_button
            )
        if PATCH_BACKGROUND_IMG is not None:
            palette = QtGui.QPalette()
            palette.setBrush(
                QtGui.QPalette.Background, QtGui.QBrush(
                    QtGui.QPixmap(PATCH_BACKGROUND_IMG)
                )
            )
            self.MainWindow.setPalette(palette)
        if PATCH_LOGO_IMG is not None:
            self.MainWindow.lbllogo.setPixmap(
                QtGui.QPixmap(PATCH_LOGO_IMG)
            )
        self.timer.start(1)

    def take_photo(self):
        self.photo.take(self)

    def print_photo_button(self):
        result, count = self.photo.printing(self.global_count)
        if result:
            self.MainWindow.lcdNumber.display(0)
            self.MainWindow.lcdNumber.repaint()
            self.MainWindow.pick_01.setText(' ')
            self.MainWindow.pick_01.repaint()
            self.MainWindow.pick_02.setText(' ')
            self.MainWindow.pick_02.repaint()
            self.MainWindow.pick_03.setText(' ')
            self.MainWindow.pick_03.repaint()
            self.global_count = count

    def show_frame(self):
        if self.photo_live:
            ipl_image = cv.QueryFrame(self.webcam)
            data = ipl_image.tostring()
            image = QtGui.QImage(
                data, ipl_image.width, ipl_image.height, ipl_image.channels
                * ipl_image.width, QtGui.QImage.Format_RGB888)
            pixmap = QtGui.QPixmap()
            pixmap.convertFromImage(image.rgbSwapped())
            self.MainWindow.lblWebcam.setPixmap(pixmap)
开发者ID:Tuxis,项目名称:PyPhotoBooth,代码行数:64,代码来源:PyPhotoBooth.py


注:本文中的photo.Photo.take方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。