gpt4 book ai didi

c# - 在多行图像上绘图/书写-EmguCV(OpenCV)无法识别新行字符

转载 作者:行者123 更新时间:2023-12-02 17:14:25 28 4
gpt4 key购买 nike

我正在尝试在EmguCV(OpenCV C#包装器)图像上绘制多于一行的字符串。但它表明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);
}

关于c# - 在多行图像上绘图/书写-EmguCV(OpenCV)无法识别新行字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16925604/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com