0, 0,
bmi.bmiHeader.biWidth, abs(bmi.bmiHeader.biHeight),
m_bitmapBits,
&bmi,
DIB_RGB_COLORS,
SRCCOPY
);
} else {
dc.FillRect(rect, COLOR_WINDOW);
}
return 0;
}
LRESULT COpenCVTestView::OnTimer(
UINT /*uMsg*/,
WPARAM /*wParam*/,
LPARAM /*lParam*/,
BOOL& /*bHandled*/
) {
// Nothing to do if capture object is not open
//
if( !m_cap.isOpened() ) return 0;
m_cap.read( m_cv_img );
_copyImage();
Invalidate();
return 0;
}
LRESULT COpenCVTestView::OnEraseBkgnd(
UINT /*uMsg*/,
WPARAM /*wParam*/,
LPARAM /*lParam*/,
BOOL& /*bHandled*/
) {
// since we completely paint our window in the OnPaint handler, use
// an empty background handler
return 0;
}
This code illustrates how to use bitmap-based drawing in a C++ application under Windows. This method
is simpler, but less efficient than using DirectShow to handle the video stream.
If you are using the .NET Runtime (either through C#, VB.NET or Managed C++), then
you may want to look into a package that completely wraps OpenCV, such as Emgu
(http://emgu.com).
Drawing Things
We often want to draw some kind of picture, or to draw something on top of an image obtained from
somewhere else. Toward this end, OpenCV provides a menagerie of functions that will allow us to make
lines, squares, circles, and the like.
The drawing functions available will work with images ...