<jupyter_start><jupyter_text>Pixel Images for Cells in F1 Video<jupyter_code>coordinates = dict(
    #     v-line 
    p1 = (111, 213, 234, 261),
    p2 = (111, 261, 234, 312),
    p3 = (111, 312, 234, 371),
    p4 = (111, 371, 234, 426),
    p5 = (111, 426, 234, 481),
    p6 = (111, 481, 234, 536),
    p7 = (111, 536, 234, 589),
    p8 = (111, 589, 234, 643),
    p9 = (111, 643, 234, 699),
    p10 = (111, 699, 234, 749),
    p11 = (111, 749, 234, 802),
    p12 = (111, 802, 234, 860),
    p13 = (111, 860, 234, 916),
    p14 = (111, 916, 234, 969),
    p15 = (111, 969, 234, 1028),
    p16 = (111, 1028, 234, 1083),
    p17 = (111, 1083, 234, 1133),
    p18 = (111, 1133, 234, 1190),
    p19 = (111, 1190, 234, 1248),
    p20 = (111, 1248, 234, 1300),

    #     v-line 
    gap1 = (333, 213, 478, 261),
    gap2 = (333, 261, 478, 312),
    gap3 = (333, 312, 478, 371),
    gap4 = (333, 371, 478, 426),
    gap5 = (333, 426, 478, 481),
    gap6 = (333, 481, 478, 536),
    gap7 = (333, 536, 478, 589),
    gap8 = (333, 589, 478, 643),
    gap9 = (333, 643, 478, 699),
    gap10 = (333, 699, 478, 749),
    gap11 = (333, 749, 478, 802),
    gap12 = (333, 802, 478, 860),
    gap13 = (333, 860, 478, 916),
    gap14 = (333, 916, 478, 969),
    gap15 = (333, 969, 478, 1028),
    gap16 = (333, 1028, 478, 1083),
    gap17 = (333, 1083, 478, 1133),
    gap18 = (333, 1133, 478, 1190),
    gap19 = (333, 1190, 478, 1248),
    gap20 = (333, 1248, 478, 1300),

    #     v-line 
    int1 = (493, 213, 637, 261),
    int2 = (493, 261, 637, 312),
    int3 = (493, 312, 637, 371),
    int4 = (493, 371, 637, 426),
    int5 = (493, 426, 637, 481),
    int6 = (493, 481, 637, 536),
    int7 = (493, 536, 637, 589),
    int8 = (493, 589, 637, 643),
    int9 = (493, 643, 637, 699),
    int10 = (493, 699, 637, 749),
    int11 = (493, 749, 637, 802),
    int12 = (493, 802, 637, 860),
    int13 = (493, 860, 637, 916),
    int14 = (493, 916, 637, 969),
    int15 = (493, 969, 637, 1028),
    int16 = (493, 1028, 637, 1083),
    int17 = (493, 1083, 637, 1133),
    int18 = (493, 1133, 637, 1190),
    int19 = (493, 1190, 637, 1248),
    int20 = (493, 1248, 637, 1300),

    #     v-line 
    lastlap1 = (653, 213, 811, 261),
    lastlap2 = (653, 261, 811, 312),
    lastlap3 = (653, 312, 811, 371),
    lastlap4 = (653, 371, 811, 426),
    lastlap5 = (653, 426, 811, 481),
    lastlap6 = (653, 481, 811, 536),
    lastlap7 = (653, 536, 811, 589),
    lastlap8 = (653, 589, 811, 643),
    lastlap9 = (653, 643, 811, 699),
    lastlap10 = (653, 699, 811, 749),
    lastlap11 = (653, 749, 811, 802),
    lastlap12 = (653, 802, 811, 860),
    lastlap13 = (653, 860, 811, 916),
    lastlap14 = (653, 916, 811, 969),
    lastlap15 = (653, 969, 811, 1028),
    lastlap16 = (653, 1028, 811, 1083),
    lastlap17 = (653, 1083, 811, 1133),
    lastlap18 = (653, 1133, 811, 1190),
    lastlap19 = (653, 1190, 811, 1248),
    lastlap20 = (653, 1248, 811, 1300),

    #     v-line 
    drs1 = (829, 213, 896, 261),
    drs2 = (829, 261, 896, 312),
    drs3 = (829, 312, 896, 371),
    drs4 = (829, 371, 896, 426),
    drs5 = (829, 426, 896, 481),
    drs6 = (829, 481, 896, 536),
    drs7 = (829, 536, 896, 589),
    drs8 = (829, 589, 896, 643),
    drs9 = (829, 643, 896, 699),
    drs10 = (829, 699, 896, 749),
    drs11 = (829, 749, 896, 802),
    drs12 = (829, 802, 896, 860),
    drs13 = (829, 860, 896, 916),
    drs14 = (829, 916, 896, 969),
    drs15 = (829, 969, 896, 1028),
    drs16 = (829, 1028, 896, 1083),
    drs17 = (829, 1083, 896, 1133),
    drs18 = (829, 1133, 896, 1190),
    drs19 = (829, 1190, 896, 1248),
    drs20 = (829, 1248, 896, 1300),
    
    #     v-line 
    sector_1_1 = (2524, 213, 2680, 261),
    sector_1_2 = (2524, 261, 2680, 312),
    sector_1_3 = (2524, 312, 2680, 371),
    sector_1_4 = (2524, 371, 2680, 426),
    sector_1_5 = (2524, 426, 2680, 481),
    sector_1_6 = (2524, 481, 2680, 536),
    sector_1_7 = (2524, 536, 2680, 589),
    sector_1_8 = (2524, 589, 2680, 643),
    sector_1_9 = (2524, 643, 2680, 699),
    sector_1_10 = (2524, 699, 2680, 749),
    sector_1_11 = (2524, 749, 2680, 802),
    sector_1_12 = (2524, 802, 2680, 860),
    sector_1_13 = (2524, 860, 2680, 916),
    sector_1_14 = (2524, 916, 2680, 969),
    sector_1_15 = (2524, 969, 2680, 1028),
    sector_1_16 = (2524, 1028, 2680, 1083),
    sector_1_17 = (2524, 1083, 2680, 1133),
    sector_1_18 = (2524, 1133, 2680, 1190),
    sector_1_19 = (2524, 1190, 2680, 1248),
    sector_1_20 = (2524, 1248, 2680, 1300),

    #     v-line 
    sector_2_1 = (2680, 213, 2851, 261),
    sector_2_2 = (2680, 261, 2851, 312),
    sector_2_3 = (2680, 312, 2851, 371),
    sector_2_4 = (2680, 371, 2851, 426),
    sector_2_5 = (2680, 426, 2851, 481),
    sector_2_6 = (2680, 481, 2851, 536),
    sector_2_7 = (2680, 536, 2851, 589),
    sector_2_8 = (2680, 589, 2851, 643),
    sector_2_9 = (2680, 643, 2851, 699),
    sector_2_10 = (2680, 699, 2851, 749),
    sector_2_11 = (2680, 749, 2851, 802),
    sector_2_12 = (2680, 802, 2851, 860),
    sector_2_13 = (2680, 860, 2851, 916),
    sector_2_14 = (2680, 916, 2851, 969),
    sector_2_15 = (2680, 969, 2851, 1028),
    sector_2_16 = (2680, 1028, 2851, 1083),
    sector_2_17 = (2680, 1083, 2851, 1133),
    sector_2_18 = (2680, 1133, 2851, 1190),
    sector_2_19 = (2680, 1190, 2851, 1248),
    sector_2_20 = (2680, 1248, 2851, 1300),

    #     v-line 
    sector_3_1 = (2851, 213, 3013, 261),
    sector_3_2 = (2851, 261, 3013, 312),
    sector_3_3 = (2851, 312, 3013, 371),
    sector_3_4 = (2851, 371, 3013, 426),
    sector_3_5 = (2851, 426, 3013, 481),
    sector_3_6 = (2851, 481, 3013, 536),
    sector_3_7 = (2851, 536, 3013, 589),
    sector_3_8 = (2851, 589, 3013, 643),
    sector_3_9 = (2851, 643, 3013, 699),
    sector_3_10 = (2851, 699, 3013, 749),
    sector_3_11 = (2851, 749, 3013, 802),
    sector_3_12 = (2851, 802, 3013, 860),
    sector_3_13 = (2851, 860, 3013, 916),
    sector_3_14 = (2851, 916, 3013, 969),
    sector_3_15 = (2851, 969, 3013, 1028),
    sector_3_16 = (2851, 1028, 3013, 1083),
    sector_3_17 = (2851, 1083, 3013, 1133),
    sector_3_18 = (2851, 1133, 3013, 1190),
    sector_3_19 = (2851, 1190, 3013, 1248),
    sector_3_20 = (2851, 1248, 3013, 1300),

    flag = (422, 35, 496, 67),
    air_temp_c = (2895, 1492, 2973, 1530),
    track_temp_c = (2895, 1530, 2973, 1576),
    humidity_perc = (2895, 1625, 2973, 1675),
    wind_kmh = (2858, 1576, 2927, 1625),
    pressure_mbar = (2807, 1675, 2915, 1723))<jupyter_output><empty_output><jupyter_text>Reading Video and Writing Frames<jupyter_code>name = "1_Austria_2020"
