0
0
Computer Visionml~10 mins

Stereo vision concept 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 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'
A'leftimage.jpg'
B'left_image.jpg'
C'left.jpg'
D'left.png'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong filename or extension.
Forgetting quotes around the filename.
2fill in blank
medium

Complete 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'
Acv2.COLOR_BGR2RGB
Bcv2.COLOR_BGR2GRAY
Ccv2.COLOR_RGB2GRAY
Dcv2.COLOR_GRAY2BGR
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong color conversion code.
Confusing RGB and BGR color orders.
3fill in blank
hard

Fix 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'
A5
B15
C21
D7
Attempts:
3 left
💡 Hint
Common Mistakes
Using an even number for blockSize.
Using a blockSize too small or too large.
4fill in blank
hard

Fill 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'
A0
B255
C-1
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using negative values for normalization range.
Confusing min and max values.
5fill in blank
hard

Fill 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'
Afocal_length
B1e-6
C0
Dnp.inf
Attempts:
3 left
💡 Hint
Common Mistakes
Dividing by zero causing errors.
Not handling zero disparity pixels.