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

Answers


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

No AdminMenu in Wordpress Plugin

wordpress wordpress-plugin

I am creating a plugin, I have a page in that plugin that displays a list of registrations.

Two similar LINQ queries, completely different generated SQL

c# sql-server linq entity-framework

I'm running into a problem with the following pseudoquery:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.