I'm using OpenCV 2.4.0 python bindings and I found that when calculating a laplacian of an image I get different results with the cv2 API from the cv2.cv API.
if I use cv2 API:
im_laplacian = cv2.Laplacian(im_gray, cv2.IPL_DEPTH_32F, ksize = 3)
im_laplacian is always uint8 (missing sign), and ddepth has to be IPL_DEPTH_32F or IPL_DEPTH_64F, if I try IPL_DEPTH_16S or IPL_DEPTH_32S I get an error:
"OverflowError: Python int too large to convert to C long"
if I use cv2.cv API:
cvgray = cv.fromarray(im_gray)
im_laplacian2 = cv.CreateImage(cv.GetSize(cvgray), cv.IPL_DEPTH_16S, 1)
cv.Laplace(cvgray, im_laplacian2, 3)
as expected I get a signed laplacian, this is the same result as in the C++ API. If I do:
im_laplacian2_scaled = cv.CreateImage(cv.GetSize(cvgray), 8, 1)
cv.ConvertScaleAbs(dst, im_laplacian2_scaled, 1, 0)
im_laplacian2_scaled is still different from im_laplacian calculated with cv2 API
In my particular case I think I can get away with the cv2 output, but I'm puzzeled, shouldn't all APIs produce the same output? do they use different algorithms? or maybe the cv2 python bindings don't correspond to individual C++ functions but some combination of them?