我需要这样的东西,因为在我看来,当我这样做时
cvRectangle( CVframe, UL, LR, CV_RGB(0,256,53), CV_FILLED);
string cvtext;
cvtext += timeStr;
cvPutText(CVframe, cvtext.c_str(), cvPoint(0,(h/2+10)), &font , CV_RGB(0,0,0));
Run Code Online (Sandbox Code Playgroud)
每次24次每秒cvRectangle不覆盖旧文本...
没有内置cvDeleteText或类似的东西,可能有充分的理由.每当您在图像上放置文本时,它都会覆盖该图像中的像素,就像您已将其值设置为CV_RGB(0,0,0)单独一样.如果你想撤消那个操作,你需要预先存储那里的任何东西.由于不是每个人都想这样做,如果cvPutText自动跟踪它所写的像素,那将浪费空间和时间.
可能最好的方法是有两个框架,其中一个框架永远不会被文本触及.代码看起来像这样.
//Initializing, before your loop that executes 24 times per second:
CvArr *CVframe, *CVframeWithText; // make sure they're the same size and format
while (looping) {
cvRectangle( CVframe, UL, LR, CV_RGB(0,256,53), CV_FILLED);
// And anything else non-text-related, do it to CVframe.
// Now we want to copy the frame without text.
cvCopy(CVframe, CVframeWithText);
string cvtext;
cvtext += timeStr;
// And now, notice in the following line that
// we're not overwriting any pixels in CVframe
cvPutText(CVframeWithText, cvtext.c_str(), cvPoint(0,(h/2+10)), &font , CV_RGB(0,0,0));
// And then display CVframeWithText.
// Now, the contents of CVframe are the same as if we'd "deleted" the text;
// in fact, we never wrote text to CVframe in the first place.
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助!
| 归档时间: |
|
| 查看次数: |
4798 次 |
| 最近记录: |