コード例 #1
0
def computeData(scene):
    isophote_mesh = scene.isophoteMesh()
    isophote_curves = isophote_mesh.isophoteCurves()

    data_list = []

    for isophote_curve in isophote_curves:
        isophote_segments = isophote_curve.toCurveSegments()

        for isophote_segment in isophote_segments:
            isophote_segment = isophote_segment.divide(
                int(0.2 * isophote_segment.numPoints()), int(0.5 * isophote_segment.numPoints())
            )

            if isophote_segment.numPoints() < 3:
                continue

            I = isophote_segment.isoValue()
            I = 2.0 * I - 1.0

            curvatures = isophote_segment.curvatures()
            curvatures = smoothing(curvatures, smooth=15.0)
            curvatures = curvatures / np.max(np.abs(curvatures))

            normals_gt = isophote_segment.normals()
            parameters = isophote_segment.arcLengthParameters()

            normals_al = NormalConeInterpolation(
                normals_gt[0], normals_gt[-1], isophote_segment.lightDir(), I
            ).interpolate(parameters)

            normals_al_error = angleErros(normals_gt, normals_al)

            cone_angle_changes = isophote_segment.coneAngleChanges()
            cone_angle_changes = smoothing(cone_angle_changes, smooth=0.05)
            cone_angle_changes = cone_angle_changes / np.max(np.abs(cone_angle_changes))

            misclassification = curvatures * cone_angle_changes

            ps = isophote_segment.points()

            misclassification_segments = clipSegments(ps, misclassification < 0)
            num_misclassification = len(np.where(misclassification < 0)[0])

            misclassification_rate = float(num_misclassification) / float(len(misclassification))

            data_list.append(
                {
                    "ps": ps,
                    "curvatures": curvatures,
                    "cone_angle_changes": cone_angle_changes,
                    "misclassification_segments": misclassification_segments,
                    "misclassification_rate": misclassification_rate,
                    "normals_gt": normals_gt,
                    "normals_al": normals_al,
                    "normals_al_error": normals_al_error,
                }
            )
    return data_list
コード例 #2
0
def computeData(scene):
    isophote_mesh = scene.isophoteMesh()
    isophote_curves = isophote_mesh.isophoteCurves()

    data_list = []

    for isophote_curve in isophote_curves:
        isophote_segments = isophote_curve.toCurveSegments()

        for isophote_segment in isophote_segments:
            L = isophote_segment.lightDir()
            isophote_segment = isophote_segment.divide(int(0.2 * isophote_segment.numPoints()), int(0.5 * isophote_segment.numPoints()))

            if isophote_segment.numPoints() < 3:
                continue

            I = isophote_segment.isoValue()
            I = 2.0 * I - 1.0

            normals_gt = isophote_segment.normals()
            parameters = isophote_segment.arcLengthParameters()
            normals_al = NormalConeInterpolation(normals_gt[0],
                                                 normals_gt[-1],
                                                 isophote_segment.lightDir(),
                                                 I).interpolate(parameters)
            #normals_al = arcLengthInterpolation(normals_gt[0], normals_gt[-1], parameters)
            normals_3D = np.array(normals_al)
            tangents_2D = isophote_segment.tangents()
            tangents_3D = projectTangent3D(tangents_2D, normals_3D)

            normals_3D = projectIteration(L, I, tangents_3D, normals_3D, parameters, 40)

            ps = isophote_segment.points()

            normals_al_error = angleErros(normals_gt, normals_al)
            normals_3d_error = angleErros(normals_gt, normals_3D)

            data_list.append({"ps": ps,
                              "normals_gt": normals_gt,
                              "normals_al": normals_al,
                              "normals_3D": normals_3D,
                              "normals_al_error": normals_al_error,
                              "normals_3d_error": normals_3d_error})
    return data_list