Commit 953ee6c2 authored by Gihan Jayatilaka's avatar Gihan Jayatilaka

landmark

parent 50c82b92
import cv2
import numpy as np
import sys
if __name__ == '__main__':
print("insert-landmark-frames-to-video.py inputVid.mp4 0 0 0 outputVid.mp4 60")
print("insert-landmark-frames-to-video.py inputVid.mp4 B G R outputVid.mp4 frameRate")
print("insert-landmark-frames-to-video.py [1] [2 3 4] [5] [6]")
INPUT_VIDEO_FILE=sys.argv[1]
R=int(sys.argv[2])
G=int(sys.argv[3])
B=int(sys.argv[4])
OUTPUT_VIDEO_FILE=sys.argv[5]
FRAME_RATE=int(sys.argv[6])
vidIn=cv2.VideoCapture(INPUT_VIDEO_FILE)
ret,fr=vidIn.read()
if not ret:
print("Something is worng")
quit(0)
H=fr.shape[0]
W=fr.shape[1]
vidIn.release()
vidIn=cv2.VideoCapture(INPUT_VIDEO_FILE)
vidOut=cv2.VideoWriter(OUTPUT_VIDEO_FILE,cv2.VideoWriter_fourcc('M','J','P','G'),FRAME_RATE,(W,H))
landmarkFrame=np.zeros(shape=(H,W,3),dtype=np.uint8)
landmarkFrame[:,:,0]=R
landmarkFrame[:,:,1]=G
landmarkFrame[:,:,2]=B
frCount=0
allFrCount=0
while vidIn.isOpened():
ret,fr=vidIn.read()
if not ret:
break
else:
vidOut.write(landmarkFrame)
cv2.imshow("col",fr)
cv2.waitKey(10)
cv2.imshow("col",landmarkFrame)
cv2.waitKey(10)
allFrCount+=1
vidOut.write(fr)
allFrCount+=1
frCount+=1
vidOut.release()
vidIn.release()
print("FINISHED writing {} video and {} total frames to {}".format(frCount,allFrCount,OUTPUT_VIDEO_FILE))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment