Complete the code to load an image for depth estimation.
import cv2 image = cv2.imread([1]) print(image.shape)
The cv2.imread function requires the filename as a string with quotes.
Complete the code to convert the image to grayscale for depth processing.
gray_image = cv2.cvtColor(image, [1]) print(gray_image.shape)
To convert a color image to grayscale, use cv2.COLOR_BGR2GRAY.
Fix the error in the code to normalize the depth map between 0 and 1.
depth_normalized = (depth_map - depth_map.min()) / [1] print(depth_normalized.min(), depth_normalized.max())
Normalization requires dividing by the range: max - min.
Fill in the blank to create a dictionary of pixel depths for pixels with depth greater than 0.5.
depth_pixels = {(x, y): depth_map[x, y] for x in range(depth_map.shape[0]) for y in range(depth_map.shape[1]) if depth_map[x, y] [1] 0.5}
print(len(depth_pixels))We want pixels with depth strictly greater than 0.5, so use >.
Fill all three blanks to compute mean squared error (MSE) between predicted and true depth maps.
mse = sum((predicted_depth[1]true_depth)[2]2 for predicted_depth, true_depth in zip(predicted.flatten(), true.flatten())) / [3] print(mse)
MSE is calculated by squaring the difference (using - and **2) and dividing by the number of elements.
