Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to load an image for depth estimation.
Computer Vision
import cv2 image = cv2.imread([1]) print(image.shape)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the filename.
Passing a variable name without defining it.
✗ Incorrect
The cv2.imread function requires the filename as a string with quotes.
2fill in blank
mediumComplete the code to convert the image to grayscale for depth processing.
Computer Vision
gray_image = cv2.cvtColor(image, [1]) print(gray_image.shape)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using RGB conversion instead of grayscale.
Using grayscale to BGR conversion by mistake.
✗ Incorrect
To convert a color image to grayscale, use cv2.COLOR_BGR2GRAY.
3fill in blank
hardFix the error in the code to normalize the depth map between 0 and 1.
Computer Vision
depth_normalized = (depth_map - depth_map.min()) / [1] print(depth_normalized.min(), depth_normalized.max())
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Dividing by max value only.
Dividing by min value.
Dividing by mean value.
✗ Incorrect
Normalization requires dividing by the range: max - min.
4fill in blank
hardFill in the blank to create a dictionary of pixel depths for pixels with depth greater than 0.5.
Computer Vision
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)) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using < instead of >.
Using <= instead of >=.
✗ Incorrect
We want pixels with depth strictly greater than 0.5, so use >.
5fill in blank
hardFill all three blanks to compute mean squared error (MSE) between predicted and true depth maps.
Computer Vision
mse = sum((predicted_depth[1]true_depth)[2]2 for predicted_depth, true_depth in zip(predicted.flatten(), true.flatten())) / [3] print(mse)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition instead of subtraction for difference.
Using single * instead of ** for power.
Dividing by wrong length.
✗ Incorrect
MSE is calculated by squaring the difference (using - and **2) and dividing by the number of elements.