I am trying to run this code and I got an error.
import cv2
import numpy as np
src = np.array([[10, 20, 40, 50],
[50, 20, 50, 20],
[10, 10, 30, 60],
[20, 40, 60, 70]])
dst1 = cv2.blur(src, ksize=(3, 3), borderType = cv2.BORDER_CONSTANT)
print(dst1)
dst2 = cv2.GaussianBlur(src, ksize=(3, 3), sigmaX=0, borderType = cv2.BORDER_CONSTANT)
Error ->
dst2 = cv2.GaussianBlur(src, ksize=(3, 3), sigmaX=0, borderType = cv2.BORDER_CONSTANT) cv2.error: OpenCV(4.5.5) /Users/runner/work/opencv-python/opencv-python/opencv/modules/imgproc/src/filter.simd.hpp:3045: error: (-213:The function/feature is not implemented) Unsupported combination of source format (=4), and buffer format (=5) in function 'getLinearRowFilter'
CodePudding user response:
if you construct an np.array
like that, it's (default) format is np.int32
, which is not supported. rather make it:
src = np.array([[10, 20, 40, 50],
[50, 20, 50, 20],
[10, 10, 30, 60],
[20, 40, 60, 70]], np.uint8) # <-- correct type !!!