Camera.py 文件源码

python
阅读 38 收藏 0 点赞 0 评论 0

项目:MyoSEMG 作者: LuffyDai 项目源码 文件源码
def run(self):

        while True:
            if self.flag:
                ret, image = self.camera.read()
                if image is None:
                    break
                color_swapped_image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
                height, width, _ = color_swapped_image.shape

                qt_image = QImage(color_swapped_image.data,
                                  width,
                                  height,
                                  color_swapped_image.strides[0],
                                  QImage.Format_RGB888)
                pixmap = QPixmap(qt_image)
                pixmap = pixmap.scaled(self.videoLabel.geometry().width(), self.videoLabel.geometry().height())
                if self.start_flag and self.support_flag:
                    fourcc = cv2.VideoWriter_fourcc(*'DIVX')
                    self.path = "appdata/" + self.cap.guide.dataset_type + "/data/" + self.cap.date_str + "-" + str(
                        self.cap.guide.gesture_type) + ".avi"
                    self.out = cv2.VideoWriter(self.path, fourcc, 20.0, (640, 480))
                    self.support_flag = False
                if self.name == "Camera" and self.out is not None:
                    self.image_siganl.emit(image)
                self.videoLabel.setPixmap(pixmap)
                if self.name == "Video":
                    time.sleep(1/self.fps)
            else:
                pass
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号