Integration of WinForm and Visual C++
-
Dear all, I might ask for help regarding this issue in the list, because I´m pretty sure someone dealt with this in the past. I´ve searched in this forum. There is one similar question, but the solution involves MFC (which does not apply for me) I have coded an application for Visual C++ Express. It basically consists on a VC++ Form and a OpenCV windows displaying video. At some point I recollect the information from the OpenCV Video Window, and I reflect it on the VC++ Form. After finishing the first draft of the application, I was considering improving the interface. The first natural step will be to integrate both OpenCV Window and VC++ Form. I´ve checking the code for cvNamedWindow, and it uses Win32 API (as expected). I´ve looking on the internet, and most of the solutions came by using MFC (which I do not use) or moving to .NET (so late). Does anyone of you have faced this problem? Does anyone has solutions or guidances? Best, Kikoso
-
Dear all, I might ask for help regarding this issue in the list, because I´m pretty sure someone dealt with this in the past. I´ve searched in this forum. There is one similar question, but the solution involves MFC (which does not apply for me) I have coded an application for Visual C++ Express. It basically consists on a VC++ Form and a OpenCV windows displaying video. At some point I recollect the information from the OpenCV Video Window, and I reflect it on the VC++ Form. After finishing the first draft of the application, I was considering improving the interface. The first natural step will be to integrate both OpenCV Window and VC++ Form. I´ve checking the code for cvNamedWindow, and it uses Win32 API (as expected). I´ve looking on the internet, and most of the solutions came by using MFC (which I do not use) or moving to .NET (so late). Does anyone of you have faced this problem? Does anyone has solutions or guidances? Best, Kikoso
So are you trying to place the OpenCV window as a child in the Form? How this is done with Window Media Player is that WMP has an activex control which can be placed in a form and instantiated. The activex exposes some methods that can be used to control the video that is played. Check if OpenCV has such an activex control. If not you should check the OpenCV documentation on how this can be done. If it is possible then I'm sure it is documented.
«_Superman_» I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) -
So are you trying to place the OpenCV window as a child in the Form? How this is done with Window Media Player is that WMP has an activex control which can be placed in a form and instantiated. The activex exposes some methods that can be used to control the video that is played. Check if OpenCV has such an activex control. If not you should check the OpenCV documentation on how this can be done. If it is possible then I'm sure it is documented.
«_Superman_» I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++)Hello Superman, and thank you for your response. OpenCV has not such an ActiveX. Just provide the basics image analyzing algorithms, and a basic Windows system based on Win32 API. After some days checking for it on the internet I have not found a response. There are some clues using MFC, but using just the standard Forms of Visual C++ doesn´t seem possible (or at least obvious). Nevermind, thank you for your interest. If a get a solution I will share it here (and if anybody has more clues, I´ll be pleased of hear them) Cheers, Kikoso
-
Hello Superman, and thank you for your response. OpenCV has not such an ActiveX. Just provide the basics image analyzing algorithms, and a basic Windows system based on Win32 API. After some days checking for it on the internet I have not found a response. There are some clues using MFC, but using just the standard Forms of Visual C++ doesn´t seem possible (or at least obvious). Nevermind, thank you for your interest. If a get a solution I will share it here (and if anybody has more clues, I´ll be pleased of hear them) Cheers, Kikoso
Found a solution (and a new problem) to this. I just post the solution in case anyone check it in the future :) I basically transform the IplImage into Bitmap, and then paint it over a Form element. void IplImageToTBitmap (IplImage* image){ System::Drawing::Bitmap^ bitmap = gcnew Bitmap(image->height,image->width * image->nChannels,System::Drawing::Imaging::PixelFormat::Format24bppRgb); int numberOfLines= image->height; int numberOfColums= image->width ;//* image->nChannels; int step= image->widthStep; unsigned char* data=reinterpret_cast<unsigned char*>(image->imageData); for(int i=0; i<numberOfLines; i++){ for(int j=0; j<numberOfColums; j+= image->nChannels){ bitmap->SetPixel(j/3,i,Color::FromArgb(data[j],data[j+1],data[j+2])); } data+= step; } this->panel2->BackgroundImage = bitmap; } Using the sentence this->panel2->BackgroundImage = bitmap; I manage to write the image to a Panel Object (and definitely every object able to support bitmaps). Now I´m trying to work just with the frames from OpenCV not displaying the video (that means, commenting the line cvNamedWindow( "video", 1 );) Nevertheless, the program gets frozen and I´m not able to use it. I´m thinking about doing some stuff with Threads (using a Thread for OpenCV and a different one for the GUI), but any advice will be welcome :) Regards