Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在Visual Studio 2013 c中显示位图源时出现问题#_C#_Visual Studio 2013_Aforge - Fatal编程技术网

C# 在Visual Studio 2013 c中显示位图源时出现问题#

C# 在Visual Studio 2013 c中显示位图源时出现问题#,c#,visual-studio-2013,aforge,C#,Visual Studio 2013,Aforge,我正在尝试编写一段代码,用视频捕获设备的前一帧更新Image.Source 我使用的是AForge.NETAPI的具体用法:AForge.Video和AForge.Video.DirectShow。但是,当我将图像更新到当前帧时,图像将变为空白 您将在我的代码中看到,经过各种转换后,我保存了位图,这是为了检查位图是否仍然包含帧。测试成功,即保存的图像不是空白帧的图像。下面是我为newFrameEvent编写的代码,如果有人有任何想法,我将不胜感激 newframeEvent参数是一个System

我正在尝试编写一段代码,用视频捕获设备的前一帧更新
Image.Source

我使用的是
AForge.NET
API的具体用法:
AForge.Video和AForge.Video.DirectShow
。但是,当我将
图像更新到当前帧时,图像将变为空白

您将在我的代码中看到,经过各种转换后,我保存了位图,这是为了检查位图是否仍然包含帧。测试成功,即保存的图像不是空白帧的图像。下面是我为
newFrameEvent
编写的代码,如果有人有任何想法,我将不胜感激

newframeEvent
参数是一个
System.Drawing.Bitmap
对象

 private void NewThermalFrameReady(object sender, NewFrameEventArgs e)
 {   
     //Copy frame into tempoary storage. In format Bitmap          
     this.frame = e.Frame; 

     //Save Bitmap frame for test
     this.frame.Save("C:/Users/Shankar/Documents/Visual Studio 
     2013/Projects/Capture_Devices/Capture_Devices/test.jpg");

     //Get BitmapSource from Bitmap and save to double check conversion was sucessful
     this.finalFrame = Imaging.CreateBitmapSourceFromBitmap(frame);
     CreateThumbnail("C:/Users/Shankar/Documents/Visual Studio 
     2013/Projects/Capture_Devices/Capture_Devices/test2.jpg",
     this.finalFrame.Clone());

     try
     {
         this.Dispatcher.Invoke((Action)(() =>
         {
             if (finalFrame!=null)
             {                       
                this.frameDisp.Source = this.finalFrame;
             }      
         }));
     }
     catch (System.Threading.Tasks.TaskCanceledException)
     {

     }


 }

这不是一直都是这样吗,你花了几个小时在一个问题上,提出问题,然后解决它!我不得不搬家:

this.finalFrame = Imaging.CreateBitmapSourceFromBitMap(frame);

在它完美工作后,将其放入dispatcher调用中!我将把这个问题留在这里,以防其他人有这个问题……

这对我在图片框上显示新图像起到了作用

void videoSource_NewFrame(对象发送方,AForge.Video.NewFrameEventArgs eventArgs) {

        pictureBoxVideo.BackgroundImage = (Bitmap)eventArgs.Frame.Clone();
    }
所以可以尝试使用

      this.frame = e.Frame.Clone(); // in your code