def save_measurements( self ): ip1 = [] ip2 = [] for i in self.measurement1: ip1.append(i/self.image1.scale) for i in self.loaded_measurement1: ip1.append(i/self.image1.scale) for i in self.measurement2: ip2.append(i/self.image2.scale) for i in self.loaded_measurement2: ip2.append(i/self.image2.scale) write_match_file(self.match_file,ip1,ip2) for i in self.__picked_objects: self.canvas.delete(i) for i in self.__match_draw_objects: self.canvas.delete(i) self.measurement1 = [] self.measurement2 = [] self.loaded_measurement1 = [] self.loaded_measurement2 = [] ip1, ip2 = read_match_file( self.match_file ) for i in ip1: self.loaded_measurement1.append(i*self.image1.scale) for i in ip2: self.loaded_measurement2.append(i*self.image2.scale) self.draw_loaded_matches()
def solve_homography(meas1, meas2): cmd_path = os.path.realpath(__file__) cmd_path = cmd_path[:cmd_path.rfind("/")+1] write_match_file("tmp.match",meas1,meas2) p = subprocess.Popen(cmd_path+"homography_fit tmp.match", shell=True,stdout=subprocess.PIPE); cmd_return = p.stdout.readline().strip() text = cmd_return[cmd_return.find(":")+13:].strip("((").strip("))").replace(")(",",").split(",") solution = identity(3,float) solution[0,0:3] = [float(text[0]), float(text[1]), float(text[2])] solution[1,0:3] = [float(text[3]), float(text[4]), float(text[5])] solution[2,0:3] = [float(text[6]), float(text[7]), float(text[8])] return solution
def keyPressEvent(self, e): if e.key() == QtCore.Qt.Key_D: print "Deleting last measurement" self.measurements.pop() self.update() if e.key() == QtCore.Qt.Key_S: print "Saving measurement" cube_meas = [] wac_meas = [] for m in self.measurements: cube_meas.append( ip([m.first.x(),m.first.y()],5) ) wac_meas.append( ip([m.second.x(),m.second.y()],5) ) write_match_file("wac.match",cube_meas,wac_meas) os.system(os.path.realpath(__file__)[:-24]+"libexec/generate_wac_cnet " + self.cube ) os.system("rm wac.match")
def solve_homography(meas1, meas2): cmd_path = os.path.realpath(__file__) cmd_path = cmd_path[:cmd_path.rfind("/") + 1] write_match_file("tmp.match", meas1, meas2) p = subprocess.Popen(cmd_path + "homography_fit tmp.match", shell=True, stdout=subprocess.PIPE) cmd_return = p.stdout.readline().strip() text = cmd_return[cmd_return.find(":") + 13:].strip("((").strip("))").replace(")(", ",").split(",") solution = identity(3, float) solution[0, 0:3] = [float(text[0]), float(text[1]), float(text[2])] solution[1, 0:3] = [float(text[3]), float(text[4]), float(text[5])] solution[2, 0:3] = [float(text[6]), float(text[7]), float(text[8])] return solution