#include <stdio.h>
using namespace cv;
using namespace std;
int edgeThresh = 1;
int edgeThreshScharr=1;
Mat image, gray, blurImage, edge1, edge2, cedge;
const char* window_name1 = "Edge map : Canny default (Sobel gradient)";
const char* window_name2 = "Edge map : Canny with custom gradient (Scharr)";
static void onTrackbar(int, void*)
{
Canny(blurImage, edge1, edgeThresh, edgeThresh*3, 3);
image.copyTo(cedge, edge1);
Canny( dx,dy, edge2, edgeThreshScharr, edgeThreshScharr*3 );
image.copyTo(cedge, edge2);
}
static void help()
{
printf("\nThis sample demonstrates Canny edge detection\n"
"Call:\n"
" /.edge [image_name -- Default is fruits.jpg]\n\n");
}
const char* keys =
{
"{help h||}{@image |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 default", window_name1, &edgeThresh, 100, onTrackbar);
createTrackbar(
"Canny threshold Scharr", window_name2, &edgeThreshScharr, 400, onTrackbar);
onTrackbar(0, 0);
return 0;
}