Complete the code to load an image using OpenCV.
import cv2 image = cv2.imread([1])
The cv2.imread function requires the image file path as a string, so it must be enclosed in quotes.
Complete the code to convert the image to grayscale.
gray_image = cv2.cvtColor(image, [1])To convert a color image to grayscale, use cv2.COLOR_BGR2GRAY because OpenCV loads images in BGR format.
Fix the error in the code to detect text regions using OpenCV's EAST text detector.
net = cv2.dnn.readNet([1])The model file path must be a string with quotes. The correct file name for EAST text detector is frozen_east_text_detection.pb.
Fill both blanks to prepare the image blob for the EAST detector.
blob = cv2.dnn.blobFromImage(image, [1], (320, 320), [2], True, False)
The scale factor should be 1.0, and the mean subtraction values are (123.68, 116.78, 103.94) for the EAST model preprocessing.
Fill all three blanks to extract scores and geometry from the network output.
scores = output[0, 0, :, :, [1]] geometry = output[0, 0, :, :, [2]:6] conf_threshold = [3]
The scores are at index 0, geometry at indices 1:6, and a common confidence threshold is 0.5 to filter weak detections.