OpenCV:如何在Windows窗体应用程序中显示网络摄像头捕获? [英] OpenCV : How to display webcam capture in windows form application?

查看:191
本文介绍了OpenCV:如何在Windows窗体应用程序中显示网络摄像头捕获?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,我们使用以下命令在opencv窗口中显示网络摄像头或视频运动:

generally we display webcam or video motion in opencv windows with :

      CvCapture* capture = cvCreateCameraCapture(0);
            cvNamedWindow( "title", CV_WINDOW_AUTOSIZE );
   cvMoveWindow("title",x,y);
   while(1) 
   {
    frame = cvQueryFrame( capture );
    if( !frame )
    {
     break;
    }
    cvShowImage( "title", frame );
    char c = cvWaitKey(33);
    if( c == 27 )
    {
     break;
    }
   }

我试图使用pictureBox通过以下方式成功以Windows形式显示图像:

i tried to use pictureBox that is successful to display image in windows form with this :

 pictureBox1->Image = gcnew System::Drawing::Bitmap( image->width,image->height,image->widthStep,System::Drawing::Imaging::PixelFormat::Undefined, ( System::IntPtr ) image-> imageData);

但是当我试图显示从视频中捕获的图像时,它是行不通的,这是来源:

but when im trying to display captured image from video it wont works, here is the source :

            CvCapture* capture = cvCreateCameraCapture(0);
   while(1) 
   {
    frame = cvQueryFrame( capture );
    if( !frame )
    {
     break;
    }
    pictureBox1->Image = gcnew System::Drawing::Bitmap( frame->width,frame->height,frame->widthStep,System::Drawing::Imaging::PixelFormat::Undefined, ( System::IntPtr ) frame-> imageData);
    char c = cvWaitKey(33);
    if( c == 27 )
    {
     break;
    }
   }

反正有使用Windows窗体代替opencv窗口来显示视频或网络摄像头吗?

is there anyway to use windows form instead opencv windows to show video or webcam?

还是我的代码有问题? 谢谢您的帮助..:)

or is there something wrong with my code? thanks for your help.. :)

推荐答案

我不知道您是否会喜欢这样,但是您可以使用OpenGL在非opencv提供的其他窗口中显示视频流. (捕获框架并将其显示在矩形..或类似的东西上.)

I don't know if you will like this, but you could use OpenGL to show the video stream in other windows than the ones provided with opencv. (Capture the frame and display it on a rectangle.. or something like that..)

这篇关于OpenCV:如何在Windows窗体应用程序中显示网络摄像头捕获?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