简体   繁体   中英

Python, OpenCV Error, Unsupported combination of source format

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'

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM