示例#1
0
    def set_update_photo(self, toggle=True):

        # this function takes care of updating the view without re-setting the
        # zoom. Is useful for when you lift or relocate landmarks or when
        # drawing lines in the middle of the face
        if self._opencvimage is not None:
            self._scene.removeItem(self._photo)

            temp_image = self._opencvimage.copy()

            if toggle:  # verify if the user wants to remove the landmarks..
                # if shape then draw 68 landmark points
                if self._shape is not None:
                    # mark_picture takes care of drawing the landmarks and the circles
                    # in the iris using opencv
                    temp_image = mark_picture(temp_image, self._shape,
                                              self._points,
                                              self._landmark_size)

            image = cv2.cvtColor(temp_image, cv2.COLOR_BGR2RGB)
            height, width, channel = image.shape
            bytesPerLine = 3 * width
            img_Qt = QtGui.QImage(image.data, width, height, bytesPerLine,
                                  QtGui.QImage.Format_RGB888)
            img_show = QtGui.QPixmap.fromImage(img_Qt)

            self._photo.setPixmap(img_show)
            self._scene.addItem(self._photo)
            self.setDragMode(QtWidgets.QGraphicsView.RubberBandDrag)
示例#2
0
    def save_snapshot(self):
        #save the current view
        if self.displayImage._opencvimage is not None:
            proposed_name = self._file_name[:-4] + '-landmarks'
            name, _ = QtWidgets.QFileDialog.getSaveFileName(
                self, 'Save File', proposed_name,
                'png (*.png);;jpg (*.jpg);; jpeg (*.jpeg)')
            if not name:
                pass
            else:
                #if shape then add shape to image
                temp_image = self.displayImage._opencvimage.copy()

                #draw 68 landmark points
                if self.displayImage._shape is not None:
                    temp_image = mark_picture(temp_image,
                                              self.displayImage._shape,
                                              self.displayImage._lefteye,
                                              self.displayImage._righteye,
                                              self.displayImage._points)

                save_snaptshot_to_file(temp_image, name)
示例#3
0
    def update_view(self):
        # this function takes care of updating the view by re-setting the zoom.
        # is useful to place the image in the scene for the first time

        # if shape then add shape to image
        if self._opencvimage is not None:
            temp_image = self._opencvimage.copy()

            # draw 68 landmark points
            if self._shape is not None:
                temp_image = mark_picture(temp_image, self._shape,
                                          self._points, self._landmark_size)

            image = cv2.cvtColor(temp_image, cv2.COLOR_BGR2RGB)
            height, width, channel = image.shape
            bytesPerLine = 3 * width
            img_Qt = QtGui.QImage(image.data, width, height, bytesPerLine,
                                  QtGui.QImage.Format_RGB888)
            img_show = QtGui.QPixmap.fromImage(img_Qt)

            # show the photo
            self.setPhoto(img_show)