Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to load two stereo images using OpenCV.
Computer Vision
import cv2 left_image = cv2.imread([1]) right_image = cv2.imread('right.jpg')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong filename or extension.
Forgetting quotes around the filename.
✗ Incorrect
The left stereo image filename is 'left.jpg'. We use cv2.imread() to load it.
2fill in blank
mediumComplete the code to convert the stereo images to grayscale.
Computer Vision
left_gray = cv2.cvtColor(left_image, [1])
right_gray = cv2.cvtColor(right_image, cv2.COLOR_BGR2GRAY) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong color conversion code.
Confusing RGB and BGR color orders.
✗ Incorrect
To convert a color image to grayscale, use cv2.COLOR_BGR2GRAY.
3fill in blank
hardFix the error in the code to compute disparity map using StereoBM.
Computer Vision
stereo = cv2.StereoBM_create(numDisparities=16, blockSize=[1]) disparity = stereo.compute(left_gray, right_gray)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using an even number for blockSize.
Using a blockSize too small or too large.
✗ Incorrect
The blockSize must be an odd number between 5 and 255. 7 is a valid choice.
4fill in blank
hardFill both blanks to normalize and display the disparity map using OpenCV.
Computer Vision
disp_norm = cv2.normalize(disparity, None, [1], [2], cv2.NORM_MINMAX) cv2.imshow('Disparity', disp_norm) cv2.waitKey(0) cv2.destroyAllWindows()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using negative values for normalization range.
Confusing min and max values.
✗ Incorrect
Normalization scales disparity to 0-255 for display.
5fill in blank
hardFill all three blanks to create a depth map from disparity and focal length.
Computer Vision
focal_length = 0.8 # in meters baseline = 0.1 # distance between cameras in meters depth_map = [1] * baseline / (disparity.astype(float) + [2]) depth_map[disparity == 0] = [3]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Dividing by zero causing errors.
Not handling zero disparity pixels.
✗ Incorrect
Depth = focal_length * baseline / disparity. Add a small number to avoid division by zero. Set depth to infinity where disparity is zero.