繁体   English   中英

在图像上绘制/写入多行 - EmguCV(OpenCV)无法识别新行char

[英]Draw / Write on an image more than one line - EmguCV (OpenCV) does not recognize new line char

我正在尝试在EmguCV(OpenCV C#wraper)Image上绘制一个包含多行的字符串。 但它接缝表明EmguCV无法识别新行“\\ r \\ n”字符。

怎么能实现呢? 或者,如何获取文本高度,以便我可以手动设置下一个字符串的位置?

StringBuilder imageComments = new StringBuilder();
imageComments.AppendLine("Camera status");
imageComments.AppendLine("Shutter: " + shutter);
Emgu.CV.Image<Gray, Byte> img = new Emgu.CV.Image<Gray, byte>(bmp);
Point location = new Point(30, 30);
MCvFont font = new MCvFont(Emgu.CV.CvEnum.FONT.CV_FONT_HERSHEY_SIMPLEX, 0.3f, 0.3f);
Gray color = new Gray(255);
img.Draw(imageComments.ToString(), ref font, location, color);

您始终可以创建自己的函数,将段落解析为单独的行,然后生成每行所需的y位移。 如果我没记错的话,默认字体大小为16像素。

void myDrawMultiLineText(string InputParagraph, Point Origin)
{
vector<string> LinesOfText = myParse(InputParagraph,"\n");
for (int i=0;i<LinesOfText.size(); ++i)
    DrawText(CurrentLine[i], Origin.x, Origin.y + i*16);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM