OpenCV+Python之cv2.error: OpenCV(4.1.1) C:\projects\opencv-python\opencv\modules\imgproc\src\smooth.d

Python Tkinter own GUI window generated by the module, when setting the parameters of the Gaussian filter, to create the text input box alone, respectively two control ksize sigmaX and size and standard deviation of the Gaussian kernel sigmaY found not simply input.

从而出现错误cv2.error: OpenCV(4.1.1) C:\projects\opencv\python\opencv\modules\imgproc\src\smooth.dispatch.cpp:189: error: (-215:Assertion failed) ksize.width > 0 && ksize.width % 2 == 1 && ksize.height > 0 && ksize.height % 2 == 1 in function ‘cv::createGaussianKernels’。

Gaussian filtering function: in OpenCV, the Gaussian filter function is implemented cv2.GaussianBlur (), the function syntax is:
DST = cv2.GaussianBlur (the src, ksize, Sigmax, sigmaY, borderType)

Typically sigmaY = 0, and the convolution kernel is sigmaX (X axis direction) of the standard deviation in the horizontal direction, sigmaY convolution kernel is standard in the vertical direction (Y axis direction) of the difference. When sigmaY = 0, only the calculated value Sigmax, when sigmaX = 0, then the function will automatically calculate the specific value; if both are 0, the to be calculated and obtained by ksize.width ksize.height.
The formula is:
①sigmaX = 0.3 × [(. 1-ksize.width) × 0.5-1] + 0.8
②sigmaY = 0.3 × [(. 1-ksize.height) × 0.5-1] + 0.8

Conclusion: 1: Order sigmaX = 0, then the function directly calculate specific values.
2: function defined by the equation custom binding Ksize (must be odd) sigma value is calculated from the defined substituted into the Gaussian filter function, to replace the value calculated by the system automatically.

Released three original articles · won praise 0 · Views 126

Guess you like

Origin blog.csdn.net/weixin_45645281/article/details/104468846
Recommended