I am using python-openCV. When using the Sobel edge detection I get the following assertion error:
src.size() == dst.size() && src.channels() == dst.channels() && ((src.depth() == CV_8U && (dst.depth() == CV_16S || dst.depth() == CV_32F)) || (src.depth() == CV_32F && dst.depth() == CV_32F))
I create the dest
using CreateImage()
and it has same size and channels as src
. Also the depth of both src and dest is IPL_DEPTH_8U. I also tried loading image using LoadImageM()
so that the constants are of kind CV_*
but that didn't help.
I also happen to find out that IPL_DEPTH_8U == CV_8U
is false
.
I found the solution a bit tricky for novices to openCV:
src = cv.LoadImageM('src.png', cv.CV_LOAD_IMAGE_GRAYSCALE)
dest = cv.CreateMat(src.height, src.width, cv.CV_16S)
cv.Sobel(src, dest, 1, 1)
The important thing to note is that the image formats required for operations are not clearly documented in API references and one should pay very careful attention to errors generated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With