К сожалению, круги являются встроенными и флаг по умолчанию для рисования прямоугольников. См. DRAW_RICH_KEYPOINTS
documentation.
Однако, поскольку у вас уже есть местоположения клавиш, вы можете написать свою собственную функцию рисования. Версия C++ drawKeypoints
- here. И ниже представлена краткая версия новой функции, которая рисует прямоугольники.
void drawKeypoints(InputArray image, const std::vector<KeyPoint>& keypoints, InputOutputArray outImage, const Scalar& _color)
{
bool isRandColor = _color == Scalar::all(-1);
std::vector<KeyPoint>::const_iterator it = keypoints.begin(),
end = keypoints.end();
for(; it != end; ++it)
{
Scalar color = isRandColor ? Scalar(rng(256), rng(256), rng(256)) : _color;
p=*it;
Point center(cvRound(p.pt.x * draw_multiplier), cvRound(p.pt.y * draw_multiplier));
int radius = cvRound(p.size/2 * draw_multiplier); // KeyPoint::size is a diameter
// draw RECTANGLES (actually squares) around keypoints with the keypoints size
rectangle(outImage, center + Point(-radius, -radius), center + Point(radius, radius), color, 1, LINE_AA, draw_shift_bits);
// draw orientation of the keypoint, if it is applicable
if(p.angle != -1)
{
float srcAngleRad = p.angle*(float)CV_PI/180.f;
Point orient(cvRound(cos(srcAngleRad)*radius),
cvRound(sin(srcAngleRad)*radius)
);
line(outImage, center, center+orient, color, 1, LINE_AA, draw_shift_bits);
}
}
}
оттуда оттуда оттуда – gpasch