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