forked from leenachennuru/objRecognition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodeBookOrbKeyPoints.py
53 lines (44 loc) · 1.58 KB
/
codeBookOrbKeyPoints.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python
## Importing all the relevant modules
import numpy as np
import cv2
from matplotlib import pyplot as plt
import preObj as prePro
import detectorDescriptor2 as detDes
import glob
import os
## Set the path to the input folder and the output folder
rootInputName = "FinalExtensiveData/"
##Format in which the files should be created
formatName = "*.png"
## List of directories from which the data needs to be collected
listDir = [];
listDir.append("kettle-bb/")
listDir.append("milk-bb/")
listDir.append("basket-bb/")
listDir.append("mug-bb/")
listDir.append("kettle-bgbb/")
listDir.append("milk-bgbb/")
listDir.append("basket-bgbb/")
listDir.append("mug-bgbb/")
listDir.append("background/")
##Initializing the codebook and the number of directories that have been explored so far to collect the data
codeBook = np.zeros((1, 32))
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:
codeBook = np.concatenate((codeBook, des), axis =0)
print ("Found some non-zero keypoints for the countours.")
count = count + 1
dirCount = dirCount + 1
codeBook = codeBook[1:np.size(codeBook,0), :]
np.save("CodeBook/withNoise.npy", codeBook)