mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-07-05 20:42:11 -07:00
9 lines
No EOL
364 B
Python
9 lines
No EOL
364 B
Python
import cv2
|
|
import numpy as np
|
|
|
|
def LinearMotionBlur(image, size, angle):
|
|
k = np.zeros((size, size), dtype=np.float32)
|
|
k[ (size-1)// 2 , :] = np.ones(size, dtype=np.float32)
|
|
k = cv2.warpAffine(k, cv2.getRotationMatrix2D( (size / 2 -0.5 , size / 2 -0.5 ) , angle, 1.0), (size, size) )
|
|
k = k * ( 1.0 / np.sum(k) )
|
|
return cv2.filter2D(image, -1, k) |