opencv-python图片边框填充(padding)

import cv2
import numpy as np

BLACK = [0,0,0]

img = cv2.imread('/home/ogai/Pictures/pistol.jpg')

constant = cv2.copyMakeBorder(img,120,120,0,0,cv2.BORDER_CONSTANT,value=BLACK)

while (1):
    cv2.imshow('pistol',constant)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
cv2.destroyAllWindows()


你可能感兴趣的:(opencv)