Ejemplo n.º 1
0
        public void BuildCalibXMPFile()
        {
            if (!isXMPSetting[4])
            {
                return;
            }
            XMPFile save_file = new XMPFile();

            save_file.LoadXML(relativeXMPFilename[4]);
            foreach (var node in xmpFileDirectory4)
            {
                int         idx    = node.Key;
                jpgFileInfo jfInfo = node.Value;
                if (!jfInfo.isXMP)
                {
                    // string posStr1 = jfInfo.xmpFile.GetPosition();
                    save_file.SetPosePrior("unknown");
                    save_file.RemoveNode(101);
                    save_file.RemoveNode(102);
                    save_file.SaveXML(jfInfo.xmp_filename);

                    Program.AddLog("SaveCalibXMP: new " + jfInfo.xmp_filename);
                    continue;
                }
                if (jfInfo.xmpFile.IsLockedData())
                {
                    continue;
                }
                //if(jfInfo.xmpFile.IsCalibrationData())
                //{
                //    string posStr1 = jfInfo.xmpFile.GetPosition();
                //    save_file.SetPosePrior();
                //    save_file.SetPosition(posStr1);
                //    save_file.RemoveNode(102);
                //    save_file.SaveXML(jfInfo.xmp_filename);
                //    continue;
                //}
                string posStr = jfInfo.xmpFile.GetPosition();
                save_file.CheckPositionNode();
                save_file.SetPosePrior("unknown");
                save_file.SetPosition(posStr);
                save_file.RemoveNode(102);
                save_file.SaveXML(jfInfo.xmp_filename);

                Program.AddLog("SaveCalibXMP: " + jfInfo.xmp_filename);
            }
            return;
        }
