def camera_check(self): cameras = qtmm.QCameraInfo.availableCameras() if not cameras: qtw.QMessageBox.critical( self, 'No cameras', 'No cameras were found, recording disabled.') else: return qtmm.QCamera(cameras[0])
def __init__(self, parent=None): # Constructor of the class. super(UMedia, self).__init__(parent) # Initialization of the class. self.setWindowTitle("U Camera") # Title of the application. win_icon = QtGui.QIcon("Icons/python1.png") self.setWindowIcon(win_icon) # Set icon for this window. self.setWindowOpacity(0.95) # Set widget opacity. self.camera = QtMultimedia.QCamera() # Video Camera device. self.camera.setViewfinder(self) # Set viewfinder for this self.camera.start() # camera and start. self.cambut1 = UBut1(self, pad=10) # Button for capture image. self.cambut1.setText("Capture") # Text of the button. self.cambut1.setVisible(False) # Set button visible false. self.cambut1.clicked.connect(self.img_capture) self.vc_grid = QtWidgets.QGridLayout() self.vc_grid.addWidget(self.cambut1, 0, 0, 1, 1) self.vc_grid.setAlignment(QtCore.Qt.AlignTop) self.setLayout(self.vc_grid) # Sets layout to the widget.