OpenCV: version 2.4.5
Visual Studio: version 2010
IsStop = false;
using namespace cv;
VideoCapture capture(0);
if (!capture.isOpened()) // check if we succeeded
return;
Mat src, src_gray, src_edge;
CvRect Rect;
long cnt = 0;
for (;;)
{
capture >> src;
System::Drawing::Graphics^ graphics = pictureBox1->CreateGraphics();
System::IntPtr ptr(src.ptr());
System::Drawing::Bitmap^ b = gcnew System::Drawing::Bitmap(src.cols,src.rows,src.step,System::Drawing::Imaging::PixelFormat::Format24bppRgb,ptr);
System::Drawing::RectangleF rect(0,0,pictureBox1->Width,pictureBox1->Height);
graphics->DrawImage(b,rect);
//----------------------------------------------------------------------------------------------------------------------
cvtColor( src, src_gray, CV_BGR2GRAY );
System::Drawing::Graphics^ graphics2 = pictureBox2->CreateGraphics();
System::IntPtr ptr2(src_gray.ptr());
System::Drawing::Bitmap^ b2 = gcnew System::Drawing::Bitmap(src_gray.cols/3,src_gray.rows,src_gray.step,System::Drawing::Imaging::PixelFormat::Format24bppRgb ,ptr2);
System::Drawing::RectangleF rect2(0,0,pictureBox2->Width,pictureBox2->Height);
graphics2->DrawImage(b2,rect2);
//----------------------------------------------------------------------------------------------------------------------
Canny( src_gray, src_edge, 50, 25, 3);
System::Drawing::Graphics^ graphics3 = pictureBox3->CreateGraphics();
System::IntPtr ptr3(src_edge.ptr());
System::Drawing::Bitmap^ b3 = gcnew System::Drawing::Bitmap(src_edge.cols,src_edge.rows,src_edge.step,System::Drawing::Imaging::PixelFormat::Format8bppIndexed ,ptr3);
System::Drawing::RectangleF rect3(0,0,pictureBox3->Width,pictureBox3->Height);
graphics3->DrawImage(b3,rect3);
cnt++;
label1->Text = Convert::ToString(cnt);
Application::DoEvents();
if(IsStop) break;
}
Sample Code: OpenCCD245