Ejemplo n.º 2
0
        public void BuildRelXMPFile()
        {
            if (!isXMPSetting[0])
            {
                return;
            }
            if (isXMPSetting[1])
            {
                int     curIdx      = 1;
                FVector relativePos = new FVector(0, 0, 0);
                relativePos.X = relPostion[curIdx].X - relPostion[0].X;
                relativePos.Y = relPostion[curIdx].Y - relPostion[0].Y;
                relativePos.Z = relPostion[curIdx].Z - relPostion[0].Z;
                FRotator relativeRotator = new FRotator(0, 0, 0);
                relativeRotator.Pitch = relRotator[curIdx].Pitch - relRotator[0].Pitch;
                relativeRotator.Yaw   = relRotator[curIdx].Yaw - relRotator[0].Yaw;
                relativeRotator.Roll  = relRotator[curIdx].Roll - relRotator[0].Roll;
                XMPFile save_file = new XMPFile();
                save_file.LoadXML(relativeXMPFilename[curIdx]);
                int key_offset = keyIndex[curIdx] - keyIndex[0];
                foreach (var node in xmpFileDirectory1)
                {
                    int         idx    = node.Key;
                    jpgFileInfo jfInfo = node.Value;
                    int         idx0   = idx - key_offset;
                    if (!xmpFileDirectory0.ContainsKey(idx0))
                    {
                        continue;
                    }
                    jpgFileInfo jfInfo0 = xmpFileDirectory0[idx0];
                    if (!jfInfo0.isXMP)
                    {
                        continue;
                    }
                    FRotator newRot = new FRotator(0, 0, 0);
                    newRot.Pitch = jfInfo0.rotation.Pitch + relativeRotator.Pitch;
                    newRot.Yaw   = jfInfo0.rotation.Yaw + relativeRotator.Yaw;
                    newRot.Roll  = jfInfo0.rotation.Roll + relativeRotator.Roll;
                    double[] mt = BuildRotationMatrix(newRot);

                    FVector newPos = new FVector(0, 0, 0);
                    newPos.X = jfInfo0.position.X + relativePos.X;
                    newPos.Y = jfInfo0.position.Y + relativePos.Y;
                    newPos.Z = jfInfo0.position.Z + relativePos.Z;
                    save_file.SetRotation(mt);
                    save_file.SetPosition(newPos.X, newPos.Y, newPos.Z);
                    string saveXMPFilename = Path.ChangeExtension(jfInfo.filename, "xmp");
                    save_file.SaveXML(saveXMPFilename);

                    Program.AddLog("SaveXML: " + saveXMPFilename);
                }
            }
            if (isXMPSetting[2])
            {
                int     curIdx      = 2;
                FVector relativePos = new FVector(0, 0, 0);
                relativePos.X = relPostion[curIdx].X - relPostion[0].X;
                relativePos.Y = relPostion[curIdx].Y - relPostion[0].Y;
                relativePos.Z = relPostion[curIdx].Z - relPostion[0].Z;
                FRotator relativeRotator = new FRotator(0, 0, 0);
                relativeRotator.Pitch = relRotator[curIdx].Pitch - relRotator[0].Pitch;
                relativeRotator.Yaw   = relRotator[curIdx].Yaw - relRotator[0].Yaw;
                relativeRotator.Roll  = relRotator[curIdx].Roll - relRotator[0].Roll;
                XMPFile save_file = new XMPFile();
                save_file.LoadXML(relativeXMPFilename[curIdx]);
                int key_offset = keyIndex[curIdx] - keyIndex[0];
                foreach (var node in xmpFileDirectory2)
                {
                    int         idx    = node.Key;
                    jpgFileInfo jfInfo = node.Value;
                    int         idx0   = idx - key_offset;
                    if (!xmpFileDirectory0.ContainsKey(idx0))
                    {
                        continue;
                    }
                    jpgFileInfo jfInfo0 = xmpFileDirectory0[idx0];
                    if (!jfInfo0.isXMP)
                    {
                        continue;
                    }
                    FRotator newRot = new FRotator(0, 0, 0);
                    newRot.Pitch = jfInfo0.rotation.Pitch + relativeRotator.Pitch;
                    newRot.Yaw   = jfInfo0.rotation.Yaw + relativeRotator.Yaw;
                    newRot.Roll  = jfInfo0.rotation.Roll + relativeRotator.Roll;
                    double[] mt = BuildRotationMatrix(newRot);

                    FVector newPos = new FVector(0, 0, 0);
                    newPos.X = jfInfo0.position.X + relativePos.X;
                    newPos.Y = jfInfo0.position.Y + relativePos.Y;
                    newPos.Z = jfInfo0.position.Z + relativePos.Z;
                    save_file.SetRotation(mt);
                    save_file.SetPosition(newPos.X, newPos.Y, newPos.Z);
                    string saveXMPFilename = Path.ChangeExtension(jfInfo.filename, "xmp");
                    save_file.SaveXML(saveXMPFilename);

                    Program.AddLog("SaveXML: " + saveXMPFilename);
                }
            }
            if (isXMPSetting[3])
            {
                int     curIdx      = 3;
                FVector relativePos = new FVector(0, 0, 0);
                relativePos.X = relPostion[curIdx].X - relPostion[0].X;
                relativePos.Y = relPostion[curIdx].Y - relPostion[0].Y;
                relativePos.Z = relPostion[curIdx].Z - relPostion[0].Z;
                FRotator relativeRotator = new FRotator(0, 0, 0);
                relativeRotator.Pitch = relRotator[curIdx].Pitch - relRotator[0].Pitch;
                relativeRotator.Yaw   = relRotator[curIdx].Yaw - relRotator[0].Yaw;
                relativeRotator.Roll  = relRotator[curIdx].Roll - relRotator[0].Roll;
                XMPFile save_file = new XMPFile();
                save_file.LoadXML(relativeXMPFilename[curIdx]);
                int key_offset = keyIndex[curIdx] - keyIndex[0];
                foreach (var node in xmpFileDirectory3)
                {
                    int         idx    = node.Key;
                    jpgFileInfo jfInfo = node.Value;
                    int         idx0   = idx - key_offset;
                    if (!xmpFileDirectory0.ContainsKey(idx0))
                    {
                        continue;
                    }
                    jpgFileInfo jfInfo0 = xmpFileDirectory0[idx0];
                    if (!jfInfo0.isXMP)
                    {
                        continue;
                    }
                    FRotator newRot = new FRotator(0, 0, 0);
                    newRot.Pitch = jfInfo0.rotation.Pitch + relativeRotator.Pitch;
                    newRot.Yaw   = jfInfo0.rotation.Yaw + relativeRotator.Yaw;
                    newRot.Roll  = jfInfo0.rotation.Roll + relativeRotator.Roll;
                    double[] mt = BuildRotationMatrix(newRot);

                    FVector newPos = new FVector(0, 0, 0);
                    newPos.X = jfInfo0.position.X + relativePos.X;
                    newPos.Y = jfInfo0.position.Y + relativePos.Y;
                    newPos.Z = jfInfo0.position.Z + relativePos.Z;
                    save_file.SetRotation(mt);
                    save_file.SetPosition(newPos.X, newPos.Y, newPos.Z);
                    string saveXMPFilename = Path.ChangeExtension(jfInfo.filename, "xmp");
                    save_file.SaveXML(saveXMPFilename);
                    Program.AddLog("SaveXML: " + saveXMPFilename);
                }
            }
        }
