0
0
Computer Visionml~20 mins

Drawing on images (lines, rectangles, circles, text) in Computer Vision - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Image Drawing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output image after drawing a red line?
Given the following code that draws a red line on a blank image, what will be the color of the pixel at position (50, 50)?
Computer Vision
import numpy as np
import cv2

img = np.zeros((100, 100, 3), dtype=np.uint8)
cv2.line(img, (0, 0), (99, 99), (0, 0, 255), 2)
pixel_color = img[50, 50].tolist()
print(pixel_color)
A[0, 0, 0]
B[255, 0, 0]
C[0, 255, 0]
D[0, 0, 255]
Attempts:
2 left
💡 Hint
Remember OpenCV uses BGR color format, not RGB.
Model Choice
intermediate
2:00remaining
Which OpenCV function draws a filled rectangle?
You want to draw a filled blue rectangle on an image. Which function and parameter combination is correct?
Acv2.rectangle(img, (10, 10), (50, 50), (255, 0, 0), thickness=-1)
Bcv2.line(img, (10, 10), (50, 50), (255, 0, 0), thickness=-1)
Ccv2.rectangle(img, (10, 10), (50, 50), (255, 0, 0), thickness=0)
Dcv2.circle(img, (30, 30), 20, (255, 0, 0), thickness=0)
Attempts:
2 left
💡 Hint
In OpenCV, thickness=-1 fills the shape.
Hyperparameter
advanced
2:00remaining
Choosing thickness for drawing a circle
You want to draw a green circle with a radius of 30 pixels on an image. Which thickness value will draw only the circle's outline with a thickness of 5 pixels?
Athickness=-1
Bthickness=5
Cthickness=0
Dthickness=None
Attempts:
2 left
💡 Hint
Thickness=-1 fills the circle, positive thickness draws outline.
🔧 Debug
advanced
2:00remaining
Why does this text not appear on the image?
Consider this code snippet: import numpy as np import cv2 img = np.zeros((100, 200, 3), dtype=np.uint8) cv2.putText(img, 'Hi', (50, 50), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2) Why might the text not be visible when displaying the image?
Computer Vision
import numpy as np
import cv2

img = np.zeros((100, 200, 3), dtype=np.uint8)
cv2.putText(img, 'Hi', (50, 50), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2)
# Display code omitted
AThe image is not displayed or saved, so text is not visible.
BThe text color is white but the image is black, so text is visible.
CThe font scale is too small to see the text.
DThe coordinates (50, 50) place the text outside the image boundaries.
Attempts:
2 left
💡 Hint
Check if the image is actually shown or saved after drawing.
🧠 Conceptual
expert
2:00remaining
Why use BGR color format in OpenCV instead of RGB?
OpenCV uses BGR color format by default instead of the more common RGB. What is the main reason for this choice?
ABGR uses less memory than RGB.
BBGR is easier to convert to grayscale than RGB.
CBGR matches the order used by most cameras and image file formats internally.
DBGR is the standard color format in all image processing libraries.
Attempts:
2 left
💡 Hint
Think about how images are stored and captured by hardware.