【发布时间】:2014-07-03 08:41:55
【问题描述】:
您好,我正在尝试将点跟踪应用于场景。
现在我想让点只水平移动。有人对此有任何想法吗? 数组“Actual”和“nextfeature”包含相关的 x,y 坐标。我试图从两个数组中得到区别,它没有用。我尝试使用 Farneback 获得光流,但它没有给我一个令人满意的结果。如果有人能给我任何关于如何让点只在水平线上移动的想法,我将不胜感激。
谢谢。
这里是代码。
private void ProcessFrame(object sender, EventArgs arg)
{
PointF[][] Actual = new PointF[0][];
if (Frame == null)
{
Frame = _capture.RetrieveBgrFrame();
Previous_Frame = Frame.Copy();
}
else
{
Image<Gray, byte> grayf = Frame.Convert<Gray, Byte>();
Actual = grayf.GoodFeaturesToTrack(300, 0.01d, 0.01d, 5);
Image<Gray, byte> frame1 = Frame.Convert<Gray, Byte>();
Image<Gray, byte> prev = Previous_Frame.Convert<Gray, Byte>();
Image<Gray, float> velx = new Image<Gray, float>(Frame.Size);
Image<Gray, float> vely = new Image<Gray, float>(Previous_Frame.Size);
Frame = _capture.RetrieveBgrFrame().Resize(300,300,Emgu.CV.CvEnum.INTER.CV_INTER_AREA);
Byte []status;
Single[] trer;
PointF[][] feature = Actual;
PointF[] nextFeature = new PointF[300];
Image<Gray, Byte> buf1 = new Image<Gray, Byte>(Frame.Size);
Image<Gray, Byte> buf2 = new Image<Gray, Byte>(Frame.Size);
opticalFlowFrame = new Image<Bgr, Byte>(prev.Size);
Image<Bgr, Byte> FlowFrame = new Image<Bgr, Byte>(prev.Size);
OpticalFlow.PyrLK(prev, frame1, Actual[0], new System.Drawing.Size(10, 10), 0, new MCvTermCriteria(20, 0.03d),
out nextFeature, out status, out trer);
for (int x = 0; x < Actual[0].Length ; x++)
{
opticalFlowFrame.Draw(new CircleF(new PointF(nextFeature[x].X, nextFeature[x].Y), 1f), new Bgr(Color.Blue), 2);
}
new1 = old;
old = nextFeature;
Actual[0] = nextFeature;
Previous_Frame = Frame.Copy();
captureImageBox.Image = Frame;
grayscaleImageBox.Image = opticalFlowFrame;
//cannyImageBox.Image = velx;
//smoothedGrayscaleImageBox.Image = vely;
}
}
【问题讨论】:
标签: c# opencv image-processing emgucv opticalflow