我正在尝试使用 EMGUCV 实时进行网络摄像头缝合。类似于 youtube 上的此设置。问题是我没有得到拼接的视频图像。
这是我的代码`
public Form1()
{
InitializeComponent();
capture1 = new Emgu.CV.Capture(0);
this.capture1.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 1920.0f);
this.capture1.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 1080.0f);
capture2 = new Emgu.CV.Capture(1);
this.capture2.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 1920.0f);
this.capture2.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 1080.0f);
}
private void button1_Click(object sender, EventArgs e)
{
#region if capture is not created, create it now
if (capture1 == null)
{
try
{
capture1 = new Emgu.CV.Capture(0);
capture2 = new Emgu.CV.Capture(1);
}
catch (NullReferenceException excpt)
{
MessageBox.Show(excpt.Message);
}
}
#endregion
if (capture1 != null)
{
if (captureInProgress)
{ //if camera is getting frames then stop the capture and set button Text
// "Start" for resuming capture
button1.Text = "Start!"; //
Application.Idle -= ProcessFrame;
}
else
{
//if camera is NOT getting frames then start the capture and set button
// Text to "Stop" for pausing capture
button1.Text = "Stop";
Application.Idle += ProcessFrame;
}
captureInProgress = !captureInProgress;
}
}
private void ProcessFrame(object sender, EventArgs arg)
{
Image<Bgr, Byte> ImageFrame = capture1.QueryFrame();
camimageBox.Image = ImageFrame; //line 2
Image<Bgr, Byte> ImageFrame2 = capture2.QueryFrame();
imageBox1.Image = ImageFrame2;
}
private void ReleaseData()
{
if (capture1 != null)
capture1.Dispose();
}
private void button2_Click(object sender, EventArgs e)
{
Image<Bgr, byte>[] frames2 = new Image<Bgr, byte>[2];
//List<Image<Bgr, Byte>> frames2 = new List<Image<Bgr, byte>>();
frames2[0] = capture1.QueryFrame();
frames2[1] = capture2.QueryFrame();
camimageBox.Image = frames2[0];
imageBox1.Image = frames2[1];
try
{
using (Stitcher stitcher = new Stitcher(true))
//using (Stitcher stitcher = new Stitcher(true))
{
Image<Bgr, Byte> result = stitcher.Stitch(frames2);
imageBox2.Image = result;
}
}
finally
{
foreach (Image<Bgr, Byte> img in frames2)
{
img.Dispose();
}
}
}
}
我正在使用 Nvidia NVS 450 GPU。我能够将各个摄像机读取为单独的流。我想知道是否可以使用 EMGUCV 将流组合在一起以产生一个流(更像是虚拟网络摄像头中的 2 个网络摄像头)。
我将不胜感激任何帮助。请注意我的英语!