Add sliders to adjust Canny thresholds
This commit is contained in:
parent
beed5fd92d
commit
5f5eae7443
|
@ -1,6 +1,11 @@
|
||||||
#include <opencv2/opencv.hpp>
|
#include <opencv2/opencv.hpp>
|
||||||
|
|
||||||
const std::string WINDOW_NAME = "A Scanner Darkly";
|
const std::string WINDOW_NAME = "A Scanner Darkly";
|
||||||
|
const std::string LOWER_THRESHOLD_TRACKBAR_NAME = "Canny: Lower Threshold";
|
||||||
|
const std::string UPPER_THRESHOLD_TRACKBAR_NAME = "Canny: Upper Threshold";
|
||||||
|
|
||||||
|
int g_Canny_lower_threshold = 110;
|
||||||
|
int g_Canny_upper_threshold = 300;
|
||||||
|
|
||||||
int main(int argc, char** argv ) {
|
int main(int argc, char** argv ) {
|
||||||
cv::VideoCapture cap;
|
cv::VideoCapture cap;
|
||||||
|
@ -12,12 +17,16 @@ int main(int argc, char** argv ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
cv::namedWindow(WINDOW_NAME);
|
cv::namedWindow(WINDOW_NAME);
|
||||||
|
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;
|
cv::Mat frame, cannyFrame;
|
||||||
while (true) {
|
while (true) {
|
||||||
cap >> frame;
|
cap >> frame;
|
||||||
|
|
||||||
cv::imshow(WINDOW_NAME, frame);
|
cv::Canny(frame, cannyFrame, g_Canny_lower_threshold, g_Canny_upper_threshold);
|
||||||
|
|
||||||
|
cv::imshow(WINDOW_NAME, cannyFrame);
|
||||||
|
|
||||||
char c = (char)cv::waitKey(33);
|
char c = (char)cv::waitKey(33);
|
||||||
if (c == 27) {
|
if (c == 27) {
|
||||||
|
|
Loading…
Reference in New Issue