예제 #1
0
def plateRecognize(inMat):
    PlateLocater.m_debug = False
    CharsIndentifier.m_debug = False

    Result = PlateLocater.fuzzyLocate(inMat)

    if m_debug:
        print '候选车牌数量:',len(Result)
        index_loc = 0
        for img in Result:
            index_loc += 1
            cv2.imshow("候选车牌"+str(index_loc),img)
        cv2.waitKey(0)
        cv2.destroyAllWindows()

    resultVec = PlateJudger.platesJudge(Result)
    

    if m_debug:
        print 'SVM筛选后的车牌数量:',len(resultVec)
        index_loc = 0
        for img in resultVec:
            index_loc += 1
            cv2.imshow("SVM-"+str(index_loc),img)
            cv2.imwrite("debug/SVM-"+str(index_loc)+".jpg", img)
        cv2.waitKey(0)
        cv2.destroyAllWindows()

    lisences = list()
    for img_plate in resultVec:
        segmented = CharsSegmenter.charsSegment(img_plate)

        if m_debug:
            index_char = 0
            for char in segmented:
                index_char += 1
                cv2.imshow("chars_segment"+str(index_char), char)
                cv2.imwrite("debug/segmented-"+str(index_char)+".jpg", char)

            cv2.waitKey(0)
            cv2.destroyAllWindows()

        lisence = CharsIndentifier.identifyPlate(segmented)
        # print lisence
        lisences.append(lisence)

    return lisences
예제 #2
0
def test_chars_segment():
    print "test_chars_segment"
    img_plate = cv2.imread("resources/image/chars_segment.jpg",cv2.IMREAD_COLOR)
    cv2.imshow("test",img_plate)

    # print cv2.countNonZero(img_plate[:,:,0])
    # print img_plate.shape[0],img_plate.shape[1],img_plate.shape[1]*img_plate.shape[0]
    # cv2.waitKey(0)
    # cv2.destroyAllWindows()

    segmented = CharsSegmenter.charsSegment(img_plate)

    index_char = 0
    for char in segmented:
        index_char += 1
        cv2.imshow("chars_segment"+str(index_char), char)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
예제 #3
0
def test_chars_segment():
    print "test_chars_segment"
    img_plate = cv2.imread("resources/image/chars_segment.jpg",
                           cv2.IMREAD_COLOR)
    cv2.imshow("test", img_plate)

    # print cv2.countNonZero(img_plate[:,:,0])
    # print img_plate.shape[0],img_plate.shape[1],img_plate.shape[1]*img_plate.shape[0]
    # cv2.waitKey(0)
    # cv2.destroyAllWindows()

    segmented = CharsSegmenter.charsSegment(img_plate)

    index_char = 0
    for char in segmented:
        index_char += 1
        cv2.imshow("chars_segment" + str(index_char), char)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
예제 #4
0
def test_chars_identify():
    print "test_chars_identify"
    img_plate = cv2.imread("resources/image/chars_identify.jpg",cv2.IMREAD_COLOR)

    # 车牌分割
    segmented = CharsSegmenter.charsSegment(img_plate)
    licence = ''
    CharsIndentifier.initModel()
    for index, char in enumerate(segmented):
        print 'char:'
        print char
        # licence += CharsIndentifier.identify(char)
        char_feature = CharsIndentifier.features(char,kPredictSize)
        if index == 0:
            char_text = CharsIndentifier.identifyChinese(char_feature)
        else:
            char_text = CharsIndentifier.identifyDigitLetter(char_feature)
        licence += char_text


    print "识别结果:"
    print licence
예제 #5
0
def test_chars_identify():
    print "test_chars_identify"
    img_plate = cv2.imread("resources/image/chars_identify.jpg",
                           cv2.IMREAD_COLOR)

    # 车牌分割
    segmented = CharsSegmenter.charsSegment(img_plate)
    licence = ''
    CharsIndentifier.initModel()
    for index, char in enumerate(segmented):
        print 'char:'
        print char
        # licence += CharsIndentifier.identify(char)
        char_feature = CharsIndentifier.features(char, kPredictSize)
        if index == 0:
            char_text = CharsIndentifier.identifyChinese(char_feature)
        else:
            char_text = CharsIndentifier.identifyDigitLetter(char_feature)
        licence += char_text

    print "识别结果:"
    print licence