-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimageManager.py
More file actions
54 lines (44 loc) · 1.73 KB
/
imageManager.py
File metadata and controls
54 lines (44 loc) · 1.73 KB
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
54
#This module is responsible for choosing which image is shown, and the UI for image preview and managing.
import os
from objDetectVariables import image, bbox, boundingRect
import csv
imageFolder = os.path.dirname(os.path.realpath(__file__)) + "/data/picsAndAnnots/"
metaDataFile = os.path.dirname(os.path.realpath(__file__)) + "/data/data.metadata"
class imageManager:
extentions = ['.jpg']
#Array of images
images = []
def __init__(self):
#print(imageFolder)
return
#Retrieves Images from folders.
def getImages(self):
with open(metaDataFile, mode='r'):
_csv = csv.reader(f, dialect='excel', delimeter=',')
for row is _csv:
#self.storeImage(fileName, realFilePath, realAnnotPath)
self.storeImage(row[0], row[1], row[2])
return
def storeImage(self, imageName, imagePath, annotPath):
_bboxs = self.getImageAnnots(annotPath)
img = image(imagePath,annotPath, imageName, _bboxs)
self.images.append(img)
for _img in self.images:
for bbox in _img.getbboxAnnots():
print(bbox.getRect().x1())
return
def getImageAnnots(self, annotFilePath):
i = 3
_bboxs = []
with open(annotFilePath) as f :
for row in csv.reader(f, delimiter=',', dialect='excel'):
_rect = boundingRect( float(row[i+0]),float(row[i+1]), float(row[i+2]), float(row[i+3]))
_bbox = bbox(row[0], _rect)
_bboxs.append(_bbox)
return _bboxs
#Sets the current Image.
def setCurrentImage(self):
return
if __name__== "__main__":
imgclass = imageManager()
imgclass.getImages()