OpenCV에서 일부 함수에는 "오버로드 된 멤버"가 있습니다 (예 : Canny edge detection).opencv에서 "오버로드 된 멤버 함수"호출
제 질문은 : 코드에서이 오버로드 된 함수를 어떻게 호출합니까? cv2.Canny()를 호출하면 인수에 상관없이 항상 "standard Canny"이 호출됩니다.
import cv2
import numpy as np
#getting gradient of image in x and y directions
def imgradient(img, sobel):
sobelx = cv2.Sobel(img, cv2.CV_64F, 1, 0, ksize=sobel)
sobely = cv2.Sobel(img, cv2.CV_64F, 0, 1, ksize=sobel)
return (sobelx,sobely)
#open image
IMG=cv2.imread("path_to_my_image") #replace with actual path
h = IMG.shape[0]; w = IMG.shape[1]
#Canny parameters : thresholds and kernel size
upper=5; lower=5; SIZE_KERNEL=3
#computing gradients (needed as arguments for overloaded Canny)
sobels=imgradient(IMG,3)
sobelx=sobels[0]
sobely=sobels[1];
output=np.zeros((h,w))
#trying to call overloaded Canny
cv2.Canny(sobelx,sobely,output,lower,upper);
#get error "only length-1 arrays can be converted to Python scalars"
#because the code is actually calling the standard Canny (second link)
edges = cv2.Canny(IMG, lower, upper, apertureSize=SIZE_KERNEL)
#works fine, but this is not the Canny I'm looking for (read this line in Obi-Wan's voice)
: 나는 파이썬 2.7을 사용하고
여기
우분투 (14)에, 그리고 OpenCV의 3.1 (? 어쩌면이 C++에 비해,이 문제에 대한 문제가 될 것입니다 것은)는 MWE입니다 감사합니다
전화 할 것으로 예상되는 기능은 무엇입니까? – Miki
첫 번째 링크에있는 링크입니다. – Soltius
몇 가지 코드를 보여줄 수 있습니까? [mcve] – Miki