def saveToJSON(self): filePath = settings.checkFileAlreadyExists( settings.application.outputFilePathJson, fileExt=".json", fileTypes=[('json files', '.json'), ('all files', '.*')]) if (filePath is None): return # save json script file_name = os.path.splitext(os.path.basename(filePath))[0] labanjson = OrderedDict() labanjson[file_name] = self.labandata try: with open(filePath, 'w') as file: json.dump(labanjson, file, indent=2) settings.application.logMessage( "Labanotation json script was saved to '" + settings.beautifyPath(filePath) + "'") except Exception as e: strError = e settings.application.logMessage( "Exception saving Labanotation json script to '" + settings.beautifyPath(filePath) + "': " + str(e))
def saveView(self): if (self.fig is None): return filePath = os.path.join( settings.application.outputFolder, settings.application.outputName + '_LabanotationScore.png') filePath = settings.checkFileAlreadyExists(filePath, fileExt=".png", fileTypes=[ ('png files', '.png'), ('all files', '.*') ]) if (filePath is None): return try: self.fig.savefig(filePath, bbox_inches='tight') settings.application.logMessage( "Labanotation score view was saved to '" + settings.beautifyPath(filePath) + "'") except Exception as e: strError = e settings.application.logMessage( "Exception saving Labanotation score view to '" + settings.beautifyPath(filePath) + "': " + str(e))
def saveImage(self): if (self.view is None): return filePath = settings.application.outputFilePathImg filePath = settings.checkFileAlreadyExists(filePath, fileExt=".png", fileTypes=[ ('png files', '.png'), ('all files', '.*') ]) if (filePath is None): return try: cv2.imwrite(filePath, self.view.img) settings.application.logMessage( "Labanotation score image was saved to '" + settings.beautifyPath(filePath) + "'") except Exception as e: strError = e settings.application.logMessage( "Exception saving Labanotation score image to '" + settings.beautifyPath(filePath) + "': " + str(e))
def saveToJSON(self): filePath = settings.checkFileAlreadyExists( settings.application.outputFilePathJson, fileExt=".json", fileTypes=[('json files', '.json'), ('all files', '.*')]) if (filePath is None): return # save json script file_name = os.path.splitext(os.path.basename(filePath))[0] labandata = OrderedDict() positions = [] # generate labanotation json data structure for i in range(len(self.timeS)): if i == (len(self.timeS) - 1): dur = '-1' else: dur = '1' time = self.timeS[i] positions.append("Position" + str(i)) data = OrderedDict() data["start time"] = [str(time)] data["duration"] = [dur] data["head"] = ['Forward', 'Normal'] data["right elbow"] = [ self.all_laban[i][0][0], self.all_laban[i][0][1] ] data["right wrist"] = [ self.all_laban[i][1][0], self.all_laban[i][1][1] ] data["left elbow"] = [ self.all_laban[i][2][0], self.all_laban[i][2][1] ] data["left wrist"] = [ self.all_laban[i][3][0], self.all_laban[i][3][1] ] data["rotation"] = ['ToLeft', '0'] labandata[positions[i]] = data labanjson = OrderedDict() labanjson[file_name] = labandata try: with open(filePath, 'w') as file: json.dump(labanjson, file, indent=2) settings.application.logMessage( "Labanotation json script was saved to '" + settings.beautifyPath(filePath) + "'") except Exception as e: strError = e settings.application.logMessage( "Exception saving Labanotation json script to '" + settings.beautifyPath(filePath) + "': " + str(e))
def saveToTXT(self): filePath = settings.checkFileAlreadyExists( settings.application.outputFilePathTxt, fileExt=".txt", fileTypes=[('text files', '.txt'), ('all files', '.*')]) if (filePath is None): return # save text script script = settings.application.labanotation.labanToScript( self.timeS, self.all_laban) try: with open(filePath, 'w') as file: file.write(script) file.close() settings.application.logMessage( "Labanotation text script was saved to '" + settings.beautifyPath(filePath) + "'") except Exception as e: strError = e settings.application.logMessage( "Exception saving Labanotation text script to '" + settings.beautifyPath(filePath) + "': " + str(e))