How to Display Image In Picturebox in VC++ from Iplimage and Mat
Introduction
This tip/trick will be useful to OpenCV programmers, who wish to use Windows Form application under Visual C++. This tip helps programmers to use Windows function with OpenCV library. The following tip shows how to assigniplimage
and mat variable to picturebox image.
Assign Iplimage to Picturebox Image
In this part, it shows how to assign iplimage
to picturebox image. First of all, declare the frame pointer. Iplimage
type.
Declare Iplimage
variable:
IplImage* frame;
Here. Create new Bitmap
image from frame properties like width
, height
, widthstep
. Set image data from frameimagedata
.
Process the PictureBox
.
pictureBox1->Image = gcnew System::Drawing::Bitmap
(frame->width,frame->height,frame->widthStep,
System::Drawing::Imaging::PixelFormat::Format24bppRgb,(System::IntPtr) frame->imageData);
pictureBox1->Refresh();
Assign Mat to Picturebox Image
In this part, it shows how to assign Mat to picturebox
image. First of all, declare the frameDetected
variable, Mat
type.
Declare Mat
variable.
Mat frameDetected;
Here. Create graphics of picturebox
. Then create new Bitmap image from frameDetected
properties like cols, rows, step. Then create Rectangle
with x
and y
with 0
value and width
and height
with picturebox height
,width
respectively. Then rectangle assign to previous initialized graphics object.
Process the PictureBox
:
System::Drawing::Graphics^ graphics2 = pictureBox3->CreateGraphics();
System::IntPtr ptr2(frameDetected.ptr());
System::Drawing::Bitmap^ b2 = gcnew System::Drawing::Bitmap(frameDetected.cols,
frameDetected.rows,frameDetected.step,System::Drawing::Imaging::PixelFormat::Format24bppRgb,ptr2);
System::Drawing::RectangleF rect2(0,0, pictureBox3->Width,pictureBox3->Height);
graphics2->DrawImage(b2,rect2);
Points of Interest
- Learn how to assign
iplimage
topicturebox
image - Learn how to assign
Mat
topicturebox
image
References
Sorry
Sorry for my English. If you notice errors or can suggest a more correct version, please let me know.
How to Display Image In Picturebox in VC++ from Iplimage and Mat的更多相关文章
- easyUI datagrid view扩展
//扩展easyuidatagrid无数据时显示界面 var emptyView = $.extend({}, $.fn.datagrid.defaults.view, { onAfterRender ...
- opencv 61篇
(一)--安装配置.第一个程序 标签: imagebuildincludeinputpathcmd 2011-10-21 16:16 41132人阅读 评论(50) 收藏 举报 分类: OpenCV ...
- 设备管理 USB ID
发现个USB ID站点,对于做设备管理识别的小伙伴特别实用 http://www.linux-usb.org/usb.ids 附录: # # List of USB ID's # # Maintain ...
- SIFT特征点检测学习一(转载)
新手上路,先转载学习tornadomeet的博客:http://www.cnblogs.com/tornadomeet/archive/2012/08/16/2643168.html 特征点检测学习_ ...
- SAP T CODE : Description (Program)
SAP T CODE : Description (Program) V : Quickstart RKCOWUSL (RKCOWUSL)V+01 : Create Sales Call (SAPMV ...
- 知乎上有一个问题“在mfc框架中,有上面方法能直接将opencv2.0库中的Mat格式图片传递到Picture Control”中显示?
一直以来,我使用的方法都是shiqiyu在opencvchina上面提供的引入directshow,并且采用cvvimage和cameraDs的方法.这个方法虽然在xp/win7/win8下面都能够成 ...
- MFC HTML的img显示摄像头图像
cv::VideoCapture vc; vc.open(0); cv::Mat temp; vc.read(temp); //cv::resize(temp,temp,cv::Size(320,24 ...
- OpenCV学习笔记(二) cv::Mat
部分内容转自:OpenCV Tuturial,ggicci 在OpenCV Tuturial中可查看Mat的初始化与打印方法. Mat本质上是由两个数据部分组成的类: 矩阵头(包含矩阵尺寸,存储方法, ...
- C++面向程序设计(第二版)课后习题答案解析
最近没什么心情整理零散的知识点,就整理一下第四章的课后习题答案. 1.定义一个复数类Complex,重载运算符“+”,使之能用于复数的加法运算.将运算符函数重载为非成员函数,非友元的普通函数.编程序, ...
随机推荐
- <转>数据库设计的三大范式
为了建立冗余较小.结构合理的数据库,设计数据库时必须遵循一定的规则.在关系型数据库中这种规则就称为范式.范式是符合某一种设计要求的总结.要想设计一个结构合理的关系型数据库,必须满足一定的范式. 在实际 ...
- 浏览器URL传参最大长度问题
这几天为解决一个BUG头疼了一段时间,BUG现象如下: 一个选择人员的选择控件,当选择多个人时(50多个的时候),返回没有错误现象,而再一次打开的时候就报404错误.看到这个错误非常纳闷,无法下手,只 ...
- C++ static内容小结
C++中static总结比较好的博客:http://blog.csdn.net/laixingjun/article/details/9139839 http://blog.csdn.net/xiaj ...
- 理解CSS盒子模型
概述 网页设计中常听的属性名:内容(content).填充(padding).边框(border).边界(margin),CSS盒子模型都具备这些属性,也主要是这些属性. 这些属性我们可以把它转移到我 ...
- MVC3.0在各个版本IIS中的部署
概述: 最近在做一个MVC 3的项目,在部署服务器时破费了一番功夫,特将过程整理下来,希望可以帮到大家! 本文主要介绍在IIS5.1.IIS6.0.IIS7.5中安装配置MVC 3的具体办法! 正文: ...
- ExcelUtils 导表实例
@RequestMapping("/dealer/chargebook/exportv.htm") public void getChargeBookList(int epm ...
- <Chapter 2>2-2-1.用户偏好模式(The User Preferences Pattern)
在这个模块中我们要创建的应用是一个简单的钟.当一个用户访问这个网站时,这个应用会更具服务器的系统时间显示当前的时间.默认情况下,这个应用使用标准国际时间(UTC)时区显示当前时间.用户可以使用Goog ...
- Python相关工具清单[持续更新]
SublimeJEDI : awesome Python autocompletion with SublimeText. Awesome Python : A curated list of awe ...
- 【Hadoop代码笔记】Hadoop作业提交之JobTracker接收作业提交
一.概要描述 在上一篇博文中主要描述了JobTracker接收作业的几个服务(或功能)模块的初始化过程.本节将介绍这些服务(或功能)是如何接收到提交的job.本来作业的初始化也可以在本节内描述,但是涉 ...
- 引擎 innodb 与 myisam 的区别
使用innodb引擎 , 查询800万数据的统计: 将innodb 引擎 改成 MyISAM引擎: alter table test_count engine = MyISAM;