Esempio n. 1
0
    def get_training_data(self):

        db_info = {}

        with open(self.db_info_file, 'r') as f:
            entries = f.readline().split(";")
            for e in entries:
                entry = e.split("=")
                db_info[str(entry[0])] = str(entry[1])
            if (db_info['cooperative'] != None
                    and db_info['cooperative'] == "True"
                    and db_info['cmlbegintime'] != None
                    and float(db_info['cmlbegintime']) > 0):
                print("CML Training performed until: " +
                      str(db_info['cmlbegintime']))
                self.cmlbegintime = float(db_info['cmlbegintime'])
            else:
                self.cmlbegintime = sys.maxsize
                print("Training performed on full dataset")

        with open(self.sessions_file, 'r') as f:
            for line in f:
                multi_corpus = line.split(":")

                corpus = multi_corpus[0]
                annotator = multi_corpus[1]
                roles = multi_corpus[2].split(";")
                stream = multi_corpus[3]
                sessions = multi_corpus[4].strip().split(";")

                for s in sessions:
                    for r in roles:
                        filename = r + "." + stream
                        annoToAdd = db.get_anno_by_session(
                            db_info, corpus, s, annotator, r)
                        if annoToAdd != None:
                            self.annos.append(annoToAdd)
                            filepath = os.path.join(db_info['root'].strip(),
                                                    corpus, s, filename)
                            #self.file_readers.append(imageio.get_reader(filepath, 'ffmpeg'))
                            self.file_readers.append(
                                cv2.VideoCapture(filepath))
                            print("Loading: " + corpus + ":" + s + ' ' +
                                  filename)
                        else:
                            print("Skipping: " + corpus + ":" + s + ' ' + r +
                                  "." + filename)

        #uncomment for debugging.
        os.remove(self.sessions_file)
        os.remove(self.db_info_file)
Esempio n. 2
0
    def get_training_data(self):

        db_info = {}

        with open(self.db_info_file, 'r') as f:
            entries = f.readline().split(";")
            for e in entries:
                entry = e.split("=")
                db_info[str(entry[0])] = str(entry[1])
            if(db_info['cooperative'] != None and db_info['cooperative'] == "True" and db_info['cmlbegintime'] != None and float(db_info['cmlbegintime']) > 0 ):
                print("CML Training performed until: " + str(db_info['cmlbegintime']))
                self.cmlbegintime = float(db_info['cmlbegintime']) 
            else:
                self.cmlbegintime = sys.maxsize
                print("Training performed on full dataset")
               

        with open(self.sessions_file, 'r') as f:
            for line in f:
                multi_corpus = line.split(":")

                corpus = multi_corpus[0]
                annotator = multi_corpus[1]
                roles = multi_corpus[2].split(";")
                stream = multi_corpus[3]
                sessions = multi_corpus[4].strip().split(";")

                for s in sessions:
                    for r in roles:
                        filename = r + "." + stream
                        annoToAdd = db.get_anno_by_session(db_info, corpus, s, annotator, r)
                        if annoToAdd != None:
                            self.annos.append(annoToAdd)
                            filepath = os.path.join(db_info['root'].strip(), corpus, s, filename)
                            #self.file_readers.append(imageio.get_reader(filepath, 'ffmpeg'))
                            self.file_readers.append(cv2.VideoCapture(filepath))
                            print("Loading: " + corpus + ":" + s + ' '+ filename)
                        else:
                            print("Skipping: " + corpus + ":" + s + ' '+ r + "." + filename)

        #uncomment for debugging.
        os.remove(self.sessions_file)
        os.remove(self.db_info_file)