OpenCV - is there anething like delete text?

I need such thing because it seems to me that when I do

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

each time 24 times per second cvRectangle does not overlay old text...


There's no built-in cvDeleteText or anything like that, and probably for good reason. Whenever you put text on an image, it overwrites the pixels in that image, just as if you had set their values to CV_RGB(0,0,0) individually. If you wanted to undo that operation, you'd need to store whatever had been there beforehand. Since not everyone wants to do that, it would be a waste of space and time if cvPutText automatically kept track of the pixels it wrote over.

Probably the best approach would be to have two frames, one of which is never touched by text. The code would look something like this.

//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.

Hope this helps!

Need Your Help

Other frameworks with compile time/ runtime “mixins” feature like Spring Roo for Java

java aop spring-roo code-injection mixins

I am wondering there is any framework which automatically injects methods into Java class similar to Spring Roo's "mixins".