Ejemplo n.º 3
0
        public void BuildFixedRelXMPFile(string sampleXMPFilename)
        {
            int      curIdx          = 1;
            FVector  relativePos     = new FVector(0, 0, 0);
            FRotator relativeRotator = new FRotator(0, 0, 0);

            relativeRotator.Yaw = 90.0f;
            XMPFile save_file = new XMPFile();

            save_file.LoadXML(sampleXMPFilename);
            int key_offset = 0;// keyIndex[curIdx] - keyIndex[0];

            foreach (var node in xmpFileDirectory1)
            {
                int         idx    = node.Key;
                jpgFileInfo jfInfo = node.Value;
                int         idx0   = idx - key_offset;
                if (!xmpFileDirectory0.ContainsKey(idx0))
                {
                    continue;
                }
                jpgFileInfo jfInfo0 = xmpFileDirectory0[idx0];
                if (!jfInfo0.isXMP)
                {
                    continue;
                }
                //FRotator newRot = new FRotator(0, 0, 0);
                //newRot.Pitch = -jfInfo0.rotation.Roll;
                //newRot.Yaw = jfInfo0.rotation.Yaw + 90.0;
                //newRot.Roll = 0;
                //double[] mt = BuildRotationMatrix(newRot);

                double[] mt = GetMtx(jfInfo0.rotationString, 3);

                FVector newPos = new FVector(0, 0, 0);
                newPos.X = jfInfo0.position.X;
                newPos.Y = jfInfo0.position.Y;
                newPos.Z = jfInfo0.position.Z;
                save_file.SetRotation(mt);
                save_file.SetPosition(newPos.X, newPos.Y, newPos.Z);
                string saveXMPFilename = Path.ChangeExtension(jfInfo.filename, "xmp");
                save_file.SaveXML(saveXMPFilename);

                Program.AddLog("SaveXML: " + saveXMPFilename);
            }

            curIdx = 2;
            //FVector relativePos = new FVector(0, 0, 0);
            //FRotator relativeRotator = new FRotator(0, 0, 0);
            relativeRotator.Yaw = -90.0;
            XMPFile save_file_2 = new XMPFile();

            save_file_2.LoadXML(sampleXMPFilename);
            //key_offset = keyIndex[curIdx] - keyIndex[0];
            foreach (var node in xmpFileDirectory2)
            {
                int         idx    = node.Key;
                jpgFileInfo jfInfo = node.Value;
                int         idx0   = idx - key_offset;
                if (!xmpFileDirectory0.ContainsKey(idx0))
                {
                    continue;
                }
                jpgFileInfo jfInfo0 = xmpFileDirectory0[idx0];
                if (!jfInfo0.isXMP)
                {
                    continue;
                }
                //FRotator newRot = new FRotator(0, 0, 0);
                //newRot.Pitch = jfInfo0.rotation.Roll ;
                //newRot.Yaw = jfInfo0.rotation.Yaw - 90.0;
                //newRot.Roll = 0;
                //double[] mt = BuildRotationMatrix(newRot);


                double[] mt = GetMtx(jfInfo0.rotationString, 1);
                //double[] mt = jfInfo0.rotation.GetRightDirMtx();

                FVector newPos = new FVector(0, 0, 0);
                newPos.X = jfInfo0.position.X;
                newPos.Y = jfInfo0.position.Y;
                newPos.Z = jfInfo0.position.Z;
                save_file_2.SetRotation(mt);
                save_file_2.SetPosition(newPos.X, newPos.Y, newPos.Z);
                string saveXMPFilename = Path.ChangeExtension(jfInfo.filename, "xmp");
                save_file_2.SaveXML(saveXMPFilename);

                Program.AddLog("SaveXML: " + saveXMPFilename);
            }


            curIdx = 3;
            //FVector relativePos = new FVector(0, 0, 0);
            //FRotator relativeRotator = new FRotator(0, 0, 0);
            relativeRotator.Yaw = 180;
            XMPFile save_file_3 = new XMPFile();

            save_file_3.LoadXML(sampleXMPFilename);
            //int key_offset = keyIndex[curIdx] - keyIndex[0];
            foreach (var node in xmpFileDirectory3)
            {
                int         idx    = node.Key;
                jpgFileInfo jfInfo = node.Value;
                int         idx0   = idx - key_offset;
                if (!xmpFileDirectory0.ContainsKey(idx0))
                {
                    continue;
                }
                jpgFileInfo jfInfo0 = xmpFileDirectory0[idx0];
                if (!jfInfo0.isXMP)
                {
                    continue;
                }
                //FRotator newRot = new FRotator(0, 0, 0);
                //newRot.Pitch = -jfInfo0.rotation.Pitch;
                //newRot.Yaw = jfInfo0.rotation.Yaw + 180;
                //newRot.Roll = 0;
                double[] mt = GetMtx(jfInfo0.rotationString, 2);
                //double[] mt = BuildRotationMatrix(newRot);

                FVector newPos = new FVector(0, 0, 0);
                newPos.X = jfInfo0.position.X;
                newPos.Y = jfInfo0.position.Y;
                newPos.Z = jfInfo0.position.Z;
                save_file_3.SetRotation(mt);
                save_file_3.SetPosition(newPos.X, newPos.Y, newPos.Z);
                string saveXMPFilename = Path.ChangeExtension(jfInfo.filename, "xmp");
                save_file_3.SaveXML(saveXMPFilename);
                Program.AddLog("SaveXML: " + saveXMPFilename);
            }
        }
