Reputation: 1
To make sure I do not xy-problem myself here, I am looking to identify timestamps within a VOD for a video game stream. For example, I would like to programatically capture the timestamps in which we see the GAME overlay for the end of a game here: https://youtu.be/L5dvJXSWf5w?t=671. Similar moments in a match can be seen such at 11:52 where the GO! is on screen.
There are slightly shifting aspects of this element GAME element where it has a white streak in the center that gets smaller over it's duration, but the "outline" is consistent. The naive approach that comes to mind would be to create a sort of template that either only has the outline of GAME, the innards or some sort of combination of the sort. Imgur album of templates: https://imgur.com/a/ssbu-game-templates-sU1kTBn
I've referenced similar posts, such as this one looking to capture the minimap in runescape and templateMatching with a transparent image.
Code I am attempting this with, iterating through all methods and all thresholds from 0.01 to 0.99
Example game images with intentionally varying quality: https://imgur.com/a/QbzU9LA
import cv2
import numpy as np
test_img = cv2.imread(test_path, cv2.IMREAD_UNCHANGED)
template_img = cv2.imread(template.template_path, cv2.IMREAD_UNCHANGED)
result = cv2.matchTemplate(test_img, template_img, method, none, template_img)
locations = np.where (result <= threshold)
locations = list(zip(*locations[::-1]))
if 0 < len(locations) < 2000:
print("method: ", method, "threshold:", threshold, "image:", i, "locations:", len(locations))
I've searched for similar issues, and I'm left wondering if this is somethign to manually calculate the alpha channel akin to this answer or if I am severely misunderstanding how the mask works as a whole, as some answers online implicate that the same template_image should work as the image_mask
Upvotes: 0
Views: 87