MCPcopy
hub / github.com/hacksider/Deep-Live-Cam / gpu_gaussian_blur

Function gpu_gaussian_blur

modules/gpu_processing.py:86–111  ·  view source on GitHub ↗

Drop-in replacement for ``cv2.GaussianBlur`` with CUDA acceleration. Parameters match ``cv2.GaussianBlur(src, ksize, sigmaX, sigmaY)``. When *ksize* is ``(0, 0)`` OpenCV computes the kernel size from *sigma_x*.

(
    src: np.ndarray,
    ksize: Tuple[int, int],
    sigma_x: float,
    sigma_y: float = 0,
)

Source from the content-addressed store, hash-verified

84# ---------------------------------------------------------------------------
85
86def gpu_gaussian_blur(
87 src: np.ndarray,
88 ksize: Tuple[int, int],
89 sigma_x: float,
90 sigma_y: float = 0,
91) -> np.ndarray:
92 """Drop-in replacement for ``cv2.GaussianBlur`` with CUDA acceleration.
93
94 Parameters match ``cv2.GaussianBlur(src, ksize, sigmaX, sigmaY)``.
95 When *ksize* is ``(0, 0)`` OpenCV computes the kernel size from *sigma_x*.
96 """
97 if CUDA_AVAILABLE:
98 try:
99 src_u8 = _ensure_uint8(src)
100 cv_type = _cv_type_for(src_u8)
101 ks = _ksize_odd(ksize) if ksize != (0, 0) else ksize
102
103 gauss = cv2.cuda.createGaussianFilter(cv_type, cv_type, ks, sigma_x, sigma_y)
104 gpu_src = cv2.cuda.GpuMat()
105 gpu_src.upload(src_u8)
106 gpu_dst = gauss.apply(gpu_src)
107 return gpu_dst.download()
108 except cv2.error:
109 pass
110
111 return cv2.GaussianBlur(src, ksize, sigma_x, sigmaY=sigma_y)
112
113
114# ---------------------------------------------------------------------------

Callers 8

_create_elliptical_maskFunction · 0.90
create_lower_mouth_maskFunction · 0.90
create_face_maskFunction · 0.90
create_face_maskFunction · 0.90
create_lower_mouth_maskFunction · 0.90
create_eyes_maskFunction · 0.90
create_eyebrows_maskFunction · 0.90
apply_mask_areaFunction · 0.90

Calls 3

_ensure_uint8Function · 0.85
_cv_type_forFunction · 0.85
_ksize_oddFunction · 0.85

Tested by

no test coverage detected