我是emgucv和光流的新手。我试图在视频中识别运动中的对象,并围绕它们绘制圆形或矩形或其他一些形状。我必须使用opticalflow.HS和opticalflow.LK,这是我想做的第一件事。我使用的是emgu cv2.4.9,我有一些代码,但这只是一些想法。我修改了前一帧和当前帧,并将其发送到opticalflow.HS,但我不知道之后该做什么,我也找不到任何使用HS的示例,所以我真的很感谢同样的示例,在opticalflow.HS之后下一步该做什么以及一些建议。
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;
}
}发布于 2016-06-29 02:24:56
https://stackoverflow.com/questions/38083170
复制相似问题