static void putTextZH(const cv::Mat &inMat, const QString text, const cv::Point wordCenter, int inWordSize, const cv::Scalar inColor)
{
QImage image;
switch (inMat.type())
{
case CV_8UC1:
image = QImage(inMat.data, inMat.cols, inMat.rows, inMat.cols, QImage::Format_Mono);
break;
case CV_8UC3:
image = QImage(inMat.data, inMat.cols, inMat.rows, inMat.step, QImage::Format_RGB888);
break;
case CV_8UC4:
image = QImage(inMat.data, inMat.cols, inMat.rows, inMat.step, QImage::Format_ARGB32);
break;
}
QColor drawColor(inColor[0], inColor[1], inColor[2]);//调用时,inColor使用CV_RGB(0, 0, 255)格式颜色
QPainter painter(&image);
QPen pen = QPen(drawColor, inWordSize);
QBrush brush = QBrush(drawColor);
painter.setPen(pen);
painter.setBrush(brush);
QFont font("微软雅黑", inWordSize);
painter.setFont(font);
painter.drawText(QPoint(wordCenter.x, wordCenter.y), text);
}