<jupyter_start><jupyter_text>We first initialize the directories, load the 'pmatrix' file and the corresponding 'offset' file, and load the merged polygons.<jupyter_code>directory = "../data/"
out_dir = "../data/output/"
facade_file = "../data/merged_polygons.txt"

#Load the relevant files, and assign directory paths
image_dir = directory + "RGB/"
param_dir = directory + "params/"
offset = np.loadtxt(param_dir + "offset.txt",usecols=range(3))
polygon_offset = np.loadtxt(directory + "polygon_offset.txt", delimiter=",")
p_matrices = np.loadtxt(param_dir + 'pmatrix.txt', usecols=range(1,13))
filenames = np.genfromtxt(param_dir + 'pmatrix.txt', usecols=range(1), dtype=str)
merged_polygons, facade_type_list, file_format = fw.load_merged_polygon_facades(filename=facade_file)<jupyter_output><empty_output><jupyter_text>We next initialize a dictionary for the Cameras. The Camera class stores all information related to the camera, i.e. intrinsic and extrinsic camera parameters. We also add a height-adjustment to the polygons, and specify the image that we want to project the facades onto.<jupyter_code>#Create a dictionary mapping the camera filename to a Camera object
camera_dict = polygon_projection.create_camera_dict(param_dir, offset)

#Adjust height if necessary for the camera images
height_adj = -polygon_offset[2]
offset_adj = np.array([0.0, 0.0, height_adj])
offset = offset + offset_adj

#Sets the image file
image_filename = "DJI_0081.JPG"

#Get the camera for the specified image file, and calculate the pmatrix
camera = camera_dict[image_filename]
pmatrix = camera.calc_pmatrix()<jupyter_output><empty_output><jupyter_text>Finally, to project the merged polygons onto the image file, we simply load the image and run 'mark_image_file':<jupyter_code>image = utils.load_image(image_dir + image_filename)
out_image = polygon_projection.mark_image_file(image, merged_polygons, facade_type_list, offset, pmatrix)

#Plotting
plt.imshow(np.asarray(out_image))
plt.show()<jupyter_output><empty_output><jupyter_text>This can then be saved to an output directory 'out_dir' and filename 'filename', as illustrated below.<jupyter_code>import os
if not os.path.exists(out_dir):
    os.makedirs(out_dir)
utils.save_image(image, out_dir, image_filename)<jupyter_output>Saving image...<jupyter_text>To crop the image so that only a single facade is visible:<jupyter_code>cropped_image = polygon_projection.crop_image_outside_building(image, merged_polygons, offset, pmatrix)

#Plotting
plt.imshow(np.asarray(cropped_image))
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09883268482490272, 'fraction_numerical': 0.005447470817120622, 'mean_word_length': 7.110410094637224, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '91710', 'license': 'BSD-3-Clause-LBNL', 'n_tokens_mistral': 853, 'n_tokens_neox': 829, 'n_words': 223, 'path': 'Example_Notebooks/RGB_Projection_Example.ipynb', 'repo_name': 'LBNL-ETA/a3dbr', 'size': '2570'}