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. Iplimagetype.

Declare Iplimage variable:

IplImage* frame; 

Here. Create new Bitmap image from frame properties like widthheightwidthstep. 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, Mattype.

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 and with 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 to picturebox image
  • Learn how to assign Mat to picturebox image

References

  1. http://opencv.org/
  2. http://en.wikipedia.org/wiki/OpenCV
  3. http://docs.opencv.org/

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的更多相关文章

  1. easyUI datagrid view扩展

    //扩展easyuidatagrid无数据时显示界面 var emptyView = $.extend({}, $.fn.datagrid.defaults.view, { onAfterRender ...

  2. opencv 61篇

    (一)--安装配置.第一个程序 标签: imagebuildincludeinputpathcmd 2011-10-21 16:16 41132人阅读 评论(50) 收藏 举报  分类: OpenCV ...

  3. 设备管理 USB ID

    发现个USB ID站点,对于做设备管理识别的小伙伴特别实用 http://www.linux-usb.org/usb.ids 附录: # # List of USB ID's # # Maintain ...

  4. SIFT特征点检测学习一(转载)

    新手上路,先转载学习tornadomeet的博客:http://www.cnblogs.com/tornadomeet/archive/2012/08/16/2643168.html 特征点检测学习_ ...

  5. SAP T CODE : Description (Program)

    SAP T CODE : Description (Program) V : Quickstart RKCOWUSL (RKCOWUSL)V+01 : Create Sales Call (SAPMV ...

  6. 知乎上有一个问题“在mfc框架中,有上面方法能直接将opencv2.0库中的Mat格式图片传递到Picture Control”中显示?

    一直以来,我使用的方法都是shiqiyu在opencvchina上面提供的引入directshow,并且采用cvvimage和cameraDs的方法.这个方法虽然在xp/win7/win8下面都能够成 ...

  7. MFC HTML的img显示摄像头图像

    cv::VideoCapture vc; vc.open(0); cv::Mat temp; vc.read(temp); //cv::resize(temp,temp,cv::Size(320,24 ...

  8. OpenCV学习笔记(二) cv::Mat

    部分内容转自:OpenCV Tuturial,ggicci 在OpenCV Tuturial中可查看Mat的初始化与打印方法. Mat本质上是由两个数据部分组成的类: 矩阵头(包含矩阵尺寸,存储方法, ...

  9. C++面向程序设计(第二版)课后习题答案解析

    最近没什么心情整理零散的知识点,就整理一下第四章的课后习题答案. 1.定义一个复数类Complex,重载运算符“+”,使之能用于复数的加法运算.将运算符函数重载为非成员函数,非友元的普通函数.编程序, ...

随机推荐

  1. select XXX into 和 Insert into XXX select

    检索一个表中的部分行存到另一张表中. 一 .另外的那张表没有新建的时候,使用 select XXX into,创建的表与原表有相同的列名和类型: select * into Departments_C ...

  2. 总结的Ubuntu的若干小知识

    一.默认开机直接进入到Ubuntu命令行界面 安装Ubuntu后,开机会默认进入到图形界面,如果不喜欢图形界面,可以通过修改配置,直接进入命令行界面,还行节省100多兆的内存空间.具体方法如下: 修改 ...

  3. HDU 5806 NanoApe Loves Sequence Ⅱ (模拟)

    NanoApe Loves Sequence Ⅱ 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5806 Description NanoApe, t ...

  4. 宏_CRTIMP分析

    CRTIMP是C run time implement的简写,C运行库的实现的意思. 作为用户代码,不应该使用这个东西. 该参数决定 运行时 到底用 动态链接库 还是静态链接 #ifndef _CRT ...

  5. Base64.java 工具类

    import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOExceptio ...

  6. 贪心-poj-2437-Muddy roads

    题目链接: http://poj.org/problem?id=2437 题目意思: 给n个区间,每次可以用长度为L的棒A去覆盖,求将所有区间覆盖至少需要几次.给的区间不覆盖. 解题思路: 简单贪心. ...

  7. Linux下移植pjsip,使用QT开发

    1.移植pjsip env:fedora14 arm-linuc-gcc:gcc version 4.5.1 (ctng-1.8.1-FA) #./configure \ CC=arm-linux-g ...

  8. freemarker截取字符串subString

    转至:http://fengzhijie1103.iteye.com/blog/1142918 freemarker截取字符串其实和JAVA语法是差不多了,也有substring 方法       如 ...

  9. ID生成器的一种可扩展实现方案

    ID生成器主要为了解决业务程序生成记录ID的场景,而一个好的ID生成器肯定要满足扩展性好.并发性好的特点,本文下面介绍一种满足上述特点的实现方案. 此方案的核心思想是:每次需要扩容机器时,将每个节点维 ...

  10. time_t转换为DateTime

    最近解析文华财经的日线数据. 取得的第一个字段是日期,为time_t格式(long)的. 因为是用C#来写解析程序,所以要转换为DateTime的. time_t是世界时间,要转换为本地时间,所以要加 ...