opencv cvCreateTrackbar的使用

#include 
#include 
#include
using namespace std;
using namespace cv;

int elementSize = 3;
const char windowName[] = "Image";
Mat srcImg;
Mat dstImg;

void imageProcess(int)
{
	Mat kernel = getStructuringElement(MORPH_RECT, Size(elementSize * 2+1, elementSize * 2+1), Point(-1, -1));
	dilate(srcImg, dstImg, kernel, Point(-1, -1));
	imshow(windowName, dstImg);
	return;
}

int main()
{
	srcImg = imread("test.jpg");
	if (srcImg.empty())
	{
		cout << "Image load failed" << endl;
		return -1;
	}
	imshow("InputImage", srcImg);
	namedWindow(windowName);//必须先创造窗口
	cvCreateTrackbar("size", windowName, &elementSize, 255, imageProcess);
	imageProcess(0);
	waitKey(0);
	return 0;
}

 

你可能感兴趣的:(opencv)