i have a function that it's very slow, about 300 milisecond!
i need to change it to a faster way!
how can i use thread to change it to a higher function?
private void FindStopSign(Image
{
for (; contours != null; contours = contours.HNext)
{
contours.ApproxPoly(contours.Perimeter * 0.02, 0, contours.Storage);
if (contours.Area > 500)
{
double ratio = CvInvoke.cvMatchShapes(_octagon, contours, Emgu.CV.CvEnum.CONTOURS_MATCH_TYPE.CV_CONTOURS_MATCH_I3, 0);
if (ratio > 0.1) //not a good match of contour shape
{
Contour
if (child != null)
{
FindStopSign(img, stopSignList, boxList, child);
}
continue;
}
Rectangle box = contours.BoundingRectangle;
Image
using (Image
{
candidate = tmp.Convert
}
//set the value of pixels not in the contour region to zero
using (Image
{
mask.Draw(contours, new Gray(255), new Gray(255), 0, -1, new Point(-box.X, -box.Y));
double mean = CvInvoke.cvAvg(candidate, mask).v0;
candidate._ThresholdBinary(new Gray(mean), new Gray(255.0));
candidate._Not();
mask._Not();
candidate.SetValue(0, mask);
}
ImageFeature[] features = _detector.DetectFeatures(candidate, null);
Features2DTracker.MatchedImageFeature[] matchedFeatures = _tracker.MatchFeature(features, 2, 20);
int goodMatchCount = 0;
foreach (Features2DTracker.MatchedImageFeature ms in matchedFeatures)
if (ms.SimilarFeatures[0].Distance < 0.5) goodMatchCount++;
if (goodMatchCount >= 10)
{
boxList.Add(box);
stopSignList.Add(candidate);
}
}
}
}
Replies
Know the answer? Post it — somebody with the same question will find it here.