1

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 を使用してストリームを結合し、1 つのストリーム (仮想 Web カメラの 2 つの Web カメラのようなもの) を生成できるかどうか疑問に思っていました。

どんな助けにも感謝します。私の英語を気にしてください!

4

1 に答える 1

0

こんにちは、2つの画像フレームで対応するポイントを見つける必要があります(カメラの位置が個別に制御されている場合はSURFタイプのアルゴリズム、またはカメラの相対位置と角度が固定されている場合はチェス盤パターンを使用して対応するコーナーを見つけることができます)、それらのポイントの座標を使用して計算しますホモグラフィ行列。マトリックスがある場合は、それを「WarpPerspective」関数のパラメーターとして使用します。2 番目のカメラからのフレームに重ねて表示できるように、画像をゆがめます。

それが役立つことを願っています。

于 2012-06-30T16:57:38.090 に答える