簡體   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