Пример #1
0
 def __init__(self,
              basepath,
              annofile,
              annomode,
              extraannofile=None,
              showwidth=1280):
     """
     :param basepath: base directory for panda image data and annotations
     :param annofile: annotation file path
     :param annomode: the type of annotation, which can be 'person', 'vehicle', 'person&vehicle', 'headbbox' or 'headpoint'
     :param extraannofile: if you want to show person and vehicle annotations simultaneously,
                             choose annomode 'person&vehicle' and send vehicle annotation file path into extraannofile
     :param showwidth: the width of visualized image
     """
     assert annomode in IMAGE_ANNO_MODE, 'Annotation mode must be \'person\', \'vehicle\', \'person&vehicle\', \'headbox\' or \'headpoint\''
     self.annomode = annomode
     self.basepath = basepath
     self.annofile = annofile
     self.extraannofile = extraannofile
     self.showwidth = showwidth
     self.imagepath = os.path.join(basepath, 'image_train')
     self.annopath = os.path.join(basepath, 'image_annos', annofile)
     if extraannofile:
         self.extraannopath = os.path.join(basepath, 'image_annos',
                                           extraannofile)
     self.imgpaths = util.GetFileFromThisRootDir(self.imagepath, ext='jpg')
     self.annos = defaultdict(list)
     self.extraannos = defaultdict(list)
     self.createIndex()
Пример #2
0
 def __init__(self,
              basepath,
              annofile,
              annomode,
              addmode,
              savepath,
              showcate,
              extraannofile=None,
              showwidth=1024):
     """
     :param basepath: base directory for panda image data and annotations
     :param annofile: annotation file path
     :param annomode: the type of annotation, which can be 'person', 'vehicle', 'person&vehicle', 'headbbox' or 'headpoint'
     :param extraannofile: if you want to show person and vehicle annotations simultaneously,
                             choose annomode 'person&vehicle' and send vehicle annotation file path into extraannofile
     :param showwidth: the width of visualized image
     """
     self.showcate = showcate
     self.annomode = annomode
     self.savepath = savepath
     self.basepath = basepath
     self.annofile = annofile
     self.addmode = addmode
     self.extraannofile = extraannofile
     self.showwidth = showwidth
     self.imagepath = os.path.join(basepath, self.addmode)
     self.annopath = os.path.join(basepath, 'image_annos', annofile)
     # self.extraannopath = os.path.join(basepath, 'image_annos', extraannofile)
     self.imgpaths = util.GetFileFromThisRootDir(self.imagepath, ext='jpg')
     self.annos = defaultdict(list)
     self.extraannos = defaultdict(list)
     self.createIndex()
Пример #3
0
 def __init__(
     self,
     basepath,
     resfile,
     splitannofile,
     srcannofile,
     outpath,
     outfile,
     imgext='.jpg',
     code='utf-8',
 ):
     """
     :param basepath: base directory for panda image data and annotations
     :param resfile: detection result file path
     :param splitannofile: generated split annotation file
     :param srcannofile: source annotation file
     :param resmode: detection result mode, which can be 'person', 'vehicle', 'headbbox' or 'headpoint'
     :param outpath: output base path for merged result file
     :param outfile: name for merged result file
     :param imgext: ext for the split image format
     """
     self.basepath = basepath
     self.resfile = resfile
     self.splitannofile = splitannofile
     self.srcannofile = srcannofile
     self.outpath = outpath
     self.outfile = outfile
     self.imgext = imgext
     self.code = code
     self.imgpath = os.path.join(self.basepath, 'PANDA_IMAGE')
     self.respath = os.path.join(self.basepath, 'results', resfile)
     self.splitannopath = os.path.join(self.basepath, 'image_annos',
                                       splitannofile)
     self.srcannopath = os.path.join(self.basepath, 'image_annos',
                                     srcannofile)
     self.imagepaths = util.GetFileFromThisRootDir(self.imgpath, ext='jpg')
     if not os.path.exists(self.outpath):
         os.makedirs(self.outpath)
     self.results = defaultdict(list)
     self.indexResults()