Min
Min

Reputation: 51

Python, OpenCV Error, Unsupported combination of source format

I am trying to run this code:

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)

And I got an 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'

Upvotes: 5

Views: 5279

Answers (1)

berak
berak

Reputation: 1374

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 !!!

Upvotes: 3

Related Questions