A basic question on point classes and ellipses

asked 2016-05-12 17:01:41 -0600

updated 2016-05-13 01:38:49 -0600

LorenaGdL gravatar image

I am attempting to teach myself some basic opencv concepts (c++ and Windows) by studying code examples. My goal is to develop a webcam based eye tracking app. I have found some good example code that I might be able to build upon, but I am first trying to learn what each part of the program does. However, I often have trouble finding a tutorial or explanation for something that seems very specific and basic.

Right now I am studying the cascade classifier tutorial:

http://docs.opencv.org/3.1.0/db/d28/t...

I am confused about a couple of lines of code, which I believe has something to do with drawing an ellipse:

 Point center( faces[i].x + faces[i].width/2, faces[i].y + faces[i].height/2 );
 ellipse( frame, center, Size( faces[i].width/2, faces[i].height/2), 0, 0, 360, Scalar( 255, 0, 255 ), 4, 8, 0 );

I understand somewhat what the second line is about, but I can't make sense of the first. It has similarities to the code for the ellipse, but I believe it is a point class object. I read about the point class in the opencv documentation, but the code examples appeared quite different from the way in which it was used in the cascade classifier program. What exactly is being added?

Finally, is this the best place to ask some of these basic questions? I have many more, although I usually try to find answers myself first. But sometimes I can't seem to find exactly what I'm looking for.

edit retag flag offensive close merge delete

Comments

  1. The first line is a Point object initialization. It assigns a x value of faces[i].x + faces[i].width/2 and a y value of faces[i].y + faces[i].height/2. Don't be confused by having expressions rather than raw numbers, it is like initializing as for example Point center (34, 60). The second line draws an ellipse calling the ellipse() function
  2. You're on the right track if you're trying to answer your own questions first, that's the best way to learn. I'd recommend you to take a look at the basic tutorials dealing with OpenCV structures, to get a good foundation, and then move on to more complex ones. But if you're still lost at the end, come back here (use the search bar before asking, your doubt might has been solved before)
LorenaGdL gravatar imageLorenaGdL ( 2016-05-13 01:53:27 -0600 )edit

Extra: use the "10101" button to format code lines here in the forum

LorenaGdL gravatar imageLorenaGdL ( 2016-05-13 01:55:01 -0600 )edit

Thanks, that makes things slightly more understandable, but now I have a few follow-up questions.

First, I am confused about the usage of the square brackets, which I understand has something to do with arrays. However this doesn't really look like an array to me. Secondly, is the period after the square brackets a dot operator, or is that something else?

Finally, does the i have something to do with the i found in the previous line:

for( size_t i = 0; i < faces.size(); i++ )
dmehling gravatar imagedmehling ( 2016-05-13 15:37:50 -0600 )edit

Well... your problem is not with OpenCV but with very very basic knowledge of C++ and Object oriented programming. You don't even seem to know what a for-loop is, so I strongly reccomend you to start reading one of the beginners C++ books available on the internet

LorenaGdL gravatar imageLorenaGdL ( 2016-05-14 04:19:18 -0600 )edit