I am having some issues using an image for a distance transform. Following the tutorial here:
http://docs.opencv.org/trunk/d2/dbd/tutorial_distance_transform.html
The only error that I am getting is that cv::cvtColor() is returning errors indicating that the input matrix doesn’t match the conversion type. Otherwise, I’m only getting a black image out of the distance transform, with some occasionally flickering (which really leads me to believe the input to the distance transform is somehow incorrect).
Mat bw, dist; Mat src = toCv(kinect.getDepthPixels()); cv::cvtColor(src, bw, CV_RGBA2GRAY); threshold(src, bw, 40, 255, CV_THRESH_BINARY | CV_THRESH_OTSU); distanceTransform(src, dist, CV_DIST_L2, 3); normalize(dist, dist, 0, 1., NORM_MINMAX); drawMat(dist,0,0,400,300); drawMat(src,400,0,400,300);
So, from what I understand, first I have to get my image into a format suitable for cv, so toCv() seemed to be the first step. Then I need to work on converting that matrix into a binary image. Now the rest is following the tutorial, but when I draw the dist mat, I get nothing, aside from some occasional flickering.
Does anyone know what I might be missing in this? The rest of my ofApp.cpp is below: