2016-06-28 9 views
0

emgucvとオプティカルフローの新機能です。私はビデオ上で動く物体を認識し、それらの周りを円や長方形などの形で描こうとしています。私は、opticalflow.HSとopticalflow.LKを使用する必要があります。それが私がしたい最初のことです。私はemgu cv 2.4.9を使用しています。私はいくつかのコードを持っていますが、それはちょっとした考えです。私は以前のフレームと現在のフレームを赤で表示し、それをopticalflow.HSに送信しましたが、その後に何をすべきかわからず、HSを使用した例は見つかりませんでした。 HSといくつかのアドバイス。C#とEmguCVを使用した動き検出

private void ProcessFrame(object sender, EventArgs e) 
    { 
     bool firstFrame = true; 
     bool keepProcessing = true; 

     Image<Gray, Byte> nextFrame = new Image<Gray, byte>(160, 640); 
     Image<Gray, Byte> previousFrame = null; 

     while (keepProcessing) 
     { 
      // ****** Change - Save previous frame before getting next one 
      // Only do this if the first frame has passed 
      if (!firstFrame) 
       previousFrame = nextFrame.Clone(); 

      // grab the next frame from video source 
     // _capture.Grab(); 

      // decode and return the grabbed video frame 
      nextFrame = _capture.RetrieveGrayFrame(); 

      // if the frame is valid (not end of video for example) 
      if (!(nextFrame==null)) 
      { 
       // **** Change - If we are on the first frame, only show that and 
       // set the flag to false 
       if (firstFrame) 
       { 
        firstFrame = false; 

       } 
       else 
       { 
        Image<Gray, float> velx = new Image<Gray, float>(previousFrame.Size); 
        Image<Gray, float> vely = new Image<Gray, float>(nextFrame.Size); 
        OpticalFlow.HS(previousFrame, nextFrame, true, velx, vely, 0.1d, new MCvTermCriteria(100)); 
        //capturedImageBox.Image = nextFrame; 

       } 
      } 
      else 
      { 
       keepProcessing = false; 
      } 
     } 

答えて

0

OpticalFlow.HS Methodでは、ホーン& Schunckのアルゴリズムを用いて、第1入力画像の画素毎のフローを計算します。

その後、オプティカルフローの描画を高密度にすることをお勧めします。ホープはあなたを助けることを望みます。

Go to link.

関連する問題