Ask Your Question

How to open camera in VS2010 (MDI App) as a view

asked 2012-08-06 02:48:42 -0500

Gaurang gravatar image

Hi! I'm new to opencv, and not an experienced programmer. I am using OpenCV 2.4 and VS2010. I am using MDI application. I want to open camera in a view. Please help me, how to do?


edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2012-08-06 05:33:15 -0500

Adi gravatar image

updated 2012-08-09 12:43:53 -0500

CvvImage was a highgui class that was removed from OpenCV from ver. 2.2.
It had 2 methods relevant to drawing in a Win32/MFC application.

#if defined WIN32 || defined _WIN32
    /* draw part of image to the specified DC */
    virtual void  Show( HDC dc, int x, int y, int width, int height,
                        int from_x = 0, int from_y = 0 );
    /* draw the current image ROI to the specified rectangle of the destination DC */
    virtual void  DrawToHDC( HDC hDCDst, RECT* pDstRect );

Unfortunately, if you don't use the HighGui windows, then after you grab the frame you'll have to display it yourself using the Windows APIs (e.g. Win32 or MFC).
The relevant Win32/MFC functions to do this are ::SetDIBitsToDevice or ::StretchDIBits.

You can refer to c:\OpenCV_install_folder\modules\highgui\src\window_w32.cpp to see how it's done there.

edit flag offensive delete link more


CvvImage is not working in Opencv 2.4.2 Please let me know how to display camera in VS2010 using OpenCV.

CvvImage is not working.....

Gaurang gravatar imageGaurang ( 2012-08-08 07:21:05 -0500 )edit

What is CvvImage?? Please note, that OpenCV has its own method for displaying images, here is sample code . But if you want to use any other GUI framework, you have to do it by yourself.

Kirill Kornyakov gravatar imageKirill Kornyakov ( 2012-08-09 02:19:07 -0500 )edit

answered 2015-05-06 05:25:28 -0500

pklab gravatar image

updated 2015-05-06 05:40:14 -0500

CvvImage::DrawTOHDC was available before OpenCV 2.2.

You could retrieve some old code from somewhere

Anyway you can check my own class PkMatToGDI that uses same principle of DrawTOHDC

An interesting implementation is here: The author creates a namedWindow as child of MFC Dialog over a Dialog ctrol. After this he uses cv::imshow

edit flag offensive delete link more
Login/Signup to Answer

Question Tools


Asked: 2012-08-06 02:48:42 -0500

Seen: 1,321 times

Last updated: May 06 '15