Login | Register 
FEATURES
APPLICATIONS
DOWNLOADS
EDUCATION
BLOG
WIKI
FORUM
STORE

Detecting the presence and location of non black pixels

Still a little green? Ask your beginner's questions here

Detecting the presence and location of non black pixels

Postby respectthecode » Wed Jun 12, 2019 2:04 pm

I have an SDI video input that contains song lyrics. The goal is the generate boxes behind the text that are sized appropriately and output the Key/Fill from a second DeckLink card.

There are 3 states that I need to be able to detect and handle, 1 or 2 lines of text and none (there should be no boxes when there is no text). The text is always white and in the same region.

The part that I am not sure how to do is detect the presence and location of the text. I don't need OCR or anything like that. I just need the boundaries of the non black pixels. The rest of this seems pretty simple.
respectthecode
 
Posts: 19
Joined: Mon Jul 16, 2018 8:50 am

Re: Detecting the presence and location of non black pixels

Postby snaut » Wed Jun 12, 2019 4:37 pm

You could use an Analyze TOP to fetch the maximum for Rows and Columns.
Convert that to a CHOP and now use the Analyze CHOP to find the Index of the First Peak.

Reversing the Channel from the topto will let you run through the same process to retrieve the last white pixel calculated from the bottom/end of the image.

Alternatively you could write a little glsl TOP that uses atomic counters to track the most left/right, top/bottom white pixels and writes out the values into rgba channels of the last pixel processed (keep track with another atomic counter). Then just fetch the last value again with a Analyze TOP...

Cheers
Markus
Attachments
textBoundsTOP.tox
TouchDesigner099 build 2019.16190
(1.76 KiB) Downloaded 78 times
textBoundsCHOP.tox
TouchDesigner099 build 2019.16190
(1.49 KiB) Downloaded 81 times
User avatar
snaut
Staff
 
Posts: 904
Joined: Mon Nov 12, 2007 6:21 pm
Location: Toronto

Re: Detecting the presence and location of non black pixels

Postby snaut » Wed Jun 12, 2019 5:08 pm

I should mention that the glsl version requires glsl version 4.6

Cheers
Markus
User avatar
snaut
Staff
 
Posts: 904
Joined: Mon Nov 12, 2007 6:21 pm
Location: Toronto

Re: Detecting the presence and location of non black pixels

Postby snaut » Wed Jun 12, 2019 5:30 pm

One more. This one uses a uv map, multiplies the incoming image with it and then analyzes the min and max to get the values. No shader required...

Cheers
Markus
Attachments
textBoundsTOP2.tox
(1.35 KiB) Downloaded 81 times
User avatar
snaut
Staff
 
Posts: 904
Joined: Mon Nov 12, 2007 6:21 pm
Location: Toronto

Re: Detecting the presence and location of non black pixels

Postby snaut » Thu Jun 13, 2019 2:15 pm

I've moved your DeckLink Question here: viewtopic.php?f=4&t=19508

Best
Markus
User avatar
snaut
Staff
 
Posts: 904
Joined: Mon Nov 12, 2007 6:21 pm
Location: Toronto

Re: Detecting the presence and location of non black pixels

Postby respectthecode » Wed Jun 19, 2019 4:47 pm

I am running into a synchronization problem with these approaches. Basically the CHOP is a frame or 2 behind the video so you see the video change and then the box moves a frame or 2 later. How can I delay the video to keep them in sync?
respectthecode
 
Posts: 19
Joined: Mon Jul 16, 2018 8:50 am

Re: Detecting the presence and location of non black pixels

Postby malcolm » Wed Jun 19, 2019 5:15 pm

You can use a Cache TOP to delay video. This should do the trick I think
User avatar
malcolm
Staff
 
Posts: 4424
Joined: Tue Nov 13, 2007 1:11 am

Re: Detecting the presence and location of non black pixels

Postby respectthecode » Wed Jun 19, 2019 7:37 pm

How would I figure out how much delay to add? It appears to be variable based on CPU load. Is there a way to get the processing time from a OP? Would that even work or would it be too late?
respectthecode
 
Posts: 19
Joined: Mon Jul 16, 2018 8:50 am

Re: Detecting the presence and location of non black pixels

Postby snaut » Thu Jun 20, 2019 12:05 am

Which approach are you using?
User avatar
snaut
Staff
 
Posts: 904
Joined: Mon Nov 12, 2007 6:21 pm
Location: Toronto

Re: Detecting the presence and location of non black pixels

Postby respectthecode » Thu Jun 20, 2019 12:20 pm

I didn't understand what the TOP approach was doing so I went with the CHOP. I might need to go back to try this with the TOP2 approach.

Here is what I have.
Attachments
Lyrics.7.toe
(6.01 KiB) Downloaded 61 times
respectthecode
 
Posts: 19
Joined: Mon Jul 16, 2018 8:50 am

Next

Return to Beginners

Who is online

Users browsing this forum: Bing [Bot] and 14 guests