Exemple #1
0
    def __init__(self, result_dir, sampleModel: SamplesModel):

        self.workDir = propsmain.get('workdirpath')
        self.resultDir = os.path.join(self.workDir, result_dir)
        self.sampleCount = sampleModel.positives
        self.xAngle = sampleModel.x_angle
        self.yAngle = sampleModel.y_angle
        self.zAngle = sampleModel.z_angle
        self.iDev = sampleModel.max_dev
        self.w = sampleModel.w
        self.h = sampleModel.h

        self.perlScript = os.path.join(
            BASE_DIR, 'earTrainer/scripts/createtrainsamples.pl')
        self.samplesRootPath = propsmain.get('samplespath')
        self.samplesDir = sampleModel.samples_dir
        self.negativesDir = 'negatives'

        self.imageFormat = propsmain.get('imageformat')
        self.samplesModel = sampleModel

        self.positivesDat = 'None'
        self.negativesDat = 'None'

        if not os.path.exists(self.workDir):
            os.mkdir(self.workDir)
        if os.path.exists(self.resultDir):
            shutil.rmtree(self.resultDir)
        os.mkdir(self.resultDir)
Exemple #2
0
    def __init__(self, trainModel: TrainerModel):

        self.resultDir = trainModel.name

        #ukladanie do vedlajsieho precinka
        self.resultDir = propsmain.get('resultsdir')
        self.workDir = propsmain.get('workdirpath')
        self.samplesDir = trainModel.positives.name

        self.numPos = trainModel.positives.positives
        self.numNeg = trainModel.negatives
        self.numStages = trainModel.num_stages
        self.precalcValBuf = trainModel.precalcValBuf
        self.precalcIdxBuf = trainModel.precalcIdxBuf
        self.numThreads = trainModel.numThreads
        self.acceptBreak = trainModel.acceptanceBreak
        self.w = trainModel.positives.w
        self.h = trainModel.positives.h
        self.bt = trainModel.bt
        self.minHitRate = trainModel.minHitRate
        self.maxFalseAlarm = trainModel.maxFalseAlarm
        self.weightTrimRate = trainModel.weightTrimRate
        self.maxDepth = trainModel.maxDepth
        self.maxWeakCount = trainModel.maxWeakCount
        self.featureType = trainModel.featureType
        self.trainerModel = trainModel
        self.mode = trainModel.mode

        self.opencv_trainer = 'opencv_traincascade.exe'
        if platform == 'linux':
            self.opencv_trainer = self.opencv_trainer[:-4]
Exemple #3
0
def get_all_xmls():
    # all_xmls = glob.glob(BASE_DIR + '/earDetector/xml/*.xml')
    # xmls = list()
    # for one_xml in all_xmls:
    #     xmls.append((os.path.basename(one_xml), one_xml))

    xmls = get_files(os.path.join(properties.get('testerdir'), 'xmls/'),
                     '.xml')
    return xmls
Exemple #4
0
    def __init__(self,samplesDir='samples/',descriptor='descriptor.txt'):
        self.root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


        self.root = propsmain.get('testerdir')

        self.descriptor_dir = os.path.join(self.root,'descriptors/')
        if not os.path.exists(self.descriptor_dir):
            os.makedirs(self.descriptor_dir)

        self.results = os.path.join(self.root,'results/')
        self.samples = os.path.join(self.root, samplesDir)

        if not os.path.exists(os.path.join(self.descriptor_dir,descriptor)):
            raise FileNotFoundError('Descriptor '+self.descriptor+' not found in '+self.descriptor_dir)
        self.descriptor = os.path.join(self.descriptor_dir,descriptor)
Exemple #5
0
    def __init__(self,
                 xml_ear_file='',
                 descriptor_name='descriptor.txt',
                 trainer_name='default',
                 custom=False,
                 samples_dir='samples/'):
        self.root_dir = os.path.dirname(
            os.path.dirname(os.path.abspath(__file__)))

        self.custom = custom
        self.root_dir = propsmain.get('testerdir')

        self.xmls_dir = os.path.join(self.root_dir, 'xmls/')
        if not os.path.exists(self.xmls_dir):
            os.makedirs(self.xmls_dir)

        self.detector = None
        self.xml_file = ''
        self.xml_ear_file = xml_ear_file

        if xml_ear_file is not '' and not custom:
            #copy to xmls dir
            new_name = trainer_name + '.xml'
            copyfile(xml_ear_file, os.path.join(self.xmls_dir, new_name))
            self.xml_file = os.path.join(self.xmls_dir, new_name)
            #os.rename(os.path.join(self.xmls_dir,'cascade.xml'),self.xml_file)
            self.detector = cv2.CascadeClassifier(self.xml_file)
            self.result_dir = os.path.join(self.root_dir, 'results/')
        else:
            self.detector = cv2.CascadeClassifier(self.xml_ear_file)

        self.result_file_name = 'results.txt'
        self.result_ear_not_found = 'not_found.txt'

        self.testing_samples = os.path.join(self.root_dir, samples_dir)
        self.descriptor = descriptor_name
        self.penalty = 0
        self.comparator = Comparator(samplesDir=self.testing_samples,
                                     descriptor=self.descriptor)
Exemple #6
0
 def __init__(self, xmlfile, type):
     self.detector = cv2.CascadeClassifier(
         os.path.join(properties.get('testerdir'), 'xmls', xmlfile))
     self.equalizer = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(4, 4))
     self.result_images = list()
     self.type = type
Exemple #7
0
def get_all_descriptors():
    return get_files(os.path.join(properties.get('testerdir'), 'descriptors/'),
                     '.txt')
Exemple #8
0
def get_all_test_dir():
    return get_dirs(properties.get('testerdir'),
                    ['xmls', 'results', 'descriptors'])
Exemple #9
0
def get_all_samples_dir():
    return get_dirs(properties.get('samplespath'))