您所描述的是一个匹配滤波器,您所需要的只是一个互相关函数,它应该是任何合理的 DSP 库的一部分。 根据您选择的处理器架构和语言,您甚至可以找到可以更有效地执行此操作的矢量化库。
如果你真的不关心性能,你可以使用 Python ......
$ python
Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy
>>> interesting_clip = [ 5, 7, 2, 1]
>>> full_stream = [ 1, 5, 7, 2, 1, 4, 3, 2, 4, 7, 1, 2, 2, 5, 1]
>>> correlation = scipy.correlate (full_stream, interesting_clip)
>>> print correlation
[56 79 55 28 41 49 44 53 73 48 28 35]
>>> for offset, value in enumerate(correlation) :
... if (value > 60) :
... print "match at position", offset, "with value of", value
...
match at position 1 with value of 79
match at position 8 with value of 73
我上面的门槛是任意的。您应该通过实验确定什么适合您。
请记住,您的“有趣剪辑”越长,计算相关性所需的时间就越长。虽然较长的剪辑有助于实际匹配从非匹配中脱颖而出,但您可能只需要几秒钟。