video_path = "../Data/MOV_Files/" + name + ".mov"
saving_dir = "../Data/Frames/" + name + "/"

if os.path.exists(saving_dir):
    print("")
else:
    os.makedirs(saving_dir)
def generate_frames(filepath, saving_directory, frame_spacing=10):
    vidcap = cv2.VideoCapture(filepath)

    success, image = vidcap.read()
    count = 0
    
    saving_directory = saving_directory + "/full_frames/"
    
    if os.path.exists(saving_directory):
        print("Directory Exists. Proceeding.")
        shutil.rmtree(saving_directory)
    os.makedirs(saving_directory)
    
    while success:
        success, image = vidcap.read()
        if count%frame_spacing == 0:
            cv2.imwrite(os.path.join(saving_directory, "frame{}.jpg".format(count)), image)
        count += 1
    vidcap.release(); 
generate_frames(video_path, saving_dir)<jupyter_output><empty_output><jupyter_text>Sub-Frames<jupyter_code>def create_subframes(name, coordinates):
    full_frames = natsorted(glob.glob("../Data/Frames/" + name + "/full_frames/*.jpg"))
    
    for coord in coordinates.keys():
        coord_dir = "../Data/Frames/"+ name + "/" + coord + "/"
        if os.path.exists(coord_dir):
            continue
        else:
            os.makedirs("../Data/Frames/"+ name + "/" + coord + "/")
            
    count = 0 
    for file in full_frames:
        img = Image.open(file)
        img = PIL.ImageChops.invert(img)
        for coord in coordinates.keys():
            cropped_img = img.crop(coordinates[coord])
            saving_path = "../Data/Frames/" + name + "/" + coord + "/" + coord + "_{}.png".format(count)
            cropped_img.save(saving_path)

        count = count + 1
