highgui: allow wrapping cv::addText

also correctly forward spacing parameter in fontQt
pull/7483/head
Pavel Rojtberg 8 years ago
parent a799cc13d9
commit 8cc09f1784
  1. 17
      modules/highgui/include/opencv2/highgui.hpp
  2. 37
      modules/highgui/src/window.cpp

@ -670,6 +670,23 @@ The function addText draws *text* on the image *img* using a specific font *font
*/
CV_EXPORTS void addText( const Mat& img, const String& text, Point org, const QtFont& font);
/** @brief Draws a text on the image.
@param img 8-bit 3-channel image where the text should be drawn.
@param text Text to write on an image.
@param org Point(x,y) where the text should start on an image.
@param nameFont Name of the font. The name should match the name of a system font (such as
*Times*). If the font is not found, a default one is used.
@param pointSize Size of the font. If not specified, equal zero or negative, the point size of the
font is set to a system-dependent default value. Generally, this is 12 points.
@param color Color of the font in BGRA where A = 255 is fully transparent.
@param weight Font weight. Available operation flags are : cv::QtFontWeights You can also specify a positive integer for better control.
@param style Font style. Available operation flags are : cv::QtFontStyles
@param spacing Spacing between characters. It can be negative or positive.
*/
CV_EXPORTS_W void addText(const Mat& img, const String& text, Point org, const String& nameFont, int pointSize = -1, Scalar color = Scalar::all(0),
int weight = QT_FONT_NORMAL, int style = QT_STYLE_NORMAL, int spacing = 0);
/** @brief Displays a text on a window image as an overlay for a specified duration.
The function displayOverlay displays useful information/tips on top of the window for a certain

@ -391,9 +391,9 @@ CV_IMPL void cvUpdateWindow(const char*)
#if defined (HAVE_QT)
cv::QtFont cv::fontQt(const String& nameFont, int pointSize, Scalar color, int weight, int style, int /*spacing*/)
cv::QtFont cv::fontQt(const String& nameFont, int pointSize, Scalar color, int weight, int style, int spacing)
{
CvFont f = cvFontQt(nameFont.c_str(), pointSize,color,weight, style);
CvFont f = cvFontQt(nameFont.c_str(), pointSize,color,weight, style, spacing);
void* pf = &f; // to suppress strict-aliasing
return *(cv::QtFont*)pf;
}
@ -404,6 +404,14 @@ void cv::addText( const Mat& img, const String& text, Point org, const QtFont& f
cvAddText( &_img, text.c_str(), org, (CvFont*)&font);
}
void cv::addText( const Mat& img, const String& text, Point org, const String& nameFont,
int pointSize, Scalar color, int weight, int style, int spacing)
{
CvFont f = cvFontQt(nameFont.c_str(), pointSize,color,weight, style, spacing);
CvMat _img = img;
cvAddText( &_img, text.c_str(), org, &f);
}
void cv::displayStatusBar(const String& name, const String& text, int delayms)
{
cvDisplayStatusBar(name.c_str(),text.c_str(), delayms);
@ -441,51 +449,58 @@ int cv::createButton(const String& button_name, ButtonCallback on_change, void*
#else
static const char* NO_QT_ERR_MSG = "The library is compiled without QT support";
cv::QtFont cv::fontQt(const String&, int, Scalar, int, int, int)
{
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
CV_Error(CV_StsNotImplemented, NO_QT_ERR_MSG);
return QtFont();
}
void cv::addText( const Mat&, const String&, Point, const QtFont&)
{
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
CV_Error(CV_StsNotImplemented, NO_QT_ERR_MSG);
}
void cv::addText(const Mat&, const String&, Point, const String&, int, Scalar, int, int, int)
{
CV_Error(CV_StsNotImplemented, NO_QT_ERR_MSG);
}
void cv::displayStatusBar(const String&, const String&, int)
{
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
CV_Error(CV_StsNotImplemented, NO_QT_ERR_MSG);
}
void cv::displayOverlay(const String&, const String&, int )
{
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
CV_Error(CV_StsNotImplemented, NO_QT_ERR_MSG);
}
int cv::startLoop(int (*)(int argc, char *argv[]), int , char**)
{
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
CV_Error(CV_StsNotImplemented, NO_QT_ERR_MSG);
return 0;
}
void cv::stopLoop()
{
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
CV_Error(CV_StsNotImplemented, NO_QT_ERR_MSG);
}
void cv::saveWindowParameters(const String&)
{
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
CV_Error(CV_StsNotImplemented, NO_QT_ERR_MSG);
}
void cv::loadWindowParameters(const String&)
{
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
CV_Error(CV_StsNotImplemented, NO_QT_ERR_MSG);
}
int cv::createButton(const String&, ButtonCallback, void*, int , bool )
{
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
CV_Error(CV_StsNotImplemented, NO_QT_ERR_MSG);
return 0;
}

Loading…
Cancel
Save