Пример #1
0
int main()
{
	HandGesture hg;
	myImage.InitKinect();
	init(&myImage);
	while (1)
	{
		myImage.Update();
		if (!myImage.src.empty())
			break;
	}
	char c;
	//建立窗口
	namedWindow("camera", 1);//显示视频原图像的窗口

							 //捕捉鼠标
	setMouseCallback("camera", onMouse, 0);
	while (1)
	{
		myImage.Update();

		//画出矩形框
		rectangle(myImage.src, Select, Scalar(255, 0, 0), 3, 8, 0);//能够实时显示在画矩形窗口时的痕迹

																   //显示视频图片到窗口
		imshow("camera", myImage.src);
		cout << Select.x << " " << Select.y << endl;
		cout << Select.width << " " << Select.height << endl;
		//    select.zeros();
		//键盘响应
		c = (char)waitKey(20);
		if (27 == c)//ESC键
			break;
	}
	destroyWindow("camera");
	myImage.Update(Select);
	for (int i = 0; i < NSAMPLES; ++i)
	{
		avgColor[i][0] = 13;
		avgColor[i][1] = 90;
		avgColor[i][2] = 130;
	}
	initWindows();
	initTrackbars();
	while (1)
	{
		hg.frameNumber++;
		myImage.Update(Select);
		rectangle(myImage.temp, Select, Scalar(255, 0, 0), 3, 8, 0);//能够实时显示在画矩形窗口时的痕迹
		pyrDown(myImage.src, myImage.srcLR);
		blur(myImage.srcLR, myImage.srcLR, Size(3, 3));
		cvtColor(myImage.srcLR, myImage.srcLR, ORIGCOL2COL);
		produceBinaries(&myImage);
		cvtColor(myImage.srcLR, myImage.srcLR, COL2ORIGCOL);
		makeContours(&myImage, &hg, Select);
		hg.getFingerNumber(&myImage);
		showWindows(myImage);
		if (cv::waitKey(30) == char('q')) break;
	}
	destroyAllWindows();
	return 0;
}