create_subframes(name, coordinates)<jupyter_output><empty_output><jupyter_text>Other<jupyter_code>full_frames = natsorted(glob.glob("../Data/Frames/" + name + "/full_frames/*.jpg"))
for coord in coordinates.keys():
    os.makedirs("../Data/Frames/Testing/" + coord + "/")
count = 0 
for file in full_frames:
    img = Image.open(file)
    print(file)
    img = PIL.ImageChops.invert(img)
    for coord in coordinates.keys():
        cropped_img = img.crop(coordinates[coord])
        saving_path = "../Data/Frames/Testing/" + coord + "/" + coord + "_{}.png".format(count)
        print(saving_path)
        cropped_img.save(saving_path)
        
    
    count = count + 1
# video = cv2.VideoCapture("hungary_2020.mov");

# # Find OpenCV version
# (major_ver, minor_ver, subminor_ver) = (cv2.__version__).split('.')

# if int(major_ver)  < 3 :
#     fps = video.get(cv2.cv.CV_CAP_PROP_FPS)
#     print("Frames per second using video.get(cv2.cv.CV_CAP_PROP_FPS): {0}".format(fps))
# else :
#     fps = video.get(cv2.CAP_PROP_FPS)
#     print("Frames per second using video.get(cv2.CAP_PROP_FPS) : {0}".format(fps))

# video.release(); 

# def generate_frames(filepath, saving_directory, frame_spacing=10)
#     vidcap = cv2.VideoCapture(filepath)

#     success, image = vidcap.read()
#     count = 0

#     while success:
#         success, image = vidcap.read()
#         if count%frame_spacing == 0:
#             cv2.imwrite("frames/frame%d.jpg" % count, image) # save frame as JPEG file 
#         count += 1
#     vidcap.release(); 

# #     v-line 
# p1 = (111, 213, 234, 261)
# p2 = (111, 261, 234, 312)
# p3 = (111, 312, 234, 371)
# p4 = (111, 371, 234, 426)
# p5 = (111, 426, 234, 481)
# p6 = (111, 481, 234, 536)
# p7 = (111, 536, 234, 589)
# p8 = (111, 589, 234, 643)
# p9 = (111, 643, 234, 699)
# p10 = (111, 699, 234, 749)
# p11 = (111, 749, 234, 802)
# p12 = (111, 802, 234, 860)
# p13 = (111, 860, 234, 916)
# p14 = (111, 916, 234, 969)
# p15 = (111, 969, 234, 1028)
# p16 = (111, 1028, 234, 1083)
# p17 = (111, 1083, 234, 1133)
# p18 = (111, 1133, 234, 1190)
# p19 = (111, 1190, 234, 1248)
# p20 = (111, 1248, 234, 1300)

