Exemple #1
0
 def __init__(self, category, name):
     super().__init__()
     uic.loadUi('View\Description.ui', self)
     self._exerciseManager = ExerciseManager(category, name)
     self.textEdit.insertPlainText(self._exerciseManager.get_description())
     self.setAction()
     self.exec_()
class Ui_Remove(QtWidgets.QDialog):
    def __init__(self, category, name):
        super().__init__()
        uic.loadUi('View\RemoveVideo.ui', self)
        self._exerciseCategory = category
        self._exerciseName = name
        self._currentExercise = None
        self.setAction()
        self.initialize_gui()
        self.exec_()


    def initialize_gui(self):
        self.comboBox.addItems(next(os.walk("./Exercises/"+self._exerciseCategory+"/"+self._exerciseName))[1])
        self.changeCategory()

    def setAction(self):
        # Imposto le azioni per gli elementi della GUI che generano eventi
        self.pushButton.clicked.connect(self.removeVideo)
        self.pushButton_2.clicked.connect(self.close)
        self.comboBox.currentIndexChanged.connect(self.changeCategory)

    def removeVideo(self):
        if self.comboBox_2.currentText():
            self._currentExercise = ExerciseManager(self._exerciseCategory, self._exerciseName)
            self._currentExercise.remove_video(self.comboBox.currentText(), self.comboBox_2.currentText()[:-4])
            self.close()

    def changeCategory(self):
        self.comboBox_2.clear()
        files = [fname for fname in sorted(os.listdir("./Exercises/"+self._exerciseCategory+"/"+self._exerciseName+"/"+self.comboBox.currentText()),  key = len) if fname.endswith('.mp4')]
        x = len(files)
        self.comboBox_2.addItems(files)
        self.comboBox_2.setCurrentIndex(0)
Exemple #3
0
 def trainLearner(self):
     exerciseManager = ExerciseManager(self._exerciseCategory,
                                       self._exerciseName)
     metricLearner = MetricLearner()
     metricLearner.train_metric_learner_supervised(
         exerciseManager.get_landmarks()[2],
         exerciseManager.get_landmarks()[3], "Exercises" + '\\' +
         self._exerciseCategory + '\\' + self._exerciseName + '\\')
Exemple #4
0
 def execute_exercise(self):
     self._currentExercise = ExerciseManager(self.comboBox.currentText(),
                                             self.comboBox_2.currentText())
     res = self._currentExercise.execute_exercise()
     if (res != 0):
         self.result = Ui_Results(res, self.comboBox.currentText(),
                                  self.comboBox_2.currentText())
     else:
         self.error_message = Ui_CameraError()
Exemple #5
0
 def changeCategory(self):
     self.comboBox_2.clear()
     self.comboBox_2.addItems(
         sorted(
             os.listdir("Exercises" + '\\' + self.comboBox.currentText() +
                        '\\' + self.comboBox_2.currentText()),
             key=len))
     self.comboBox_2.setCurrentIndex(0)
     self._currentExercise = ExerciseManager(self.comboBox.currentText(),
                                             self.comboBox_2.currentText())
Exemple #6
0
    def createNewVideo(self, typeVideo):
        exerciseManager = ExerciseManager(self._exerciseCategory,
                                          self._exerciseName)
        res = exerciseManager.insert_new_video(typeVideo)
        if res != 0:
            self._windowVideoChoice = Ui_VideoTraining(self._exerciseCategory,
                                                       self._exerciseName,
                                                       typeVideo)
        else:
            self.error_message = Ui_CameraError()

        self.initialize()
Exemple #7
0
 def changeExercise(self):
     if (self.comboBox_2.currentText()):
         self._currentExercise = ExerciseManager(
             self.comboBox.currentText(), self.comboBox_2.currentText())
         self.label_5.setText(self._currentExercise.get_description())
         self.play_video(self.comboBox.currentText(),
                         self.comboBox_2.currentText())
     if path.exists("Exercises" + '\\' + self.comboBox.currentText() +
                    '\\' + self.comboBox_2.currentText() +
                    "\\TreanedModel.sav"):
         self.pushButton.setEnabled(True)
     else:
         self.pushButton.setEnabled(False)
Exemple #8
0
 def initialize_gui(self):
     diect = []
     for file in os.listdir("Exercises"):
         if not (file.endswith(".npy")) and not (
                 file.endswith(".png")) and not (file.endswith(".mp4")):
             diect.append(file)
     self.comboBox.addItems(diect)
     self.changeCategory()
     self._currentExercise = ExerciseManager(self.comboBox.currentText(),
                                             self.comboBox_2.currentText())
     self.play_video(self.comboBox.currentText(),
                     self.comboBox_2.currentText())
     self.label_5.setText(self._currentExercise.get_description())
     if path.exists("Exercises" + '\\' + self.comboBox.currentText() +
                    '\\' + self.comboBox_2.currentText() +
                    "\\TreanedModel.sav"):
         self.pushButton.setEnabled(True)
     else:
         self.pushButton.setEnabled(False)
