예제 #1
0
파일: slips.py 프로젝트: kostafey/jal
    def readCameraQR(self):
        self.initUi()
        if len(QCameraInfo.availableCameras()) == 0:
            logging.warning(
                g_tr('ImportSlipDialog', "There are no cameras available"))
            return
        self.cameraActive = True
        self.CameraGroup.setVisible(True)
        self.SlipDataGroup.setVisible(False)

        camera_info = QCameraInfo.defaultCamera()
        logging.info(
            g_tr('ImportSlipDialog',
                 "Read QR with camera: " + camera_info.deviceName()))
        self.camera = QCamera(camera_info)
        self.camera.errorOccurred.connect(self.onCameraError)
        self.img_capture = QCameraImageCapture(self.camera)
        self.img_capture.setCaptureDestination(
            QCameraImageCapture.CaptureToBuffer)
        self.img_capture.setBufferFormat(QVideoFrame.Format_RGB32)
        self.img_capture.error.connect(self.onCameraCaptureError)
        self.img_capture.readyForCaptureChanged.connect(self.onReadyForCapture)
        self.img_capture.imageAvailable.connect(self.onCameraImageReady)
        self.camera.setViewfinder(self.Viewfinder)
        self.camera.setCaptureMode(QCamera.CaptureStillImage)
        self.camera.start()
예제 #2
0
 def __init__(self, img_rec: ImageRecognition, res_wid: ResultWid,
              sig_res_wid: SingleResultWid):
     super(CameraMainWin, self).__init__()
     self.setupUi(self)
     # 设置图像处理实例和跳转实例
     self.img_rec = img_rec
     self.res_wid = res_wid
     self.sig_res_wid = sig_res_wid
     # camera设置
     self.camera = QCamera()
     self.camera.setCaptureMode(QCamera.CaptureViewfinder)
     self.cameraOpened = False  # 设置相机打开状态为未打开
     # 设置取景器分辨率
     view_finder_settings = QCameraViewfinderSettings()
     self.camera.setViewfinderSettings(view_finder_settings)
     # 初始化取景器
     self.viewCamera = QtMultimediaWidgets.QCameraViewfinder(self)
     self.camera.setViewfinder(self.viewCamera)
     self.cameraLayout.addWidget(self.viewCamera)  # 取景器放置到预留的布局中
     # 设置图像捕获
     self.capImg = QCameraImageCapture(self.camera)
     self.capImg.setCaptureDestination(QCameraImageCapture.CaptureToBuffer)
     self.capImg.imageCaptured.connect(self._process_captured_image)
     # 绑定按钮槽函数
     self.cameraButton.clicked.connect(self.switch_camera)
     self.captureButton.clicked.connect(self.take_pic)
     self.loadButton.clicked.connect(self.load_file)
     self.reconitionButton.clicked.connect(self.load_path)
     self.chg_mod_Button.clicked.connect(self.change_model)
예제 #3
0
 def setCamera(self, cameraInfo):
     self.m_pCamera = QCamera(cameraInfo)
     self.m_pImageCapture = QCameraImageCapture(self.m_pCamera.metaData(self))
     self.refreshResAndCodecList()
     self.m_pCamera.setCaptureMode(QCamera.CaptureStillImage)
     self.m_pCamera.setCaptureMode(QCamera.CaptureMode.CaptureViewfinder)
     self.m_pCamera.setViewfinder(self.ui.viewfinder)
     self.m_pCamera.start()
     pass
예제 #4
0
    def __init__(self):
        super(MainWindow, self).__init__()

        self.cameraInfo = QCameraInfo.defaultCamera()
        self.camera = QCamera(self.cameraInfo)
        self.camera.setCaptureMode(QCamera.CaptureStillImage)
        self.imageCapture = QCameraImageCapture(self.camera)
        self.imageCapture.imageCaptured.connect(self.imageCaptured)
        self.imageCapture.imageSaved.connect(self.imageSaved)
        self.currentPreview = QImage()

        toolBar = QToolBar()
        self.addToolBar(toolBar)

        fileMenu = self.menuBar().addMenu("&File")
        shutterIcon = QIcon(
            os.path.join(os.path.dirname(__file__), "shutter.svg"))
        self.takePictureAction = QAction(shutterIcon,
                                         "&Take Picture",
                                         self,
                                         shortcut="Ctrl+T",
                                         triggered=self.takePicture)
        self.takePictureAction.setToolTip("Take Picture")
        fileMenu.addAction(self.takePictureAction)
        toolBar.addAction(self.takePictureAction)

        exitAction = QAction(QIcon.fromTheme("application-exit"),
                             "E&xit",
                             self,
                             shortcut="Ctrl+Q",
                             triggered=self.close)
        fileMenu.addAction(exitAction)

        aboutMenu = self.menuBar().addMenu("&About")
        aboutQtAction = QAction("About &Qt", self, triggered=qApp.aboutQt)
        aboutMenu.addAction(aboutQtAction)

        self.tabWidget = QTabWidget()
        self.setCentralWidget(self.tabWidget)

        self.cameraViewfinder = QCameraViewfinder()
        self.camera.setViewfinder(self.cameraViewfinder)
        self.tabWidget.addTab(self.cameraViewfinder, "Viewfinder")

        if self.camera.status() != QCamera.UnavailableStatus:
            name = self.cameraInfo.description()
            self.setWindowTitle("PySide2 Camera Example (" + name + ")")
            self.statusBar().showMessage("Starting: '" + name + "'", 5000)
            self.camera.start()
        else:
            self.setWindowTitle("PySide2 Camera Example")
            self.takePictureAction.setEnabled(False)
            self.statusBar().showMessage("Camera unavailable", 5000)
예제 #5
0
    def select_camera(self, i):
        self.camera = QCamera(self.available_cameras[i])
        self.camera.setViewfinder(self.viewfinder)
        self.camera.setCaptureMode(QCamera.CaptureStillImage)
        self.camera.error.connect(lambda: self.alert(self.camera.errorString()))
        self.camera.start()

        self.capture = QCameraImageCapture(self.camera)
        self.capture.error.connect(lambda i, e, s: self.alert(s))
        self.capture.imageCaptured.connect(lambda d, i: self.status.showMessage("Image %04d captured" % self.save_seq))

        self.current_camera_name = self.available_cameras[i].description()
        self.save_seq = 0
예제 #6
0
파일: CAIO.py 프로젝트: mishrilal/CAIO
    def select_camera(self, i):
        # getting the selected camera
        self.camera = QCamera(self.available_cameras[i])

        # setting capture mode to the camera
        self.camera.setCaptureMode(QCamera.CaptureStillImage)

        # start the camera
        self.camera.start()

        # creating a QCameraImageCapture object
        self.capture = QCameraImageCapture(self.camera)

        # when image captured showing message
        self.capture.imageCaptured.connect(
            lambda d, i: self.status.showMessage("Image captured : " + str(
                self.save_seq)))

        # getting current camera name
        self.current_camera_name = self.available_cameras[i].description()

        # inital save sequence
        self.save_seq = 0