Utilities/file_io/automated_files_tasks.py
def check_video_conversion_correct(self):
        """[Check if the video conversion was done correctly, i.e. we have all the frames and all clips have same length]
        
        Raises:
            ValueError -- [If something went wrong raise an error]
        """

        tdmss = [f for f in os.listdir(self.videos_fld) if '.tdms' in f]
        editor = Editor()

        for t in tdmss:
            print('\n\nChecking: ', t)
            name = t.split('.')[0]
            conv, join = self.check_if_file_converted(name, self.videos_fld)
            number_of_frames = []
            if conv and not join:
                mp4s = [v for v in os.listdir(self.videos_fld) if name in v and '.mp4' in v]
                for mp4 in mp4s:
                    if [f for f in ['top', 'side', 'catwalk'] if f in mp4]: continue # ignore cropped videos
                    cap = cv2.VideoCapture(os.path.join(self.videos_fld, mp4))
                    nframes, width, height, fps = editor.get_video_params(cap)
                    number_of_frames.append(nframes)
                if not number_of_frames or number_of_frames[0] == 0:
                    continue 

                # Check that we are sure about the total number of frames
                tot = np.sum(np.array(number_of_frames))
                metadata = pd.DataFrame(self.video_metadata.fetch())
                entry = metadata.loc[metadata['videopath'] == os.path.join(self.videos_fld, t)]
                if not entry.shape[0]: raise FileNotFoundError('Load video metadata first')

                if tot != entry['number_of_frames'].values[0]: raise ValueError('Tot frames, converted frames:', a, number_of_frames)

                else: 
                    print(' ...  correctly converted all ',  tot, 'frames [{} converted]'.format(tot))
                # else: 
                #     raise ValueError('Tot frames, converted frames:', a, number_of_frames)
[Check if the video conversion was done correctly, i.e. we have all the frames and all clips have same length]
        
        Raises:
            ValueError -- [If something went wrong raise an error]
        
[Check if the video conversion was done correctly, i.e. we have all the frames and all clips have same length]
Raises:
ValueError -- [If something went wrong raise an error]
[ Check if the video conversion was done correctly i . e . we have all the frames and all clips have same length ] Raises : ValueError -- [ If something went wrong raise an error ]
def check_video_conversion_correct(self):
        tdmss = [f for f in os.listdir(self.videos_fld) if '.tdms' in f]
        editor = Editor()
        for t in tdmss:
            print('\n\nChecking: ', t)
            name = t.split('.')[0]
            conv, join = self.check_if_file_converted(name, self.videos_fld)
            number_of_frames = []
            if conv and not join:
                mp4s = [v for v in os.listdir(self.videos_fld) if name in v and '.mp4' in v]
                for mp4 in mp4s:
                    if [f for f in ['top', 'side', 'catwalk'] if f in mp4]: continue 
                    cap = cv2.VideoCapture(os.path.join(self.videos_fld, mp4))
                    nframes, width, height, fps = editor.get_video_params(cap)
                    number_of_frames.append(nframes)
                if not number_of_frames or number_of_frames[0] == 0:
                    continue 
                tot = np.sum(np.array(number_of_frames))
                metadata = pd.DataFrame(self.video_metadata.fetch())
                entry = metadata.loc[metadata['videopath'] == os.path.join(self.videos_fld, t)]
                if not entry.shape[0]: raise FileNotFoundError('Load video metadata first')
                if tot != entry['number_of_frames'].values[0]: raise ValueError('Tot frames, converted frames:', a, number_of_frames)
                else: 
                    print(' ...  correctly converted all ',  tot, 'frames [{} converted]'.format(tot))
def check_video_conversion_correct ( self ) : tdmss = [ f for f in os . listdir ( self . videos_fld ) if '.tdms' in f ] editor = Editor ( ) for t in tdmss : print ( '\n\nChecking: ' , t ) name = t . split ( '.' ) [ 0 ] conv , join = self . check_if_file_converted ( name , self . videos_fld ) number_of_frames = [ ] if conv and not join : mp4s = [ v for v in os . listdir ( self . videos_fld ) if name in v and '.mp4' in v ] for mp4 in mp4s : if [ f for f in [ 'top' , 'side' , 'catwalk' ] if f in mp4 ] : continue cap = cv2 . VideoCapture ( os . path . join ( self . videos_fld , mp4 ) ) nframes , width , height , fps = editor . get_video_params ( cap ) number_of_frames . append ( nframes ) if not number_of_frames or number_of_frames [ 0 ] == 0 : continue tot = np . sum ( np . array ( number_of_frames ) ) metadata = pd . DataFrame ( self . video_metadata . fetch ( ) ) entry = metadata . loc [ metadata [ 'videopath' ] == os . path . join ( self . videos_fld , t ) ] if not entry . shape [ 0 ] : raise FileNotFoundError ( 'Load video metadata first' ) if tot != entry [ 'number_of_frames' ] . values [ 0 ] : raise ValueError ( 'Tot frames, converted frames:' , a , number_of_frames ) else : print ( ' ...  correctly converted all ' , tot , 'frames [{} converted]' . format ( tot ) )
[Check if the video conversion was done correctly, i.e.
[ Check if the video conversion was done correctly i . e .
"""[Check if the video conversion was done correctly, i.e. we have all the frames and all clips have same length]
        
        Raises:
            ValueError -- [If something went wrong raise an error]
        """ # ignore cropped videos # Check that we are sure about the total number of frames # else:  #     raise ValueError('Tot frames, converted frames:', a, number_of_frames)
self