Click here to Skip to main content
15,902,299 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hello, I am a newbie learning c# as well as EMGU.CV. I have tried out the SURFFeature program in the tutorial from emgu.com. Lines will be drawn to the matched features right. Is there any way I can find out how many lines are there all together being drawn and display the "no of lines drawn" on a label?
Posted
Updated 25-Oct-10 19:18pm
v2

1 solution

Hi my apologise for a late response but in case you haven't figured this
out yet I thought I'd give you an answer.

The section of code that draws the lines on the image is:

C#
#region draw lines between the matched features
foreach (SURFTracker.MatchedSURFFeature matchedFeature in matchedFeatures)
{
    PointF p = matchedFeature.ObservedFeature.Point.pt;
    p.Y += modelImage.Height;
    res.Draw(new LineSegment2DF(matchedFeature.SimilarFeatures[0].Feature.Point.pt, p), new Gray(0), 1);
}
#endregion


This "foreach" loop repeats for all the features matched in the image therefore the the size of "matchedFeatures" which is an array is the number of matches and lines to be drawn (Please note the s on the end of this variable). We can assign this value to a integer.

C#
int num_lines = matchedFeatures.Length;


Now if you wish to display the number of lines to a label then you will have to re-create the project with windows form controls and display the result image in a picture box. You can the convert to num_lines integer to a string (num_lines.toString()).

To save you some time I have used the Hello world example as reference to draw the result on the black box left unused to the right of the results. At the end of your code copy and paste this:


C#
int num_lines = matchedFeatures.Length;
MCvFont f = new MCvFont(FONT.CV_FONT_HERSHEY_COMPLEX, 1.0, 1.0); //Create the font
res.Draw(num_lines.ToString(),ref f,new System.Drawing.Point(400, 100), new Gray(255)); //Draw to text on the image
ImageViewer.Show(res, String.Format("Matched in {0} milliseconds", watch.ElapsedMilliseconds)); //Show the image


NOTE This is already the last line in the example code.
C#
ImageViewer.Show(res, String.Format("Matched in {0} milliseconds", watch.ElapsedMilliseconds));


What I am doing here is drawing the results directley onto the resultant image stored in the variable "res". An easy cheat way to quickly display your results, your answer should be 35.

Cheers
Chris
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900