Exemplo n.º 1
0
def features(inMat, sizeData):
    # 抠取中间区域
    center_rect = getCenterRect(inMat)
    x, y, w, h = center_rect
    roi = inMat[y:y + h, x:x + w]

    # low data feature
    low_data = cv2.resize(roi, (sizeData, sizeData))

    VERTICAL = 0
    HORIZONTAL = 1
    # Histogram feature
    vhist = PlateJudger.ProjectedHistogram(low_data, VERTICAL)
    hhist = PlateJudger.ProjectedHistogram(low_data, HORIZONTAL)

    # print vhist.shape
    # print hhist.shape
    # print low_data

    numCols = vhist.shape[1] + hhist.shape[
        1] + low_data.shape[0] * low_data.shape[1]
    outMat = np.zeros((1, numCols))

    # feature,ANN的样本特征为水平、垂直直方图和低分辨率图像所组成的矢量
    index = 0
    for i in range(0, vhist.shape[1]):
        outMat[0, index] = vhist[0, i]
        index += 1

    # print outMat

    for i in range(0, hhist.shape[1]):
        outMat[0, index] = hhist[0, i]
        index += 1

    for i in range(0, low_data.shape[0]):
        for j in range(0, low_data.shape[0]):
            outMat[0, index] = low_data[i, j]
            index += 1

    return outMat