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. iOS开发常用输入校验

    1.数字字符校验 #define NUMBERSPERIOD @"0123456789." - (BOOL)CheckInput:(NSString *)string { NSCh ...

  2. 基于Python的Grib数据可视化

    http://www.cnblogs.com/kallan/p/5160017.html

  3. WinDriver&PCIE

    1.安装VS2012 安装VS2012略过,主要用它来做数据传输应用程序的,WINDRIVER提供了一系列API接口,方便了用户,使用户能直接进入用户态的编程,因为内核态的编程它已做好,不需要进行修改 ...

  4. 用Windows Live Writer发来

    文字     package com.myeclipseide.example.myblog.secure; import com.opensymphony.xwork2.ActionSupport; ...

  5. Unity3d自定义脚本模板

    这是一个小技巧,打开Unity安装目录,如: C:\Program Files (x86)\Unity\Editor\Data\Resources\ScriptTemplates /* * * Tit ...

  6. CalendarUtil

    package ch.makery.address.util; import java.text.ParseException; import java.text.SimpleDateFormat; ...

  7. POJ 2185 Milking Grid(KMP)

    Milking Grid Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 4738   Accepted: 1978 Desc ...

  8. Java IO (1) - InputStream

    Java IO (1) - InputStream 前言 JavaIO一共包括两种,一种是stream,一种是reader/writer,每种又包括in/out,所以一共是四种包.Java 流在处理上 ...

  9. jpa仓库接口

    可以使用的仓库接口有: Repository: 是 Spring Data的一个核心接口,它不提供任何方法,开发者需要在自己定义的接口中声明需要的方法. CrudRepository: 继承Repos ...

  10. [ASP.NET MVC] Child actions are not allowed to perform redirect

    我在Umbraco平台下,用MVC(SurfaceController)开发时,遇到这个问题 MemberEdit是一个partial View [HttpGet] [ActionName(" ...