import cv2 as cv
import matplotlib.pyplot as plt
import matplotlib.patches as patches
plt.ion()
plt.figure()
def main():
cap = cv.VideoCapture("./data/testvideo1.mp4")
sz = (int(cap.get(cv.CAP_PROP_FRAME_WIDTH)), int(cap.get(cv.CAP_PROP_FRAME_HEIGHT)))
fourcc = cv.VideoWriter_fourcc('m', 'p', '4', 'v')
video_write = cv.VideoWriter("./data/1.mp4", fourcc, 30, sz, True)
frame_cnt = 1
while True:
ret, frame = cap.read()
if not ret:
break
a = (2, 3)
b = (140, 160)
cv.rectangle(frame, a, b, (255, 0, 0), 2, )
rect = patches.Rectangle(a, b[0]-a[0], b[1]-a[1], linewidth=1, edgecolor='black', facecolor='none', linestyle='dotted')
cv.imshow('Demo', frame)
cv.imwrite("./image/{}.jpg".format(frame_cnt), frame)
frame_cnt = + 1
cv.waitKey(100)
plt.imshow(frame[:, :, ::-1])
currentAxis = plt.gca()
currentAxis.add_patch(rect)
plt.pause(0.01)
if __name__ == "__main__":
main()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)