Exemplo n.º 1
0
        //private Transform correctPCATransform(DenseMatrix inputMat_source, DenseMatrix inputMat_target, Transform PCATrans_source, Transform PCATrans_target)
        //{
        //    DenseMatrix mat0 = PCATrans_source.GetMatrix();
        //    List<DenseMatrix> mats = new List<DenseMatrix>();
        //    double min = -1;
        //    int minIndex = 0;

        //    DenseMatrix invTrans_target = PCATrans_target.GetMatrix().Inverse() as DenseMatrix;
        //    DenseMatrix invedMat_target = invTrans_target * inputMat_target;

        //    for (int i = 0; i < 8; i++)
        //    {
        //        DenseMatrix mat = Utils_PCA.getMirroredTransMat(mat0, i);
        //        mats.Add(mat);
        //        DenseMatrix invTrans_source = mat.Inverse() as DenseMatrix;

        //        double err = Utils_CheckErr.CheckErr(invTrans_source * inputMat_source, invedMat_target, ref cellIndex);
        //        if (min < 0 || min > err)
        //        {
        //            min = err;
        //            minIndex = i;
        //        }
        //    }

        //    Transform newPCATrans_source = new Transform(mats[minIndex]);
        //    return newPCATrans_source;
        //}


        private void endICP(int iLoop)
        {
            TWO_MESHS_sourceObj.Transform = new Transform(PCA_TransMat_target * SVD_TransMat * PCA_InvTransMat_source);

            DenseMatrix checkSourceMat     = PCA_TransMat_target * SVD_TransMat * PCA_InvTransMat_source * TWO_MESHS_sourceObj.ToDataMat();
            DenseMatrix checkSourceMat_PCA = PCA_TransMat_target * PCA_InvTransMat_source * TWO_MESHS_sourceObj.ToDataMat();

            int    timeDelta = EndTime - StartTime;
            double err_pca   = Utils_CheckErr.CheckErr(checkSourceMat_PCA, TWO_MESHS_targetObj.ToDataMat());
            double err       = Utils_CheckErr.CheckErr(checkSourceMat, TWO_MESHS_targetObj.ToDataMat());


            string str = "Time: " + timeDelta.ToString() + "\n";

            str += "Err_PCA: " + err_pca.ToString() + "\n";
            str += "Err: " + err.ToString() + "\n";
            foreach (double rec in errList)
            {
                str += rec.ToString() + "\n";
            }
            StreamWriter writer = new StreamWriter("d:/rec_icp_"
                                                   + TargetSamples.ToString() + "_" + SourceSamples.ToString() + "_" + iLoop.ToString() + ".txt");

            writer.Write(str);
            writer.Close();
        }
Exemplo n.º 2
0
        private void endSA(int iloop)
        {
            double[] data = sa_Processor.currentMinData;

            DenseMatrix mirrorMat = Utils_PCA.getMirrorTransMat(Convert.ToInt32(data[7]));

            Transform transform = new Transform();

            transform.DoMove(data[0], data[1], data[2]);
            transform.DoRotateX(data[3]);
            transform.DoRotateY(data[4]);
            transform.DoRotateZ(data[5]);
            transform.DoScale(data[6]);

            DenseMatrix transformMat = transform.GetMatrix() * mirrorMat;


            TWO_MESHS_sourceObj.Transform = new Transform(PCA_TransMat_target * transformMat * PCA_InvTransMat_source);

            DenseMatrix checkSourceMat     = PCA_TransMat_target * transformMat * PCA_InvTransMat_source * TWO_MESHS_sourceObj.ToDataMat();
            DenseMatrix checkSourceMat_PCA = PCA_TransMat_target * PCA_InvTransMat_source * TWO_MESHS_sourceObj.ToDataMat();

            int    timeDelta = EndTime - StartTime;
            double err_pca   = Utils_CheckErr.CheckErr(checkSourceMat_PCA, TWO_MESHS_targetObj.ToDataMat());
            double err       = Utils_CheckErr.CheckErr(checkSourceMat, TWO_MESHS_targetObj.ToDataMat());


            string str = "Time: " + timeDelta.ToString() + "\n";

            str += "Err_PCA: " + err_pca.ToString() + "\n";
            str += "Err: " + err.ToString() + "\n";
            foreach (double rec in sa_Processor.Record)
            {
                str += rec.ToString() + "\n";
            }
            StreamWriter writer = new StreamWriter("d:/rec_sa_"
                                                   + TargetSamples.ToString() + "_" + SourceSamples.ToString() + "_" + iloop.ToString() + ".txt");

            writer.Write(str);
            writer.Close();
        }