def check_repeated_scenes(self,fps,program_mode,check_mode, make_video): similars = [] for cluster1 in sorted(self.clusters,key= lambda cl: cl[0].get_only_num())[:len(self.clusters)-1]: clCounter1 = sorted(self.clusters,key= lambda cl: cl[0].get_only_num()).index(cluster1) for cluster2 in sorted(self.clusters,key= lambda cl: cl[0].get_only_num())[(clCounter1+1):]: clCounter2 = sorted(self.clusters,key= lambda cl: cl[0].get_only_num()).index(cluster2) img1 = self.get_closest_to_ref_point(cluster1) img2 = self.get_closest_to_ref_point(cluster2) dist = self.get_distance_between_two_img(img1,img2) diff = int(math.fabs(img1.get_only_num()-img2.get_only_num())) # print '----> ', img1.get_only_num(), img2.get_only_num(), 'dist', dist, 'diff', diff if are_scenes_joinable(diff,fps,dist,program_mode,check_mode,img1,img2, None,True): similars.append((clCounter1,clCounter2)) for s in sorted(similars, key= lambda s: s[0], reverse=False): print 'SIMILAR SCENES: #',s[0]+1, ' - #', s[1]+1 if make_video: cluster_similars = {} for s in sorted(similars, key= lambda s: s[0], reverse=False): cluster_similars[s[0]] = [] for s in sorted(similars, key= lambda s: s[1], reverse=False): cluster_similars[s[1]] = [] for s in sorted(similars, key= lambda s: s[0], reverse=False): cluster_similars[s[0]].extend([s[1]+1]) for s in sorted(similars, key= lambda s: s[1], reverse=False): cluster_similars[s[1]].extend([s[0]+1]) for k, v in cluster_similars.iteritems(): print v for img in sorted(self.clusters,key= lambda cl: cl[0].get_only_num())[k]: draw_text_on_img(img.filename, 'Similars: %s' % v, right=True, mult=len(v)) '''
def print_scene_starts(self,fps, mode, make_video): if mode=='scenes': print '\n\n####### Scenes (time: hh:mm:ss) #######' text = 'Scene: # %d' elif mode=='joined': print '\n\n####### Videos (time: hh:mm:ss) #######' text = 'Video: # %d' i = 0 for cluster in sorted(self.clusters,key= lambda cl: cl[0].get_only_num()): i+=1 clIndex = self.clusters.index(cluster) scene_firstImg = self.get_cluster_sorted(clIndex)[0] frame_timeDiff_msec = (1.0/eval_float(fps))*1000.0 scene_startTime = (scene_firstImg.get_only_num()*frame_timeDiff_msec)-frame_timeDiff_msec # kis igazitas, scenek kezdesi idejet korabbra veszem egy frame_timediff-nyi idovel, # hogy kezdes elotti legyen inkabb...mint utana scene_startTime -= frame_timeDiff_msec if scene_startTime < 0.0: scene_startTime = 0.0 print '#',i,'start time:',GetInHMS(int(scene_startTime)),'; start img:',scene_firstImg.get_only_filename() if make_video: for img in cluster: draw_text_on_img(img.filename, text % (i)) print '\n' if make_video: frames_to_video('_output.avi', fps)