Ask Your Question

Revision history [back]

Okay to provide a solution to your problem, starting from the following facts:

  1. Your top left corner is p0.
  2. Your bottom right corner is p1.
  3. Both points are made of the type cv::Point(x,y).

Which makes point 2 quite useless. If I am wrong here, then please provide explanation of what p0, p1 and p2 are.

Then the following code will work perfectly:

int width = p1.x - p0.x;
int height = p1.y - p0.h;

However your functions seem more complex and I am guessing you do not have a bounding box yet. SO like said before, could you give the code leading to those 3 points and explain what they are?