def prune(skeleton, ogml, iterations):
        assert skeleton.flags["C_CONTIGUOUS"]
        itime = time.time()

        xi, n, m = Cffi.to_double_pointer_copy(skeleton)
        yi = ffi.cast('int*', skeleton.ctypes.data)

        lib.prune(xi, yi, n, m, ogml['min_x'], ogml['max_x'], ogml['min_y'],
                  ogml['max_y'], iterations)
        Print.art_print("Pruning time: " + str(time.time() - itime),
                        Print.BLUE)
        return skeleton
    def prune(skeleton, ogml, iterations):

        x = [np.array(v, dtype='int32') for v in skeleton]
        xi = ffi.new(("int* [%d]") % (len(x)))
        for i in range(len(x)):
            xi[i] = ffi.cast("int *", x[i].ctypes.data)

        y = [np.array(v, dtype='int32') for v in skeleton]
        yi = ffi.new(("int* [%d]") % (len(y)))
        for i in range(len(y)):
            yi[i] = ffi.cast("int *", y[i].ctypes.data)

        lib.prune(xi, yi, len(x), len(x[0]), ogml['min_x'], ogml['max_x'], ogml['min_y'], ogml['max_y'], iterations)
        skeleton = cp_prune(skeleton, yi, skeleton.shape[0], skeleton.shape[1])

        return skeleton
Beispiel #3
0
    def prune(skeleton, ogml, iterations):
      itime = time.time()
      x = [np.array(v, dtype='int32') for v in skeleton]
      xi = ffi.new(("int* [%d]") % (len(x)))
      for i in range(len(x)):
        xi[i] = ffi.cast("int *", x[i].ctypes.data)

      y = [np.array(v, dtype='int32') for v in skeleton]
      yi = ffi.new(("int* [%d]") % (len(y)))
      for i in range(len(y)):
        yi[i] = ffi.cast("int *", y[i].ctypes.data)

      br_c = lib.prune(xi, yi, len(x), len(x[0]),
          ogml['min_x'], ogml['max_x'], ogml['min_y'], ogml['max_y'], iterations)

      # TODO: Must be faster!
      for i in range(skeleton.shape[0]):
        for j in range(skeleton.shape[1]):
          skeleton[i][j] = yi[i][j]
      Print.art_print("Pruning time: " + str(time.time() - itime), Print.BLUE)
      return skeleton