Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I want to dig this old thread because this bug isn't fixed until now. I think changing this piece of code to

...
box.center.x = (float)rp[0] + c.x;
box.center.y = (float)rp[1] + c.y;
box.size.width = (float)(rp[2]*2);
box.size.height = (float)(rp[3]*2);
if( box.size.width > box.size.height )
{
    float tmp;
    CV_SWAP( box.size.width, box.size.height, tmp );
    box.angle = (float)(90 + rp[4]*180/CV_PI);
}
else
{
    box.angle = (float)(rp[4]*180/CV_PI);
}
if( box.angle < -180 )
    box.angle += 360;
if( box.angle > 180 )
    box.angle -= 360;

return box;

should fix it. And I think the angle range should be between -180 and +180 degrees, so I changed the last condition, too.

I want to dig this old thread because this bug isn't fixed until now. I think changing this piece of code to

...
box.center.x = (float)rp[0] + c.x;
box.center.y = (float)rp[1] + c.y;
box.size.width = (float)(rp[2]*2);
box.size.height = (float)(rp[3]*2);
box.angle = (float)(rp[4]*180/CV_PI);

if( box.size.width > box.size.height )
{
    float tmp;
    CV_SWAP( box.size.width, box.size.height, tmp );
    box.angle = (float)(90 + rp[4]*180/CV_PI);
+= 90;
}
else
{
    box.angle = (float)(rp[4]*180/CV_PI);
}
 if( box.angle < -180 )
    box.angle += 360;
if( box.angle > 180 )
    box.angle -= 360;

return box;

should fix it. And I think the angle range should be between -180 and +180 degrees, so I changed the last condition, too.

I want to dig this old thread because this bug isn't fixed until now. I think changing this piece of code to

...
box.center.x = (float)rp[0] + c.x;
box.center.y = (float)rp[1] + c.y;
box.size.width = (float)(rp[2]*2);
box.size.height = (float)(rp[3]*2);
box.angle = (float)(rp[4]*180/CV_PI);

if( box.size.width > box.size.height )
{
    float tmp;
    CV_SWAP( box.size.width, box.size.height, tmp );
    box.angle += 90;
}

if( box.angle < -180 )
    box.angle += 360;
if( box.angle > 180 )
    box.angle -= 360;

return box;

should fix it. And I think the angle range should be between -180 and +180 degrees, degrees (or even between -90 and +90 degrees?), so I changed the last condition, too.