Question: Below is a block-matching given for motion estimation. A code for block-matching is given under Understand this code and answer why optical flow is very

Below is a block-matching given for motion estimation.
A code for block-matching is given under

Understand this code and answer why optical flow is very useful and powerful, yet has some drawbacks! describe the main aspects based in the code given. Only rely to theory given in the lectures!


Search Area Candidate Block

cap = cv2.VideoCapture(video_path)

suc, prev = cap.read()

prevgray = cv2.cvtColor(prev, cv2.COLOR_BGR2GRAY)


count=0

while count

suc, img = cap.read()

gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

# start time to calculate FPS

start = time.time()

flow = cv2.calcOpticalFlowFarneback(prevgray, gray, None, 0.5, 3, 15, 3, 5, 1.2, 0)

prevgray = gray

# End time

end = time.time()

# calculate the FPS for current frame detection

fps = 1 / (end-start)

print(f"{fps:.2f} FPS")


cv2_imshow(motion_flow(gray, flow))

cv2_imshow(motion_hsv(flow))


key = cv2.waitKey(5)

if key == ord('q'):

break

count+=1
 

Search Area Candidate Block

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!