def HPlusSolution(s1, s2):
  col = SolutionFactory()
  s1.Reset()
  s2.Reset()
  s1_margin = 0
  s2_margin = s1.CurSpan()
  s2.MoveToMargin(s2_margin)
  while True:
    # When forming the composite cost gradient and intercept, we must
    # eliminate the over-counting of the last line of the s1, which is
    # attributable to its projection beyond the margins.
    g1 = s1.CurGradient()
    g2 = s2.CurGradient()
    overhang0 = s2_margin - options.m0  # s2_margin = m1 + span of s1
    overhang1 = s2_margin - options.m1  # s2_margin = m1 + span of s1
    g_cur = (g1 + g2 -
             options.c0 * (overhang0 >= 0) -
             options.c1 * (overhang1 >= 0))
    i_cur = (s1.CurValueAt(s1_margin) + s2.CurValueAt(s2_margin) -
             options.c0 * max(overhang0, 0) -
             options.c1 * max(overhang1, 0))
    # The Layout computed by the following implicitly sets the margin
    # for s2 at the end of the last line printed for s1.
    col.Append(s1_margin, s1.CurSpan() + s2.CurSpan(), i_cur, g_cur,
               Layout([LayoutElement.PrintLayout(s1.CurLayout()),
                       LayoutElement.PrintLayout(s2.CurLayout())]))
    # Move to the knot closest to the margin of the corresponding
    # component.
    kn1 = s1.NextKnot()
    kn2 = s2.NextKnot()
    if kn1 == INFINITY and kn2 == INFINITY: break
    # Note in the following that one of kn1 or kn2 may be infinite.
    if kn1 - s1_margin <= kn2 - s2_margin:
      s1.Advance()
      s1_margin = kn1
      s2_margin = s1_margin + s1.CurSpan()
      # Note that s1.CurSpan() may have changed, and s2_margin may
      # decrease, so we cannot simply increment s2's index.
      s2.MoveToMargin(s2_margin)
    else:
      s2.Advance()
      s2_margin = kn2
      s1_margin = s2_margin - s1.CurSpan()
  return col.MkSolution()
Save feature location and descriptor to file.
dataset/ETHPy150Open google/rfmt/formatter/support.py/HPlusSolution--crossover with--dataset/ETHPy150Open jesolem/PCV/pcv_book/sift.py/write_features_to_file