I want to use edge detection algorithms from opencv library. Here is a piece of python code:
from opencv.cv import *
from opencv.highgui import *
img = cvLoadImage ('xxx.jpg')
cvNamedWindow ('img')
cvShowImage ('img', img)
cvWaitKey ()
canny = cvCreateImage (cvSize (img.width, img.height), 8, 3)
cvCanny (img, canny, 50, 200)
harris = cvCreateImage (cvSize (img.width, img.height), 8, 3)
cvCornerHarris (img, harris, 5, 5, 0.1)
Loading and showing image works fine, but canny and harris transformations fail.cvCanny
fails with:
RuntimeError: openCV Error:
Status=Unsupported format or combination of formats
function name=cvCanny
error message=
file_name=cv/cvcanny.cpp
line=72
and cvCornerHarris
fails with this error:
RuntimeError: openCV Error:
Status=Assertion failed
function name=cvCornerHarris
error message=src.size() == dst.size() && dst.type() == CV_32FC1
file_name=cv/cvcorner.cpp
line=370
From this messages I can infer that loaded image has invalid format. But I don't understand how to convert it.
Here are values of some img
fields:
img.type = 1111638032
img.nChannels = 3
img.depth = 8