コード例 #1
0
 def __init__(self, concurrency=mp.cpu_count(), projection=2154, chunksize=100, printer=None):
     self.concurrency = concurrency
     self.projection = projection
     self.chunksize = chunksize
     self.printer = printer
     self.classifier, self.scaler = load_classifier_and_scaler()
     if sys.version_info > (3, 4):
         self.mp_context = mp.get_context("fork")
         # 'fork' is significantly faster than 'forkserver' or 'spawn'
         # it could use more memory but we avoid this by
         # creating the processes at the begining
     else:
         self.mp_context = multiprocessing
     self.queue = self.mp_context.Queue(concurrency * 2)
     self.start_processes()
コード例 #2
0
def main(argv):
  args = argv[1:]
  global VERBOSE
  i = 0
  while i < (len(args) - 1):
    if args[i] == "-v":
      VERBOSE=True
      del(args[i])
    else:
      i = i + 1
  if len(args) == 0 or len(args) > 2 or any([arg.startswith("-") for arg in args]):
      command_line_error("wrong argument", HELP_MESSAGE)
  else:
    input_filename = args[0]
    if len(args) > 1:
      output_filename = args[1]
    else:
      name,ext = os.path.splitext(input_filename)
      output_filename = name + "-prediction_segmente" + ext

    if VERBOSE: print "load " + input_filename + " ..."

    osm = OsmParser().parse(input_filename)
    #simplify(osm, 0.2, 0.2, 0.1)

    if VERBOSE: print "transform..."
    inputTransform, outputTransform = get_centered_metric_equirectangular_transformation_from_osm(osm)
    compute_transformed_position_and_annotate(osm, inputTransform)

    if VERBOSE: print "detect..."
    classifier, scaler = load_classifier_and_scaler()
    buildings = get_predicted_segmented_buildings(classifier, scaler, osm)
    if VERBOSE: print " -> ", len(buildings), "cas"

    output_osm = filter_buildings_junction(osm, buildings)
    
    if len(output_osm.nodes) > 0:
        if VERBOSE: print "save ", output_filename 
        OsmWriter(output_osm).write_to_file(output_filename)
    else:
        print "Nothing detected"

    return 0
コード例 #3
0
def main(argv):
    global VERBOSE
    VERBOSE = True
    osm_args = [f for f in argv[1:] if os.path.splitext(f)[1] in (".zip", ".osm")]
    other_args = [f for f in argv[1:] if os.path.splitext(f)[1] not in (".zip", ".osm")]
    if len(other_args) != 0:
        command_line_error("invalid argument: " + other_args[0], HELP_MESSAGE)
    if len(osm_args) == 0:
        command_line_error("not enough file.osm args", HELP_MESSAGE)

    classifier, scaler = load_classifier_and_scaler()

    score = 0

    for name, stream in open_zip_and_files_with_extension(osm_args, ".osm"):
        if VERBOSE: print "load " + name
        input_osm = OsmParser().parse_stream(stream)
        inputTransform, outputTransform = get_centered_metric_equirectangular_transformation_from_osm(input_osm)
        compute_transformed_position_and_annotate(input_osm, inputTransform)

        nb_ok, nb_missed, nb_false, missed_osm, false_osm = test_classifier(classifier, scaler, input_osm)

        if VERBOSE: print nb_ok, "correctly found"

        if len(missed_osm.ways) or nb_missed:
            missed_name = os.path.splitext(name)[0] + "-missed.osm"
            if VERBOSE: print nb_missed, " missed detections, write file", missed_name
            OsmWriter(missed_osm).write_to_file(missed_name)
        if len(false_osm.ways) or nb_false:
            false_name = os.path.splitext(name)[0] + "-false.osm"
            if VERBOSE: print nb_false, " false positives, write file", false_name
            OsmWriter(false_osm).write_to_file(false_name)
        score  += nb_ok * 2 - nb_missed - nb_false*10

    if VERBOSE: print "TOTAL SCORE (ok*3 - missed - false*10):"
    print score
    return 0