OPENCV鼠标点击建立回调函数示例+C++调用Windows 控制台cmd并且返回调用结果示例--函数_popen()与fgets()

void fun2(int event,int x, int y, int flags,void *)
{
	if(event==EVENT_LBUTTONDOWN||event==EVENT_LBUTTONUP)
	AfxMessageBox(L"hello nice to meet you");
	if (event == EVENT_RBUTTONDOWN)
	{
		string str = "ipconfig /all";
		FILE* f;
		f = _popen(str.c_str(),"r");
		string result;
		char buffer[2000];
		while (fgets(buffer, sizeof(buffer), f))
		{
			for (int i = 0; i < sizeof(buffer); i++)
			{
				if (buffer[i]=='v'&&buffer[i-1]=='P'&&buffer[i-2]=='I')
				{
					result += buffer;

				}

			}
		}
	}
}
void CrelaxMyFriendDlg::OnBnClickedOk()
{
	hdc = this->GetDC()->GetSafeHdc();
	// TODO: 在此添加控件通知处理程序代码
	string addrImg = "c:/Users/actorsun/Pictures/";
	string addrVideo = "c:/Users/actorsun/Videos/";
	string addr = addrImg + "1.png";
	Mat relax, positive, gray;
	relax = Mat(900, 1500, CV_8UC3, Scalar(0, 0, 255));
	namedWindow("good");
	imshow("good", relax);
	setMouseCallback("good", fun2);


	//在运动物体上面画个矩形框,像我的监控一样
}

你可能感兴趣的:(机器人,opencv,c++)