def histogramContour(des,codeBookCenters):
	histPoints = classifier.minDistance(des,codeBookCenters)
	return histPoints[0]
def histogramContour(des, codeBookCenters):
    histPoints = classifier.minDistance(des, codeBookCenters)
    return histPoints[0]
listDir.append("background/")

histogramSVM = []
labels = []
HistogramComputed = 0
# testing the things
dirCount = 0
for direct in listDir:
	fileList = glob.glob(rootInputName + listDir[dirCount] + formatName)
	print ("Current Directory Name:" + rootInputName + listDir[dirCount])
	count = 0
	for files in fileList:
		inputImage=cv2.imread(fileList[count])
		fileName = os.path.basename(fileList[count])
		roiImageFiltered = inputImage
		kp, roiKeyPointImage = detDes.featureDetectCorner(roiImageFiltered)
		kp, des, roiKeyPointImage = detDes.featureDescriptorORB(roiImageFiltered, kp)
		if np.size(kp)>0:
			histPoints = classifier.minDistance(des,codeBookCenters)
			histogramSVM.append(histPoints[0])
			labels.append([dirCount])
			HistogramComputed = HistogramComputed + 1
			print ("Histogram computed for the chosen Image. directory = " + str(dirCount) + 'image number' + str(count))
		count = count + 1	
	dirCount = dirCount + 1

histogramNew  = np.float32(np.array(histogramSVM))
labelsNew  = np.float32(np.array(labels))

np.save("SVM/TrainingData25000.npy", histogramNew)
np.save("SVM/TrainingLabels25000.npy", labelsNew)
Example #4
0
histogramSVM = []
labels = []
HistogramComputed = 0
# testing the things
dirCount = 0
for direct in listDir:
    fileList = glob.glob(rootInputName + listDir[dirCount] + formatName)
    print("Current Directory Name:" + rootInputName + listDir[dirCount])
    count = 0
    for files in fileList:
        inputImage = cv2.imread(fileList[count])
        fileName = os.path.basename(fileList[count])
        roiImageFiltered = inputImage  #cv2.medianBlur(inputImage, 3)
        kp, roiKeyPointImage = detDes.featureDetectCorner(roiImageFiltered)
        kp, des, roiKeyPointImage = detDes.featureDescriptorORB(
            roiImageFiltered, kp)
        if np.size(kp) > 0:
            histPoints = classifier.minDistance(des, codeBookCenters)
            histogramSVM.append(histPoints[0])
            labels.append([dirCount])
            HistogramComputed = HistogramComputed + 1
            print("Histogram computer for the chosen Image.")
        count = count + 1
    dirCount = dirCount + 1

histogramNew = np.float32(np.array(histogramSVM))
labelsNew = np.float32(np.array(labels))

np.save("TrainingSet/SVMCodes/Noise/Testing/TestingData.npy", histogramNew)
np.save("TrainingSet/SVMCodes/Noise/Testing/TestingLabels.npy", labelsNew)