Ejemplo n.º 1
0
 def _searchForObject(self):
     alg_params = dict([('hes_threshold', self.hessian_threshold),
                        ('min_match_num', self.min_match),
                        ('good_distance', self.distance)])
     self.master.config(cursor="wait")
     self.master.update()
     #print alg_params['hes_threshold']
     try:
         obj_index = self.select_li.curselection()[0]
         objects = h.processFile('objects.csv')
         objDetect.setupMatch(objects[obj_index][0], objects[obj_index][1],
                              alg_params)
     except IndexError:
         tkMessageBox.showinfo(
             "Oops", "Please select an object from the list to locate")
         self.master.config(cursor="")
         self.master.update()
     except socket.error:
         tkMessageBox.showinfo(
             "o Connection",
             "The computer cannot connect to the robot.\nPlease ensure the robot is switched on and\nthe computer is connected to the robot WiFi."
         )
         self.master.config(cursor="")
         self.master.update()
     self.master.config(cursor="")
     self.master.update()
Ejemplo n.º 2
0
    def __init__(self, master):

        self.master = master
        self.master.title("DALA")
        self.master.geometry('198x440')

        self.hessian_threshold = 550
        self.min_match = 20
        self.distance = 0.6

        self.search_lbl = Label(self.master, text="Select object to locate")
        self.search_lbl.grid(row=1, column=0, columnspan=2, pady=(8, 0))

        self.select_li = Listbox(self.master,
                                 width=27,
                                 height=15,
                                 font=tkFont.Font(family="Helvetica", size=10))

        self.objects = h.processFile('objects.csv')
        setListboxItems(self.objects, self.select_li)

        self.select_li.grid(row=2, column=0, columnspan=2, pady=2, padx=(3, 0))

        self.search_btn = Button(self.master,
                                 text="Locate",
                                 command=self._searchForObject,
                                 width=26,
                                 height=2)
        self.search_btn.grid(row=3,
                             column=0,
                             columnspan=2,
                             pady=(0, 15),
                             padx=(3, 0),
                             sticky="ew")

        self.settings_btn = Button(self.master,
                                   text="Settings",
                                   command=self._openSettings,
                                   width=26,
                                   height=2)
        self.settings_btn.grid(row=5,
                               column=0,
                               columnspan=2,
                               pady=3,
                               padx=(3, 0),
                               sticky="ew")

        self.quit_btn = Button(self.master,
                               text="Quit",
                               command=master.destroy,
                               width=26,
                               height=2)
        self.quit_btn.grid(row=6,
                           column=0,
                           columnspan=2,
                           padx=(3, 0),
                           sticky="ew")
Ejemplo n.º 3
0
def solve():
    path = ''
    errorFile = open('errorLog_task_b.txt', 'w')

    # the following two lists will be used to plot the graph
    cpu_time = []
    first_seq_len = []

    total_time = time.perf_counter()
    sorted_files = getInstancesFiles(
        __DIR__, sort=True)  # sort the list of files (key = len(s1))
    i = 0

    for f in sorted_files:
        path = f
        print(path)
        s1, s2 = processFile(path)

        time_start = time.perf_counter()

        try:
            ans = prog_dyn(s1, s2)
            i += 1
            print(ans)
        except MemoryError:
            print('mem error')
            continue
        except TimeoutError:
            msg = 'Timed out the following instance: ' + path
            print(msg)
            errorFile.write(msg + '\n')
            continue
        except KeyboardInterrupt:
            break

        time_elapsed = (time.perf_counter() - time_start)  # in seconds

        first_seq_len.append(len(s1))
        cpu_time.append(time_elapsed)

    errorFile.close()

    print("It took " + str(time.perf_counter() - total_time) +
          " secs to process all the " + str(i) + " instances.")

    x = np.array(first_seq_len)
    y = np.array(cpu_time)

    d = {'|x|': x, 'time (s)': y}
    data = pd.DataFrame(d)

    sns.set(style='darkgrid')
    sns.lineplot(x='|x|', y='time (s)', data=data)
    plt.title(
        'PROG_DYN: courbe de consommation de temps CPU en fonction de la taille |x|'
    )
    plt.savefig('task_b.png', dpi=300)
    plt.show()

    with open('plotted_values_task_b.txt', 'a+') as f:
        f.write('\n')
        f.write(str(list(x)))
        f.write('\n')
        f.write(str(list(y)))
        f.write('\n\n')
Ejemplo n.º 4
0
from functions import dist_1, dist_2
from helper import processFile
import pdb

if __name__ == '__main__':
    s1, s2 = processFile('Instances_genome/Inst_0000015_76.adn')
    print(dist_2(s1, s2))