0
0
Prompt Engineering / GenAIml~10 mins

Video understanding basics in Prompt Engineering / GenAI - 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 a video file using OpenCV.

Prompt Engineering / GenAI
import cv2
video = cv2.VideoCapture([1])
Drag options to blanks, or click blank then click option'
Avideo.mp4
B'video.mp4'
Copen('video.mp4')
Dcv2.VideoCapture('video.mp4')
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to put the filename in quotes.
Passing the filename without quotes causing a NameError.
2fill in blank
medium

Complete the code to read a frame from the video.

Prompt Engineering / GenAI
ret, frame = video.[1]()
Drag options to blanks, or click blank then click option'
Acapture
Bread_frame
Cread
Dget_frame
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent methods like get_frame or capture.
Confusing method names with other libraries.
3fill in blank
hard

Fix the error in the code to convert a frame to grayscale.

Prompt Engineering / GenAI
gray = cv2.cvtColor(frame, [1])
Drag options to blanks, or click blank then click option'
Acv2.COLOR_GRAY2BGR
Bcv2.COLOR_RGB2GRAY
Ccv2.COLOR_BGR2RGB
Dcv2.COLOR_BGR2GRAY
Attempts:
3 left
💡 Hint
Common Mistakes
Using COLOR_RGB2GRAY which is incorrect for OpenCV frames.
Using COLOR_GRAY2BGR which converts grayscale to color.
4fill in blank
hard

Fill both blanks to create a dictionary of frame indices and their grayscale frames for frames with index less than 5.

Prompt Engineering / GenAI
frames_dict = {i: [1] for i, frame in enumerate(frames) if i [2] 5}
Drag options to blanks, or click blank then click option'
Acv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
B<
C<=
Dframe
Attempts:
3 left
💡 Hint
Common Mistakes
Not converting frames to grayscale in the dictionary.
Using wrong comparison operator like <= instead of <.
5fill in blank
hard

Fill all three blanks to extract frames, convert to grayscale, and store only frames with brightness above 100.

Prompt Engineering / GenAI
filtered_frames = {i: [1] for i, frame in enumerate(video_frames) if cv2.mean([2])[0] [3] 100}
Drag options to blanks, or click blank then click option'
Acv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
Bframe
C>
Dcv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
Attempts:
3 left
💡 Hint
Common Mistakes
Using COLOR_RGB2GRAY which is incorrect for OpenCV frames.
Comparing brightness with < instead of >.
Applying cv2.mean on grayscale frame instead of original.