generate_side_by_side.py [292:347]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    def _get_frames(video):
        """Gets all frames from a video into a list."""
        allframes = []
        orange_pixind = 0
        orange_frameind = 0
        frame_count = 0
        check_for_orange = True
        while video.isOpened():
            ret, frame = video.read()
            if ret:
                # Convert to gray to simplify the process
                allframes.append(cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY))

                # Check if it's orange still
                if check_for_orange:
                    frame = allframes[-1]
                    histo, _, _ = plt.hist(np.asarray(frame).flatten(), bins=255)

                    maxi = np.argmax(histo)
                    if not orange_pixind:
                        if maxi > 130:
                            continue
                        orange_pixind = maxi
                    elif maxi == orange_pixind:
                        orange_frameind = frame_count
                    else:
                        check_for_orange = False

                frame_count += 1

            else:
                video.release()
                break

        return allframes[orange_frameind:], orange_frameind

    nhists = []

    old_videos = [entry["data"] for entry in old_videos_info]
    new_videos = [entry["data"] for entry in new_videos_info]

    new_orange_frameinds = []
    old_orange_frameinds = []
    total_vids = min(len(old_videos), len(new_videos))
    xcorr = np.zeros((total_vids, total_vids))

    for i in range(total_vids):
        datao, old_orange_frameind = _get_frames(old_videos[i])
        datao = np.asarray(datao)
        old_orange_frameinds.append(old_orange_frameind)

        histo, _, _ = plt.hist(datao.flatten(), bins=255)
        plt.clf()
        gc.collect()

        for j in range(total_vids):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



mozperftest_tools/mozperftest_tools/side_by_side.py [433:488]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        def _get_frames(video):
            """Gets all frames from a video into a list."""
            allframes = []
            orange_pixind = 0
            orange_frameind = 0
            frame_count = 0
            check_for_orange = True
            while video.isOpened():
                ret, frame = video.read()
                if ret:
                    # Convert to gray to simplify the process
                    allframes.append(cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY))

                    # Check if it's orange still
                    if check_for_orange:
                        frame = allframes[-1]
                        histo, _, _ = plt.hist(np.asarray(frame).flatten(), bins=255)

                        maxi = np.argmax(histo)
                        if not orange_pixind:
                            if maxi > 130:
                                continue
                            orange_pixind = maxi
                        elif maxi == orange_pixind:
                            orange_frameind = frame_count
                        else:
                            check_for_orange = False

                    frame_count += 1

                else:
                    video.release()
                    break

            return allframes[orange_frameind:], orange_frameind

        nhists = []

        old_videos = [entry["data"] for entry in old_videos_info]
        new_videos = [entry["data"] for entry in new_videos_info]

        new_orange_frameinds = []
        old_orange_frameinds = []
        total_vids = min(len(old_videos), len(new_videos))
        xcorr = np.zeros((total_vids, total_vids))

        for i in range(total_vids):
            datao, old_orange_frameind = _get_frames(old_videos[i])
            datao = np.asarray(datao)
            old_orange_frameinds.append(old_orange_frameind)

            histo, _, _ = plt.hist(datao.flatten(), bins=255)
            plt.clf()
            gc.collect()

            for j in range(total_vids):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



