Example #1
0
 def calibration_setUp(self, needle, haystack, calibrate_backends):
     # use a single finder type for these tests
     finder = FeatureFinder()
     for category in calibrate_backends:
         finder.can_calibrate(category, True)
     calibrator = Calibrator(Image(needle), Image(haystack))
     return calibrator.calibrate(finder)
Example #2
0
#finder.params["text"]["datapath"].value = "../../misc"
#finder.params["ocr"]["oem"].value = 0
#finder.params["tdetect"]["verticalVariance"].value = 5
#finder.params["threshold"]["blockSize"].value = 3
# synchronize at this stage to take into account all configuration
finder.synchronize()

# Main steps: calibration, searching, and benchmarking
calibrator = Calibrator(NEEDLE, HAYSTACK)
# uncomment this to use a list of needles and haystacks instead
#calibrator = Calibrator(config="pairs.list")
calibrator.run = calibrator.run_performance
# uncomment these for alternative run functions
#calibrator.run = calibrator.run_default
#calibrator.run = calibrator.run_peak
similarity_before = calibrator.calibrate(finder, max_attempts=1)
# categories to calibrate
for category in ENABLED:
    finder.can_calibrate(category, True)
# example parameter to solo allow for calibration:
#finder.params["threshold2"]["blockSize"].fixed = False
similarity_after = calibrator.calibrate(finder,
                                        max_attempts=MAX_ATTEMPTS,
                                        max_exec_time=MAX_EXEC_TIME)
logging.info("Similarity before and after calibration: %s -> %s",
             similarity_before, similarity_after)
similarity_global = calibrator.search(finder,
                                      random_starts=RANDOM_STARTS,
                                      uniform=UNIFORM_DRAW,
                                      calibration=CALIBRATED_SEARCH,
                                      max_attempts=MAX_ATTEMPTS,