# Path: moonlight/glyphs/base.py
# class GlyphsTensorColumns(enum.IntEnum):
# class BaseGlyphClassifier(object):
#   STAFF_INDEX = 0
#   Y_POSITION = 1
#   X = 2
#   TYPE = 3
#   def __init__(self):
#   def get_detected_glyphs(self):
#   def glyph_predictions_to_page(self, predictions):
#     def create_glyph(glyph):
#     def generate_staff(staff_num):


import abc
import numpy as np
import tensorflow as tf
from moonlight.glyphs import base
from moonlight.protobuf import musicscore_pb2
    """
    glyphs = []
    num_staves, num_stafflines, width = predictions_arr.shape
    for staff in range(num_staves):
      for staffline in range(num_stafflines):
        y_position = num_stafflines // 2 - staffline
        run_start = -1
        run_value = musicscore_pb2.Glyph.NONE
        for x in range(width + 1):
          if x < width:
            value = predictions_arr[staff, staffline, x]
          if x == width or value != run_value:
            if run_value > musicscore_pb2.Glyph.NONE:
              # Process the current run if it is at least run_min_length pixels.
              if x - run_start >= self.run_min_length:
                glyph_center_x = (run_start + x) // 2
                glyphs.append(
                    self._create_glyph_arr(staff, y_position, glyph_center_x,
                                           run_value))
            run_value = value
            run_start = x
    # Convert to a 2D array.
    glyphs = np.asarray(glyphs, np.int32)
    return np.reshape(glyphs, (-1, 4))

  def _create_glyph_arr(self, staff_index, y_position, x, type_value):
    glyph = np.empty(len(base.GlyphsTensorColumns), np.int32)
    glyph[base.GlyphsTensorColumns.STAFF_INDEX] = staff_index
    glyph[base.GlyphsTensorColumns.Y_POSITION] = y_position
    glyph[base.GlyphsTensorColumns.X] = x

# Path: moonlight/glyphs/base.py
# class GlyphsTensorColumns(enum.IntEnum):
# class BaseGlyphClassifier(object):
#   STAFF_INDEX = 0
#   Y_POSITION = 1
#   X = 2
#   TYPE = 3
#   def __init__(self):
#   def get_detected_glyphs(self):
#   def glyph_predictions_to_page(self, predictions):
#     def create_glyph(glyph):
#     def generate_staff(staff_num):


# Path: moonlight/glyphs/convolutional.py
import abc
import numpy as np
import tensorflow as tf
from moonlight.glyphs import base
from moonlight.protobuf import musicscore_pb2

    """
    glyphs = []
    num_staves, num_stafflines, width = predictions_arr.shape
    for staff in range(num_staves):
      for staffline in range(num_stafflines):
        y_position = num_stafflines // 2 - staffline
        run_start = -1
        run_value = musicscore_pb2.Glyph.NONE
        for x in range(width + 1):
          if x < width:
            value = predictions_arr[staff, staffline, x]
          if x == width or value != run_value:
            if run_value > musicscore_pb2.Glyph.NONE:
              # Process the current run if it is at least run_min_length pixels.
              if x - run_start >= self.run_min_length:
                glyph_center_x = (run_start + x) // 2
                glyphs.append(
                    self._create_glyph_arr(staff, y_position, glyph_center_x,
                                           run_value))
            run_value = value
            run_start = x
    # Convert to a 2D array.
    glyphs = np.asarray(glyphs, np.int32)
    return np.reshape(glyphs, (-1, 4))

  def _create_glyph_arr(self, staff_index, y_position, x, type_value):
    glyph = np.empty(len(base.GlyphsTensorColumns), np.int32)
    glyph[base.GlyphsTensorColumns.STAFF_INDEX] = staff_index
    glyph[base.GlyphsTensorColumns.Y_POSITION] = y_position
    glyph[base.GlyphsTensorColumns.X] = x

    glyph[base.GlyphsTensorColumns.TYPE] = type_value