2010-12-02 73 views
1

我需要这样的东西,因为在我看来,当我每次做OpenCV - 有没有像删除文本?

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)); 

每秒cvRectangle 24次不覆盖旧的文本......

回答

6

有没有内置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. 

希望这有助于!