Exemple #9
0
class Ui_Description(QtWidgets.QDialog):
    def __init__(self, category, name):
        super().__init__()
        uic.loadUi('View\Description.ui', self)
        self._exerciseManager = ExerciseManager(category, name)
        self.textEdit.insertPlainText(self._exerciseManager.get_description())
        self.setAction()
        self.exec_()

    def setAction(self):
        # Imposto le azioni per gli elementi della GUI che generano eventi
        self.pushButton.clicked.connect(self.saveDescription)
        self.pushButton_2.clicked.connect(self.close)

    def saveDescription(self):
        self._exerciseManager.replace_description(self.textEdit.toPlainText())
        self.close()

    def removeVideo(self):
        self.window_remove = Ui_Remove(self._exerciseCategory,
                                       self._exerciseName)
 def removeVideo(self):
     if self.comboBox_2.currentText():
         self._currentExercise = ExerciseManager(self._exerciseCategory, self._exerciseName)
         self._currentExercise.remove_video(self.comboBox.currentText(), self.comboBox_2.currentText()[:-4])
         self.close()
Exemple #11
0
class Ui(QtWidgets.QMainWindow):
    def __init__(self):
        super(Ui, self).__init__()
        self.ui = uic.loadUi('View\MainPage.ui', self)
        self._currentExercise = None
        self.player = QtMultimedia.QMediaPlayer(
            None, QtMultimedia.QMediaPlayer.VideoSurface)
        self.player.setVideoOutput(self.ui.widget_8)
        self.initialize_gui()
        self.setAction()
        self.show()

    def initialize_gui(self):
        diect = []
        for file in os.listdir("Exercises"):
            if not (file.endswith(".npy")) and not (
                    file.endswith(".png")) and not (file.endswith(".mp4")):
                diect.append(file)
        self.comboBox.addItems(diect)
        self.changeCategory()
        self._currentExercise = ExerciseManager(self.comboBox.currentText(),
                                                self.comboBox_2.currentText())
        self.play_video(self.comboBox.currentText(),
                        self.comboBox_2.currentText())
        self.label_5.setText(self._currentExercise.get_description())
        if path.exists("Exercises" + '\\' + self.comboBox.currentText() +
                       '\\' + self.comboBox_2.currentText() +
                       "\\TreanedModel.sav"):
            self.pushButton.setEnabled(True)
        else:
            self.pushButton.setEnabled(False)

    def setAction(self):
        # Imposto le azioni per gli elementi della GUI che generano eventi
        self.comboBox.currentIndexChanged.connect(self.changeCategory)
        self.comboBox_2.currentIndexChanged.connect(self.changeExercise)
        self.pushButton_3.clicked.connect(self.show_settings)
        self.pushButton.clicked.connect(self.execute_exercise)
        self.player.stateChanged.connect(self.player.play)

    def changeCategory(self):
        self.comboBox_2.clear()
        self.comboBox_2.addItems(
            sorted(
                os.listdir("Exercises" + '\\' + self.comboBox.currentText() +
                           '\\' + self.comboBox_2.currentText()),
                key=len))
        self.comboBox_2.setCurrentIndex(0)
        self._currentExercise = ExerciseManager(self.comboBox.currentText(),
                                                self.comboBox_2.currentText())

    def changeExercise(self):
        if (self.comboBox_2.currentText()):
            self._currentExercise = ExerciseManager(
                self.comboBox.currentText(), self.comboBox_2.currentText())
            self.label_5.setText(self._currentExercise.get_description())
            self.play_video(self.comboBox.currentText(),
                            self.comboBox_2.currentText())
        if path.exists("Exercises" + '\\' + self.comboBox.currentText() +
                       '\\' + self.comboBox_2.currentText() +
                       "\\TreanedModel.sav"):
            self.pushButton.setEnabled(True)
        else:
            self.pushButton.setEnabled(False)

    def show_settings(self):
        self.window_setting = Ui_settingss(self.comboBox.currentText(),
                                           self.comboBox_2.currentText())

    def play_video(self, category, name):
        file = "Exercises/" + category + "/" + name + "/demo.wmv"
        self.player.setMedia(
            QtMultimedia.QMediaContent(QtCore.QUrl.fromLocalFile(file)))
        self.player.play()

    def execute_exercise(self):
        self._currentExercise = ExerciseManager(self.comboBox.currentText(),
                                                self.comboBox_2.currentText())
        res = self._currentExercise.execute_exercise()
        if (res != 0):
            self.result = Ui_Results(res, self.comboBox.currentText(),
                                     self.comboBox_2.currentText())
        else:
            self.error_message = Ui_CameraError()