OpenCV 通过 MFC 的 Picture Control 控件操作图像
来源:互联网 发布:阿里云推荐码在哪里看 编辑:程序博客网 时间:2024/05/16 14:40
如果希望对显示在MFC Picture Control 控件里的图像进行操作,比如画线画点之类的,可以利用 OpenCV 结合 MFC 本身的鼠标响应函数来实现。
如何将图像显示到 Picture Control 控件不谈,本文是采用的这篇博客所介绍的方法实现的。 点击打开链接
给对话框添加 WM_LBUTTONDOWN 鼠标左键点击消息,在消息响应函数中添加如下代码:
void CMFCOpenCVShowDlg::OnLButtonDown(UINT nFlags, CPoint point){CRect myshowwinrect;GetDlgItem(IDC_STATIC_SHOW)->GetWindowRect(myshowwinrect);//获得屏幕坐标ScreenToClient(&myshowwinrect);//转到客户区相对坐标if (point.x >= myshowwinrect.left && point.x <= myshowwinrect.right && point.y >= myshowwinrect.top && point.y <= myshowwinrect.bottom)//鼠标在Picture Control 控件上进行了单击操作{int img_x = (double)img->width*(double)(point.x - myshowwinrect.left) / (double)myshowwinrect.Width();//计算鼠标点击横坐标相对图片上的横位置int img_y = (double)img->height*(double)(point.y - myshowwinrect.top) / (double)myshowwinrect.Height();int changepoint = img_y*img->widthStep / sizeof(uchar)+img_x*img->nChannels;//将图片的相应点标记为白色img->imageData[changepoint+0] = 255;img->imageData[changepoint+1] = 255;img->imageData[changepoint+2] = 255;drawpic(img, IDC_STATIC_SHOW);}CDialogEx::OnLButtonDown(nFlags, point);}到此,鼠标在 Picture Control 控件上点击,则会在图像相应位置处画出一个白点。
1 0
- OpenCV 通过 MFC 的 Picture Control 控件操作图像
- MFC Picture Control显示OpenCV图像
- OpenCV 利用MFC的Picture控件显示和处理图像
- OpenCV 利用MFC的Picture控件显示和处理图像
- OpenCV导入图像显示到MFC的PICTURE控件
- OpenCV 利用MFC的Picture控件显示和处理图像
- OpenCV 利用MFC的Picture控件显示和处理图像
- 【opencv/mfc】PICTURE控件显示图像
- control picture 大小如何设定 mfc MFC中怎么通过程序改变Picture Control控件的大小
- 6.MFC Picture Control控件的使用.
- VS2012中MFC使用Picture Control显示OpenCV处理的图像
- MFC的picture control响应鼠标操作
- vs2013+opencv Mat图像显示到picture control控件
- 利用MFC中的picture control 控件显示图像
- MFC:利用CImage动态加载图像,无需Picture Control控件
- 利用MFC中的picture control 控件显示图像
- MFC中 利用OpenCv显示图片到Picture Control控件
- MFC中基于OpenCV实现Picture Control控件成像方法
- C++文件读写详解(ofstream,ifstream,fstream)
- FFMPEG架构分析
- linux strsep字符串分割
- 谢谢你,不曾离开我
- mysql 中函数的混合使用
- OpenCV 通过 MFC 的 Picture Control 控件操作图像
- 美国“鼠女”放生数千老鼠 旧金山成鼠城
- Creating, detaching, re-attaching, and fixing a SUSPECT database
- 项目管理能力提升四要素
- Mfc中设置按钮不可用
- jquery 登陆窗口用户名、密码显示提示框
- 3.5 MonoForAndroid用户人机界面-取得手机屏幕大小
- 65种GPU性能测试,AMD开源驱动领先!
- MySQL学习笔记之二十一 用户的权限