0

How can I set an opencv Mat image object into a C++/CLI label? I have tried the following.

 Mat image = imread("C:/Users/Public/Pictures/Sample Pictures/Desert.jpg");
 imageLabel->BackgroundImage = image;

But it is simply generating errors.

Error   1   error C2664: 'void System::Windows::Forms::Control::BackgroundImage::set(System::Drawing::Image ^)' : cannot convert parameter 1 from 'cv::Mat' to 'System::Drawing::Image ^'   c:\users\yohan\documents\visual studio 2010\projects\opencvfinaltest\opencvfinaltest\Form1.h    144 1   OpenCVFinalTest

Any ideas?

PeakGen
  • 21,894
  • 86
  • 261
  • 463
  • What kind of errors you are getting? – praks411 May 14 '13 at 08:19
  • I don't think you can directly assign image to imageLabel->BackgroundImage. Those two are different and you will need to convert Mat into image. I think image is BitMap image so you will need to convert your Mat image to BitMap – praks411 May 14 '13 at 08:29
  • http://msdn.microsoft.com/en-us/library/stf701f5.aspx – LovaBill May 14 '13 at 09:12
  • @Willy: That is loading an image from a file. That is not what I need. – PeakGen May 14 '13 at 09:16
  • 1
    Then, your job is to fully understand both objects and provide a custom '=' operator. – LovaBill May 14 '13 at 11:08
  • possible duplicate of [How to display a cv::Mat in a Windows Form application?](http://stackoverflow.com/questions/9580397/how-to-display-a-cvmat-in-a-windows-form-application) – mevatron May 14 '13 at 17:52

0 Answers0