def nextImg(self): self.cur_idx += 1 cur = self.list_idx % self.maxLen if cur not in self.img_dict: print("Warning: Not in dictionary. Returning previous image") worker = ImageLoader.Worker( self.loadImg, self.img_list[self.list_idx], cur) # Any other args, kwargs are passed to the run function self.threadpool.start(worker) self.list_idx += 1 return self.current print("Current: ", self.list_idx, cur, self.img_dict[cur][1]) img = self.img_dict[cur][0] self.current = img if self.list_idx < self.vidLen: # Load new image worker = ImageLoader.Worker( self.loadImg, self.img_list[self.list_idx], cur) # Any other args, kwargs are passed to the run function self.threadpool.start(worker) self.list_idx += 1 else: self.list_idx += 1 return img
def load(self, begin=None, end=None): if begin == None: start = self.list_idx if self.list_idx < self.maxLen else self.list_idx - self.maxLen load_len = self.maxLen + start if self.maxLen + start < self.vidLen else self.vidLen elif begin != None: start = begin #if end > self.vidLen: # self.list_idx = start + self.maxLen + 1 # return if self.list_idx >= self.vidLen: self.list_idx = start + self.maxLen + 1 return load_len = start + self.maxLen + 1 if start + self.maxLen + 1 < self.vidLen else self.vidLen self.list_idx = start img = Image.open(self.img_list[start]) img = self.prepareImg(img) self.current = img print("Loading...", start, load_len) for i in range(start, load_len): worker = ImageLoader.Worker( self.loadImg, self.img_list[self.list_idx], self.list_idx % self.maxLen ) # Any other args, kwargs are passed to the run function self.threadpool.start(worker) self.list_idx += 1