Ejemplo n.º 4
0
        public void BuildXMPDirectory(int index, string path)
        {
            if (path.Length < 3)
            {
                Program.AddLog("BuildXMPDirectory: wrong Path." + index + " " + path);
                return;
            }
            if (!Directory.Exists(path))
            {
                Program.AddLog("BuildXMPDirectory: No Path." + index + " " + path);
                return;
            }
            string[] files = Directory.GetFiles(path);
            foreach (var file in files)
            {
                string ext = Path.GetExtension(file);
                ext = ext.ToLower();
                if (ext == ".jpg")
                {
                    jpgFileInfo jfInfo = new jpgFileInfo();
                    jfInfo.filename = file;
                    string filename   = Path.GetFileNameWithoutExtension(file);
                    string keyword    = "";
                    int    idx        = 0;
                    bool   isFilename = GetIndexAndKeyword(out keyword, out idx, filename);
                    if (!isFilename)
                    {
                        continue;
                    }
                    string xmpFileName = Path.ChangeExtension(file, "xmp");
                    jfInfo.xmp_filename = xmpFileName;
                    if (File.Exists(xmpFileName))
                    {
                        jfInfo.xmpFile = new XMPFile();
                        jfInfo.xmpFile.LoadXML(xmpFileName);
                        jfInfo.isXMP = true;
                        //if(index == 0)
                        {
                            jfInfo.rotationString = jfInfo.xmpFile.GetRotation();
                            jfInfo.rotation       = GetRotator(jfInfo.xmpFile.GetRotation());
                            jfInfo.position       = GetPostiion(jfInfo.xmpFile.GetPosition());
                        }
                    }
                    else
                    {
                        jfInfo.isXMP = false;
                    }
                    if (index == 0)
                    {
                        xmpFileDirectory0.Add(idx, jfInfo);
                    }
                    if (index == 1)
                    {
                        xmpFileDirectory1.Add(idx, jfInfo);
                    }
                    if (index == 2)
                    {
                        xmpFileDirectory2.Add(idx, jfInfo);
                    }
                    if (index == 3)
                    {
                        xmpFileDirectory3.Add(idx, jfInfo);
                    }
                    if (index == 4)
                    {
                        xmpFileDirectory4.Add(idx, jfInfo);
                    }
                }
            }

            Program.AddLog("Check XMP Folder:" + xmpFileDirectory0.Count + " " + xmpFileDirectory1.Count + " " + xmpFileDirectory2.Count + " " + xmpFileDirectory3.Count);
        }