0
0
Computer Visionml~10 mins

Depth estimation basics in Computer Vision - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
Adepth_map.png
B'depth_map'
C'depth_map.png'
Ddepth_map
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the filename.
Passing a variable name without defining it.
2fill in blank
medium

Complete 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'
Acv2.COLOR_BGR2GRAY
Bcv2.COLOR_BGR2RGB
Ccv2.COLOR_RGB2GRAY
Dcv2.COLOR_GRAY2BGR
Attempts:
3 left
💡 Hint
Common Mistakes
Using RGB conversion instead of grayscale.
Using grayscale to BGR conversion by mistake.
3fill in blank
hard

Fix 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'
Adepth_map.min()
Bdepth_map.max() - depth_map.min()
Cdepth_map.max()
Ddepth_map.mean()
Attempts:
3 left
💡 Hint
Common Mistakes
Dividing by max value only.
Dividing by min value.
Dividing by mean value.
4fill in blank
hard

Fill 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'
A<=
B<
C>=
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Using < instead of >.
Using <= instead of >=.
5fill in blank
hard

Fill 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'
A-
B**
Clen(predicted.flatten())
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition instead of subtraction for difference.
Using single * instead of ** for power.
Dividing by wrong length.