OEP
OEP

Reputation: 448

cv::Canny throws mismatched/unsupported formats exception

I'm doing some pretty basic edge detection stuff. Part of my implementation involves copying from a custom Image class to a cv::Mat and then copying back to an Image. I'm working with this article as my guide for getting the edge detection and contour work (not shown in the current listing) done. In this example, PerturbedBorderFilter subclasses Image. Here is what I have:

void PerturbedBorderFilter::performFilter(const Image& src)
{
  int h = src.Height(), w = src.Width();
  cv::Mat
    orig(h, w, CV_32FC3),
    cannyOutput(h,w,CV_32FC1),
    origGray(h,w,CV_32FC1);

  src.copyTo(orig);

  cv::cvtColor(orig, origGray, CV_RGB2GRAY);
  cv::blur(origGray, origGray, cv::Size(3,3));
  cv::Canny( origGray, cannyOutput, 0.1, 0.2, 3);

  copyFrom(cannyOutput);
}

I end up with this runtime error:

OpenCV Error: Unsupported format or combination of formats () in cvCanny, file /build/buildd/opencv-2.3.1/modules/imgproc/src/canny.cpp, line 67
terminate called after throwing an instance of 'cv::Exception'
  what():  /build/buildd/opencv-2.3.1/modules/imgproc/src/canny.cpp:67: error: (-210)  in function cvCanny

From what I can tell, 'origGray' and 'cannyOutput' share the same type, depth, and channel count. I am not sure what else I should check into.

If somehow the implementation of copyTo() and copyFrom() are important I can give those as well.

Some additional information:

  1. Class Image's native color space is RGB, 32-bit float depth, with values in [0,1].
  2. Currently, copyTo() copies the image upside down but intact otherwise. I figured this had to be unrelated, but who knows, maybe it is useful...

Upvotes: 0

Views: 2230

Answers (1)

Andrey Kamaev
Andrey Kamaev

Reputation: 30152

cv::Canny supports only CV_8U image depth.

Upvotes: 5

Related Questions