code: def FromR(R):
      trace = np.trace(R)
  
      if trace > 0:
          qw = 0.5 * np.sqrt(1.0 + trace)
          qx = (R[2, 1] - R[1, 2]) * 0.25 / qw
          qy = (R[0, 2] - R[2, 0]) * 0.25 / qw
          qz = (R[1, 0] - R[0, 1]) * 0.25 / qw
      elif R[0, 0] > R[1, 1] and R[0, 0] > R[2, 2]:
          s = 2.0 * np.sqrt(1.0 + R[0, 0] - R[1, 1] - R[2, 2])
          qw = (R[2, 1] - R[1, 2]) / s
          qx = 0.25 * s
          qy = (R[0, 1] + R[1, 0]) / s
          qz = (R[0, 2] + R[2, 0]) / s
      elif R[1, 1] > R[2, 2]:
          s = 2.0 * np.sqrt(1.0 + R[1, 1] - R[0, 0] - R[2, 2])
          qw = (R[0, 2] - R[2, 0]) / s
          qx = (R[0, 1] + R[1, 0]) / s
          qy = 0.25 * s
          qz = (R[1, 2] + R[2, 1]) / s
      else:
          s = 2.0 * np.sqrt(1.0 + R[2, 2] - R[0, 0] - R[1, 1])
          qw = (R[1, 0] - R[0, 1]) / s
          qx = (R[0, 2] + R[2, 0]) / s
          qy = (R[1, 2] + R[2, 1]) / s
          qz = 0.25 * s
  
      return Quaternion(np.array((qw, qx, qy, qz)))
  
imports: import numpy
label_desc: Use image node_id 1 for calling the Quaternion obj's underlying member method code with example usage: obj.FromR(R) and returns: Quaternion