make sure you have first allocated them to the right size:
gray.allocate(w, h);
canny.allocate(w, h);
then in your update loop call:
int minVal = 60;
int maxVal = 150;
cvCanny(gray.getCvImage(), canny.getCvImage(), minVal, maxVal, 3);
canny.flagImageChanged();
the canny.flagImageChanged() is important as it tells ofxOpenCv that something was done in opencv directly to the image and it should be updated.
The min and max values define how many edges are picked up.
Definitely worth playing with those values.
Just trying out your example code, unfortunately not working, I get the following error message:
OpenCV Error: Null pointer (NULL array pointer is passed) in cvGetMat, file /Users/theo/Downloads/OpenCV-2.3.1/modules/core/src/array.cpp, line 2382
libc++abi.dylib: terminate called throwing an exception
sharedlibrary apply-load-rules all
[unknown]kill
I think you might be calling the newer API, i.e. cv::canny rather than cvCanny which is what ofxOpenCv wants? Because one wants mats and the other wants CvArr*
Hmm. Well, something must not be getting initialized because the code Theo posted looks right to me, and this is from one of my own projects that I just re-ran to sanity check that it still works: