[英]OpenCV Error: Unsupported format or combination of formats (Unsupported combination of input and output formats) in getRectSubPix
[英]Python, OpenCV Error, Unsupported combination of source format
我正在嘗試運行此代碼,但出現錯誤。
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)
錯誤->
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) 函數中不支持源格式 (=4) 和緩沖區格式 (=5) 的組合'getLinearRowFilter'
如果你像這樣構造一個np.array
,它的(默認)格式是np.int32
,這是不受支持的。 而是讓它:
src = np.array([[10, 20, 40, 50],
[50, 20, 50, 20],
[10, 10, 30, 60],
[20, 40, 60, 70]], np.uint8) # <-- correct type !!!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.