Below is a block-matching given for motion estimation. A code for block-matching is given under Understand this
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 useful and powerful, yet has some drawbacks! describe the main aspects based in the code given. Only rely to theory given in the lectures!
cap = cv2.VideoCapture(video_path)
suc, prev = cap.read()
prevgray = cv2.cvtColor(prev, cv2.COLOR_BGR2GRAY)
count=0
while count<=20:
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
Computer Architecture Fundamentals And Principles Of Computer Design
ISBN: 9781032097336
2nd Edition
Authors: Joseph D. Dumas II