displaying image in mfc dialog box.
-
Tuesday, March 01, 2011 7:46 PM
hi,
i am preparing the dialog box which contains a button to open my web cam and start the video session. I am doing this with the help of openCv library. Now, I want to display this frame (from the webcam) inside the same dialog box.
Which control should i use from the toolbox or can anyone provide me the sample code (if any).
Thanks in Advance:)
All Replies
-
Tuesday, March 01, 2011 8:01 PM
You can use a PictureBox. Covert your frame from IplImage to a CBitmap and call SetBitmap() on your picturebox control.
-Seetharam
-
Tuesday, March 01, 2011 8:33 PM
hi,
thanks for your reply. But, we are unable to create a variable for the pictureBox once we drag and drop into dialog box.
Hence we are not able to proceed that way.
-
Tuesday, March 01, 2011 9:20 PM
I assume you are using an MFC dialog? So when you say "unable to create a picturebox" what do you mean? When you drag a picture control onto your dialog from the toolbox, do you see it on your dialog? You would then need to right-click and do a "add variable". Does this step work?
A picture control is nothing but a CStatic with SS_BITMAP style set.
-Seetharam
-
Wednesday, March 02, 2011 12:50 AMI am not sure what data you are receiving and how streaming is handled but if you are receiving MJPEG You can use CWnd as a base class to render each bitmap frame by using BitBlt for example.
JohnCz - MVP VC++ -
Thursday, March 10, 2011 12:22 AM
yes sir,
You are right. but,
when i drag the picture control from the toolbox to my dialog, the default id is ID_STATIC and when i try to create a variable for the same by a right click on it and choose Add a variable option, i was shown a popup saying that unable to create a variable for static type.
So, i renamed the id as mypic and repeated the process.
Now am able to create the variable for the control but i couldnt display my bitmap image using SetBitmap() function invoked using the variable created.
I would like to display the camera frame dynamically.
Hope you got my problem. Waiting for your sugesstions.
Thanks in Advance.
-
Thursday, March 10, 2011 12:36 AM
hi sir,
the data format is IplImage available with openCv library.
i am grabing the camera frame using cvQueryFrame() and displaying the frame using api cvShowImage()
Thus every time i grab a camera frame and display the same after my processing operations.
Thus it looks like streaming video.
My problem is...
Doing like this, i could only display my video in separate window but i want to make it appear inside the dialog box.
Since it is not the bitmap image format, i could not also take advantage of bitblt function.
If converting to bitmap and displaying is the only solution, then i would like to get the code snippet for the iplimage to bitmap conversion.
So it is not MPEJ. It just a image.
Looking forward for your reply.. Thanks in Advance.
-
Friday, June 08, 2012 12:08 PM
hy i also have the same problem. if you have solved it then please help me too.
thanks
-
Friday, August 17, 2012 12:13 PM
I am sorry for the delay – health issues.
I am not familiar with openCv library, however if you are able to display the image in some window, why don’t you use this window as embedded in a dialog?
Simply create this window as a child of the dialog.
JohnCz

