OpenCV相机进纸显示在Visual c + + CLR PictureBox中 [英] OpenCV camera feed display in Visual c++ CLR PictureBox

查看:71
本文介绍了OpenCV相机进纸显示在Visual c + + CLR PictureBox中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要得到我的相机饲料中视觉显示在图片框c ++ CLR应用程序。我应该在myform.h中的pictureBox回调中包含什么?
我应该在.cpp文件中包含哪些内容?



感谢您的帮助。

解决方案

您好fMax6,


感谢您在此处发帖。


>>我想要在Visual c + + CLR应用程序中的PictureBox中显示我的相机提要。我应该在myform.h中的pictureBox回调中包含什么?我应该在.cpp文件中包含什么内容?


对于这种情况,你可以像这样在Winform控件中绘制你的cv图像。


< pre class ="prettyprint"> void DrawCVImage(System :: Windows :: Forms :: Control ^ control,cv :: Mat& colorImage)
{
System :: Drawing :: Graphics ^ graphics = control - >的createGraphics();
System :: IntPtr ptr(colorImage.ptr());
。系统::绘图::位图^ B = gcnew系统::绘图::位图(colorImage.cols,colorImage.rows,colorImage.step,系统::绘图::成像::的PixelFormat :: Format24bppRgb,PTR );
System :: Drawing :: RectangleF rect(0,0,control-> Width,control-> Height);
graphics-> DrawImage(b,rect);
删除图形;
}

或者将你的cv图像转换为位图对象,然后在你的图片框中绘图。

 Mat matImage = imread(" image.bmp",CV_LOAD_IMAGE_COLOR); 
cvtColor(matImage,matImage,CV_BGRA2RGBA);

HBITMAP = CreateBitmap(matImage.cols,matImage.rows,1,32,matImage.data);


希望这你可以帮助。


最诚挚的问候,


Baron Bi




I want to get my camera feed displayed in the PictureBox in Visual c++ CLR application. What should I include in the pictureBox callback in myform.h? What should I include in the .cpp file?

Thank you for your help.

解决方案

Hi fMax6,

thanks for posting here.

>>I want to get my camera feed displayed in the PictureBox in Visual c++ CLR application. What should I include in the pictureBox callback in myform.h? What should I include in the .cpp file?

For this case, you could draw your cv image in Winform control like this.

void DrawCVImage(System::Windows::Forms::Control^ control, cv::Mat& colorImage)
{
    System::Drawing::Graphics^ graphics = control->CreateGraphics();
    System::IntPtr ptr(colorImage.ptr());
    System::Drawing::Bitmap^ b  = gcnew System::Drawing::Bitmap(colorImage.cols,colorImage.rows,colorImage.step,System::Drawing::Imaging::PixelFormat::Format24bppRgb,ptr);
    System::Drawing::RectangleF rect(0,0,control->Width,control->Height);
    graphics->DrawImage(b,rect);
    delete graphics;
}

Or convert your cv image to bitmap object, then draw in your picturebox.

Mat matImage = imread("image.bmp", CV_LOAD_IMAGE_COLOR);
cvtColor(matImage, matImage, CV_BGRA2RGBA);

hBitmap = CreateBitmap(matImage.cols, matImage.rows, 1, 32, matImage.data);

Hope this could be help of you.

Best Regards,

Baron Bi


这篇关于OpenCV相机进纸显示在Visual c + + CLR PictureBox中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