#include<opencv2/opencv.hpp>
#include<iostream>
using namespace cv;
using namespace std;
int g_nCurrValue = 0, g_nP = 0, g_nWay = 0;
int main()
{
Mat srcImage = imread("1.jpg");
imshow("【原图】", srcImage);
Mat grayImage;
cvtColor(srcImage, grayImage, CV_BGR2GRAY);
namedWindow("【显示窗口】", 0);
createTrackbar("Value:", "【显示窗口】", &g_nCurrValue, 255, 0);
createTrackbar("P:", "【显示窗口】", &g_nP, 100, 0);
createTrackbar("Gray/BGR", "【显示窗口】", &g_nWay, 1, 0);
Mat dstImage;
dstImage.create(grayImage.size(), grayImage.type());
char key;
Mat resImage;
while (1)
{
key = waitKey(10);
if (!g_nWay)
{
blur(grayImage, dstImage, Size(3, 3));
Canny(dstImage, dstImage, (double)g_nCurrValue, (double)((g_nCurrValue + 1) * (2 + g_nP / 100.0)), 3);
resImage = Scalar::all(0);
grayImage.copyTo(resImage, dstImage);
}
el
opencv3中Canny边缘检测-Canny函数
最新推荐文章于 2024-09-28 06:00:00 发布
本文演示了如何在OpenCV3中利用Canny函数进行边缘检测。通过读取图片并转换为灰度图,然后应用模糊处理和Canny算法,动态调整阈值和参数,最终显示检测结果。用户可以通过滑动条交互调整效果。
摘要由CSDN通过智能技术生成