示例#1
0
 public void Process()
 {
     foreach (PhotoInfo node in photo_info_list)
     {
         XMPFile xmp_file = new XMPFile();
         xmp_file.LoadXML("Sample.xmp");
         double focalLen = focallength;
         double ppx_mm   = ppx / width - 0.5;
         double ppy_mm   = ppy / height - 0.5;
         xmp_file.SetParameters(focallength, ppx_mm, ppy_mm);
         xmp_file.SetPosition(node.x, node.y, node.z);
         xmp_file.SetRotation(node.mt);
         xmp_file.SetDistortion(distorttion_p1, distorttion_p2, distorttion_p3, distorttion_k1, distorttion_k2);
         string filename = Path.GetFileNameWithoutExtension(node.image_path);
         filename += ".xmp";
         filename  = Path.Combine(output_folder, filename);
         xmp_file.SaveXML(filename);
     }
 }
示例#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);
                }
            }
        }
示例#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);
            }
        }