# #     v-line 
# gap1 = (333, 213, 478, 261)
# gap2 = (333, 261, 478, 312)
# gap3 = (333, 312, 478, 371)
# gap4 = (333, 371, 478, 426)
# gap5 = (333, 426, 478, 481)
# gap6 = (333, 481, 478, 536)
# gap7 = (333, 536, 478, 589)
# gap8 = (333, 589, 478, 643)
# gap9 = (333, 643, 478, 699)
# gap10 = (333, 699, 478, 749)
# gap11 = (333, 749, 478, 802)
# gap12 = (333, 802, 478, 860)
# gap13 = (333, 860, 478, 916)
# gap14 = (333, 916, 478, 969)
# gap15 = (333, 969, 478, 1028)
# gap16 = (333, 1028, 478, 1083)
# gap17 = (333, 1083, 478, 1133)
# gap18 = (333, 1133, 478, 1190)
# gap19 = (333, 1190, 478, 1248)
# gap20 = (333, 1248, 478, 1300)

# #     v-line 
# int1 = (493, 213, 637, 261)
# int2 = (493, 261, 637, 312)
# int3 = (493, 312, 637, 371)
# int4 = (493, 371, 637, 426)
# int5 = (493, 426, 637, 481)
# int6 = (493, 481, 637, 536)
# int7 = (493, 536, 637, 589)
# int8 = (493, 589, 637, 643)
# int9 = (493, 643, 637, 699)
# int10 = (493, 699, 637, 749)
# int11 = (493, 749, 637, 802)
# int12 = (493, 802, 637, 860)
# int13 = (493, 860, 637, 916)
# int14 = (493, 916, 637, 969)
# int15 = (493, 969, 637, 1028)
# int16 = (493, 1028, 637, 1083)
# int17 = (493, 1083, 637, 1133)
# int18 = (493, 1133, 637, 1190)
# int19 = (493, 1190, 637, 1248)
# int20 = (493, 1248, 637, 1300)

# #     v-line 
# lastlap1 = (653, 213, 811, 261)
# lastlap2 = (653, 261, 811, 312)
# lastlap3 = (653, 312, 811, 371)
# lastlap4 = (653, 371, 811, 426)
# lastlap5 = (653, 426, 811, 481)
# lastlap6 = (653, 481, 811, 536)
# lastlap7 = (653, 536, 811, 589)
# lastlap8 = (653, 589, 811, 643)
# lastlap9 = (653, 643, 811, 699)
# lastlap10 = (653, 699, 811, 749)
# lastlap11 = (653, 749, 811, 802)
# lastlap12 = (653, 802, 811, 860)
# lastlap13 = (653, 860, 811, 916)
# lastlap14 = (653, 916, 811, 969)
# lastlap15 = (653, 969, 811, 1028)
# lastlap16 = (653, 1028, 811, 1083)
# lastlap17 = (653, 1083, 811, 1133)
# lastlap18 = (653, 1133, 811, 1190)
# lastlap19 = (653, 1190, 811, 1248)
# lastlap20 = (653, 1248, 811, 1300)

# #     v-line 
# drs1 = (829, 213, 896, 261)
# drs2 = (829, 261, 896, 312)
# drs3 = (829, 312, 896, 371)
# drs4 = (829, 371, 896, 426)
# drs5 = (829, 426, 896, 481)
# drs6 = (829, 481, 896, 536)
# drs7 = (829, 536, 896, 589)
# drs8 = (829, 589, 896, 643)
# drs9 = (829, 643, 896, 699)
# drs10 = (829, 699, 896, 749)
# drs11 = (829, 749, 896, 802)
# drs12 = (829, 802, 896, 860)
# drs13 = (829, 860, 896, 916)
# drs14 = (829, 916, 896, 969)
# drs15 = (829, 969, 896, 1028)
# drs16 = (829, 1028, 896, 1083)
# drs17 = (829, 1083, 896, 1133)
# drs18 = (829, 1133, 896, 1190)
# drs19 = (829, 1190, 896, 1248)
# drs20 = (829, 1248, 896, 1300)

