Exemplo n.º 1
0
def catch_number(y, framerate, nframes):
    frh = []
    frl = []
    math_list = [] # 存放频率
    # DTMF编码
    fruquent = [697, 770, 852, 941, 1209, 1336, 1477, 1633]
    math = {(697, 1209): '1', (697, 1336): '2', (697, 1477): '3', (697, 1633): 'A',
            (770, 1209): '4', (770, 1336): '5', (770, 1477): '6', (770, 1633): 'B',
            (852, 1209): '7', (852, 1336): '8', (852, 1477): '9', (852, 1633): 'C',
            (941, 1209): '*', (941, 1336): '0', (941, 1477): '#', (941, 1633): 'D'}
    for fr in fruquent:
        sum1 = sum(y[fr* nframes //framerate-(20* nframes //framerate):fr* nframes //framerate])
        sum2 = sum(y[fr* nframes //framerate:fr * nframes //framerate+(20* nframes //framerate)])
        sumx = sum1 + sum2
        if fr < 1000:
            frl.append([fr, sumx])
        else:
            frh.append([fr, sumx])
    frl = sorted(frl, key=lambda x: x[1])
    frh = sorted(frh, key=lambda x: x[1])
    frl = frl.pop()
    frh = frh.pop()
    if frh[1] < 10:
        return None
    if frl[1] < 10:
        return None
    math_list.append(frl[0])
    math_list.append(frh[0])
    math_list = tuple(math_list)
    for key, value in math.items():
        if key == math_list:
            return value
Exemplo n.º 2
0
def getMathUptLut(scaleMap, obj1, obj2, math=None):
    precision_math = getPrecisionByName(scaleMap, obj1, obj2, 'Math')

    rc = {}
    for cut, func in list(math.items()):
        scale1 = getScaleByName(scaleMap, obj1, cut)
        scale2 = getScaleByName(scaleMap, obj2, cut)
        vec = tmEventSetup.DoubleVec()
        lut = tmEventSetup.LlongVec()
        n = tmEventSetup.getDeltaVector(vec, scale1, scale2)
        func(vec, n)
        tmEventSetup.setLut(lut, vec, precision_math)
        rc[func.__name__] = lut

    precision_pt = getPrecisionByName(scaleMap, obj1, obj2, 'MassPt')
    if obj1 == obj2:
        key = '-'.join([obj1, 'UPT'])
        rc['Key'] = key
        rc[key] = getUptLut(scaleMap, obj1, precision_pt)

    return rc