Ejemplo n.º 1
0
def dirPicTest():

	clf = joblib.load('model/svm.pkl')
	print type(clf)
	print clf

	platePath = 'resource/general_test'
	for root, dirs, files in os.walk( platePath ):
		print len(files)	
		for file in files:
			path = os.path.join( root, file )
			print 'loading....',path
			imgPlate = cv2.imread(path,cv2.IMREAD_COLOR)
			PlateLocater.m_debug = False
			Result = PlateLocater.fuzzyLocate(imgPlate)

			for plate in Result:
				
				feature = PlateJudger.getHistogramFeatures(plate)
				res = clf.predict(feature)
				
				flag = (res==1)
				print flag[0]

				if flag[0]:
					cv2.imshow('test',plate)
					cv2.waitKey(0)
					cv2.destroyAllWindows()

				
				


	return None
Ejemplo n.º 2
0
def main():
	# version 3.0.0
	# version 2.4.11
	print cv2.__version__

	imgPlate = cv2.imread('plate_judge.jpg',cv2.IMREAD_COLOR)

	PlateLocater.m_debug = False
	Result = PlateLocater.fuzzyLocate(imgPlate)

	print type(Result)
	print '候选车牌数量:',len(Result)
	print Result[0].shape

	platesJudge(Result)

	# imgGray = cv2.cvtColor(imgPlate,cv2.COLOR_BGR2GRAY)
	# cv2.imshow('src',imgGray)
	# imgEqulhist = cv2.equalizeHist(imgGray)
	# cv2.imshow('equal',imgEqulhist)
	cv2.waitKey(0)
	cv2.destroyAllWindows()


	# box = cv2.boxPoints(mr)  # if you are use opencv 3.0.0
	# box = cv2.cv.boxPoints(mr) # if your are using opencv 2.4.11

	# svm 参考
	# http://answers.opencv.org/question/5713/save-svm-in-python/
	#

	# 遇到的问题
	# http://answers.opencv.org/question/55152/unable-to-find-knearest-and-svm-functions-in-cv2/

	return None
Ejemplo n.º 3
0
def CV_dirPicTest():
	model = CV_trainModel()

	platePath = 'resource/general_test'
	for root, dirs, files in os.walk( platePath ):
		print len(files)	
		for file in files:
			path = os.path.join( root, file )
			print 'loading....',path
			imgPlate = cv2.imread(path,cv2.IMREAD_COLOR)
			PlateLocater.m_debug = False
			Result = PlateLocater.fuzzyLocate(imgPlate)

			for plate in Result:
				
				feature = PlateJudger.getHistogramFeatures(plate)

				print feature.dtype

				feature = np.float32(feature)
				res = model.predict(feature)
				
				a = (res==1)
				print a[0]

				if a[0]:
					cv2.imshow('test',plate)
					cv2.waitKey(0)
					cv2.destroyAllWindows()
Ejemplo n.º 4
0
def CV_PicTest():
	model = CV_trainModel()

	imgPlate = cv2.imread('plate_judge.jpg',cv2.IMREAD_COLOR)

	PlateLocater.m_debug = False
	Result = PlateLocater.fuzzyLocate(imgPlate)

	for plate in Result:
		cv2.imshow('test',plate)
		feature = PlateJudger.getHistogramFeatures(plate)
		feature = np.float32(feature)
		res = model.predict(feature)
		print res
		cv2.waitKey(0)
		cv2.destroyAllWindows()
Ejemplo n.º 5
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
Ejemplo n.º 6
0
def test_plate_locate():
    PlateLocater.m_debug = False
    rootdir = "resources/easy_test"
    print 'test_plate_locate'

    for parent,dirnames,filenames in os.walk(rootdir):        
        index_file = 0
        print filenames        
        for filename in filenames:
                cv2.destroyAllWindows()
                index_file += 1

                imgPlate = cv2.imread(os.path.join(parent,filename),cv2.IMREAD_COLOR)
                print '文件名:',filename.split('.')[0]

                cv2.imshow("原图",imgPlate)
                Result = PlateLocater.fuzzyLocate(imgPlate)
                print '候选车牌数量:',len(Result)

                index_loc = 0
                for img in Result:
                    index_loc += 1
                    cv2.imshow("候选车牌"+str(index_loc),img)
                cv2.waitKey(0)

                resultVec = PlateJudger.platesJudge(Result)
                print 'SVM筛选后的车牌数量:',len(resultVec)

                index_loc = 0
                for img in resultVec:
                    index_loc += 1
                    cv2.imshow("SVM-"+str(index_loc),img)
                cv2.waitKey(0)


                if index_file >20:
                     break
Ejemplo n.º 7
0
def test_plate_locate():
    PlateLocater.m_debug = False
    rootdir = "resources/easy_test"
    print 'test_plate_locate'

    for parent, dirnames, filenames in os.walk(rootdir):
        index_file = 0
        print filenames
        for filename in filenames:
            cv2.destroyAllWindows()
            index_file += 1

            imgPlate = cv2.imread(os.path.join(parent, filename),
                                  cv2.IMREAD_COLOR)
            print '文件名:', filename.split('.')[0]

            cv2.imshow("原图", imgPlate)
            Result = PlateLocater.fuzzyLocate(imgPlate)
            print '候选车牌数量:', len(Result)

            index_loc = 0
            for img in Result:
                index_loc += 1
                cv2.imshow("候选车牌" + str(index_loc), img)
            cv2.waitKey(0)

            resultVec = PlateJudger.platesJudge(Result)
            print 'SVM筛选后的车牌数量:', len(resultVec)

            index_loc = 0
            for img in resultVec:
                index_loc += 1
                cv2.imshow("SVM-" + str(index_loc), img)
            cv2.waitKey(0)

            if index_file > 20:
                break