# #     v-line 
# sector_1_1 = (2524, 213, 2680, 261)
# sector_1_2 = (2524, 261, 2680, 312)
# sector_1_3 = (2524, 312, 2680, 371)
# sector_1_4 = (2524, 371, 2680, 426)
# sector_1_5 = (2524, 426, 2680, 481)
# sector_1_6 = (2524, 481, 2680, 536)
# sector_1_7 = (2524, 536, 2680, 589)
# sector_1_8 = (2524, 589, 2680, 643)
# sector_1_9 = (2524, 643, 2680, 699)
# sector_1_10 = (2524, 699, 2680, 749)
# sector_1_11 = (2524, 749, 2680, 802)
# sector_1_12 = (2524, 802, 2680, 860)
# sector_1_13 = (2524, 860, 2680, 916)
# sector_1_14 = (2524, 916, 2680, 969)
# sector_1_15 = (2524, 969, 2680, 1028)
# sector_1_16 = (2524, 1028, 2680, 1083)
# sector_1_17 = (2524, 1083, 2680, 1133)
# sector_1_18 = (2524, 1133, 2680, 1190)
# sector_1_19 = (2524, 1190, 2680, 1248)
# sector_1_20 = (2524, 1248, 2680, 1300)

# #     v-line 
# sector_2_1 = (2680, 213, 2851, 261)
# sector_2_2 = (2680, 261, 2851, 312)
# sector_2_3 = (2680, 312, 2851, 371)
# sector_2_4 = (2680, 371, 2851, 426)
# sector_2_5 = (2680, 426, 2851, 481)
# sector_2_6 = (2680, 481, 2851, 536)
# sector_2_7 = (2680, 536, 2851, 589)
# sector_2_8 = (2680, 589, 2851, 643)
# sector_2_9 = (2680, 643, 2851, 699)
# sector_2_10 = (2680, 699, 2851, 749)
# sector_2_11 = (2680, 749, 2851, 802)
# sector_2_12 = (2680, 802, 2851, 860)
# sector_2_13 = (2680, 860, 2851, 916)
# sector_2_14 = (2680, 916, 2851, 969)
# sector_2_15 = (2680, 969, 2851, 1028)
# sector_2_16 = (2680, 1028, 2851, 1083)
# sector_2_17 = (2680, 1083, 2851, 1133)
# sector_2_18 = (2680, 1133, 2851, 1190)
# sector_2_19 = (2680, 1190, 2851, 1248)
# sector_2_20 = (2680, 1248, 2851, 1300)

# #     v-line 
# sector_3_1 = (2851, 213, 3013, 261)
# sector_3_2 = (2851, 261, 3013, 312)
# sector_3_3 = (2851, 312, 3013, 371)
# sector_3_4 = (2851, 371, 3013, 426)
# sector_3_5 = (2851, 426, 3013, 481)
# sector_3_6 = (2851, 481, 3013, 536)
# sector_3_7 = (2851, 536, 3013, 589)
# sector_3_8 = (2851, 589, 3013, 643)
# sector_3_9 = (2851, 643, 3013, 699)
# sector_3_10 = (2851, 699, 3013, 749)
# sector_3_11 = (2851, 749, 3013, 802)
# sector_3_12 = (2851, 802, 3013, 860)
# sector_3_13 = (2851, 860, 3013, 916)
# sector_3_14 = (2851, 916, 3013, 969)
# sector_3_15 = (2851, 969, 3013, 1028)
# sector_3_16 = (2851, 1028, 3013, 1083)
# sector_3_17 = (2851, 1083, 3013, 1133)
# sector_3_18 = (2851, 1133, 3013, 1190)
# sector_3_19 = (2851, 1190, 3013, 1248)
# sector_3_20 = (2851, 1248, 3013, 1300)

# flag = (422, 35, 496, 67)
# air_temp_c = (2895, 1492, 2973, 1530)
# track_temp_c = (2895, 1530, 2973, 1576)
# humidity_perc = (2895, 1625, 2973, 1675)
# wind_kmh = (2858, 1576, 2927, 1625)
# pressure_mbar = (2807, 1675, 2915, 1723)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18317840315802877, 'fraction_numerical': 0.3240162995033745, 'mean_word_length': 3.0618050168088957, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '301526', 'license': 'MIT', 'n_tokens_mistral': 10765, 'n_tokens_neox': 7235, 'n_words': 1883, 'path': 'Notebooks/1_Creating_Frames.ipynb', 'repo_name': 'pedrojrv/Formula1ML', 'size': '15706'}