def create_border(frame, height, width, color):
"""Add constant border for the frame.
The original frame will be displayed at the center of the monitor
Parameters
----------
frame : OpenCV Mat
the original frame of image or video
height : int
height of the monitor
width : int
width of the monitor
color : list
the color of the border
Returns
-------
new_frame : OpenCV Mat
border added OpenCV Mat
"""
vert = height/2-frame.shape[0]/2
hor = width/2-frame.shape[1]/2
new_frame = cv2.copyMakeBorder(src=frame, top=vert, bottom=vert, left=hor,
right=hor, borderType=cv2.BORDER_CONSTANT,
value=color)
return new_frame
评论列表
文章目录