An example on using the canny edge detector
#include <stdio.h>
int edgeThresh = 1;
Mat image, gray, edge, cedge;
static void onTrackbar(int, void*)
{
Canny(edge, edge, edgeThresh, edgeThresh*3, 3);
}
static void help()
{
printf("\nThis sample demonstrates Canny edge detection\n"
"Call:\n"
" /.edge [image_name -- Default is ../data/fruits.jpg]\n\n");
}
const char* keys =
{
"{@image |../data/fruits.jpg|input image name}"
};
int main( int argc, const char** argv )
{
help();
string filename = parser.get<string>(0);
if(image.empty())
{
printf("Cannot read image file: %s\n", filename.c_str());
help();
return -1;
}
cedge.
create(image.size(), image.type());
createTrackbar(
"Canny threshold",
"Edge map", &edgeThresh, 100, onTrackbar);
onTrackbar(0, 0);
return 0;
}