Ask Your Question
0

find object size in pixels

asked 2014-01-11 07:22:41 -0600

lp gravatar image

I'm new to opencv, i use the c++ package. I used the code in the tutorial to detect an known object in the picture. Now I need to find the size of the object in pixels. I just need the number of pixels of his height and width in the pic (not the actual size). I couldn't find something that will help me.. is there a way to do it?

edit retag flag offensive close merge delete

Comments

We need more information than that. What have you done so far? Do you have bounding rectangles? If so you can easily check the size of the bounding rectangles. Width and height are members of the rect class.

JAyThaRevo gravatar imageJAyThaRevo ( 2014-01-12 06:54:33 -0600 )edit

could put your code, that will help us to help you

dervish79 gravatar imagedervish79 ( 2014-01-13 04:53:05 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-02-09 03:32:56 -0600

rushix gravatar image

@lp, You are trying to detect a known object, what i understands from this line is, You must be using a already trained cascade classifier to detect the known objects in a given image :

vector<Rect> faces;

// here we are trying to detect number of faces 

FaceCascadeClassifier.detectMultiScale(image, faces, 1.1, 1, 0|CV_HAAR_SCALE_IMAGE, Size(20, 20));

cout<<"no of found faces :" <<faces.size();

for (int i = 0; i < faces.size(); i++) 
{
  Rect r = faces[i];
  printf("a face is found at Rect(%d,%d,%d,%d).\n", r.x, r.y, r.width, r.height);
}

kindly try to find such code in your code and look at width and height parameters i am printing, and i think this is what you want. Dot.

edit flag offensive delete link more

Comments

It looks too old question to which i have answered, never mind, It may help to others who are trying to search for this problem and if comes to this thread.

rushix gravatar imagerushix ( 2018-02-09 03:46:38 -0600 )edit
supra56 gravatar imagesupra56 ( 2018-02-09 08:52:21 -0600 )edit

Question Tools

Stats

Asked: 2014-01-11 07:22:41 -0600

Seen: 1,117 times

Last updated: Feb 09 '18