2012-06-17 3 views
1

EMGUCV로 실시간 웹캠 스티치를하려고합니다. this setup on youtube과 비슷한 것입니다. 문제는 스티칭 된 비디오 전용 이미지를 얻지 못한다는 것입니다. EmguCV로 리얼 타임 웹캠 비디오 스티칭

내 코드 `

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(); 
      } 

     } 
    } 
} 

내가 엔비디아 NVS 450 GPU를 사용하고있다. 개별 카메라를 별도의 스트림으로 읽을 수 있습니다. EMGUCV를 사용하여 스트림을 결합하여 하나의 스트림 (가상 웹캠에 2 개의 웹캠을 더 생성)을 생성 할 수 있는지 궁금합니다.

나는 도움을 준 것에 대해 감사 할 것입니다. 내 영어를 마음 먹고 PLS!

답변

0

안녕하세요 당신은 2 개의 이미지 프레임 (카메라 위치가 별도로 제어되는 경우 SURF 유형의 알고리즘 또는 체스 판 패턴을 사용할 수 있고 카메라가 상대 위치와 각도를 고정하면 해당 모서리를 찾을 수 있음)에 해당 지점을 찾아야합니다. 동위 원소 행렬을 계산하는 포인트. 행렬이있을 때 "WarpPerspective"함수의 매개 변수로 사용합니다. 이미지가 뒤틀려서 두 번째 카메라의 프레임 위에 놓을 수 있습니다.

희망이 있습니다.

+0

안녕하세요 OscylO 감사합니다. 늦은 답변 죄송합니다. 나는 다른 것들로 매우 바쁩니다. 나는 당신이 쓴 것을 확인하고 그것이 좋자 마자 피드백을 줄 것이다. – user1462296

관련 문제