Convert to grayscale before doing edge detection

This commit is contained in:
The Magician 2024-05-15 12:19:06 +01:00
parent 5f5eae7443
commit 54d82711eb
1 changed files with 3 additions and 2 deletions

View File

@ -20,11 +20,12 @@ int main(int argc, char** argv ) {
cv::createTrackbar(LOWER_THRESHOLD_TRACKBAR_NAME, WINDOW_NAME, &g_Canny_lower_threshold, 1000, NULL);
cv::createTrackbar(UPPER_THRESHOLD_TRACKBAR_NAME, WINDOW_NAME, &g_Canny_upper_threshold, 1000, NULL);
cv::Mat frame, cannyFrame;
cv::Mat frame, grayscaleFrame, cannyFrame;
while (true) {
cap >> frame;
cv::Canny(frame, cannyFrame, g_Canny_lower_threshold, g_Canny_upper_threshold);
cv::cvtColor(frame, grayscaleFrame, cv::COLOR_BGR2GRAY);
cv::Canny(grayscaleFrame, cannyFrame, g_Canny_lower_threshold, g_Canny_upper_threshold);
cv::imshow(WINDOW_NAME, cannyFrame);