我正在尝试对视频文件的每 10 帧进行 blob 检测,如何找到每帧的 x,y 坐标?
我是 python 和 opencv 的新手,我正在尝试使用 if 语句,该语句将每 10 帧在视频上找到一个 blob 的 x,y 坐标,我有 if 语句每 10 帧返回一次,但现在我无法弄清楚如何找到每个 x,y 坐标。我是否必须保存每个图像然后进行计算,或者有更简单的方法?
vidcap = cv2.VideoCapture('testing.mov')
count = 0
fps = int(vidcap.get(cv2.CAP_PROP_FPS))
length = int(vidcap.get(cv2.CAP_PROP_FRAME_COUNT))
while count < length:
count += 1
if count % 10 == 0:
我希望 if 语句返回每 10 帧的 x,y 坐标,以便我可以对它们进行进一步的计算
您需要
使用VideoCapture.read()
抓取每一帧并根据需要进行处理。
vidcap = cv2.VideoCapture('testing.mov')
count = 0
fps = int(vidcap.get(cv2.CAP_PROP_FPS))
length = int(vidcap.get(cv2.CAP_PROP_FRAME_COUNT))
while count < length:
count += 1
# read the next frame
ret, frame = vidcap.read()
# if read fail, then break
if not ret: break
if count % 10 == 0:
# frame contains the detail you need, do your calculation here