Example #1
0
        private void makeCSVFromXmpWithCertainFormat(string xmpPath, string statementFormat, CSVFile csv)
        {
            XMPFile xmp = new XMPFile();

            xmp.LoadXML(xmpPath);
            XMPGenerator xmpGen = new XMPGenerator();

            /*
             * Program.AddLog(xmp.GetPosition());
             * Program.AddLog("strat add rotation");
             * Program.AddLog(xmp.GetRotation());
             * Console.ReadLine();*/



            //string statement = Path.GetFileNameWithoutExtension(filePaths[2]) + " " + xmp.GetPosition() + " " + xmp.GetRotation();

            string xmpPostions  = xmp.GetPosition();
            string xmpRotations = xmp.GetRotation();

            XMPGenerator.FRotator xmpYawPitchAndRoll = xmpGen.GroundVUYawPitchRow(xmpRotations);

            string[] Positions = xmpPostions.Split(' ');
            string[] Rotations = xmpRotations.Split(' ');


            //string statement = string.Format(format_string_images, Path.GetFileNameWithoutExtension(filePaths[i]), Positions[0], Positions[1], Positions[2], Rotations[0], Rotations[1], Rotations[2], Rotations[3], Rotations[4], Rotations[5], Rotations[6], Rotations[7], Rotations[8]);
            string statement = string.Format(statementFormat, Path.GetFileNameWithoutExtension(xmpPath), Positions[0], Positions[1], Positions[2], xmpYawPitchAndRoll.Roll, xmpYawPitchAndRoll.Pitch, xmpYawPitchAndRoll.Yaw);

            csv.AddLineWithoutIdx(statement);
        }
Example #2
0
        static void XMPFileGenerator(string[] args)
        {
            if (args[1] == "1")
            {
                XMPGenerator xmpGen = new XMPGenerator();
                xmpGen.BuildXMPDirectory(4, args[2]);
                xmpGen.SetRelativeXMPFile(4, args[3]);
                xmpGen.BuildCalibXMPFile();
                return;
            }
            if (args[1] == "2")
            {
                XMPGenerator xmpGen2 = new XMPGenerator();
                xmpGen2.BuildXMPDirectory(0, args[2]);
                xmpGen2.BuildXMPDirectory(1, args[3]);
                xmpGen2.BuildXMPDirectory(2, args[4]);
                xmpGen2.BuildXMPDirectory(3, args[5]);
                xmpGen2.BuildFixedRelXMPFile(args[6]);
                return;
            }
            if (args[1] == "3")
            {
                Virb360 v360 = new Virb360();
                v360.LoadGPSFile_csv(args[3]);
                //v360.BuildXMPFile_LerpGPSData(args[2]);
                v360.BuildCSVFile_Lerp(args[2]);
                return;
            }
            XMPGenerator xmpGenerator = new XMPGenerator();

            xmpGenerator.BuildXMPDirectory(0, args[1]);
            xmpGenerator.BuildXMPDirectory(1, args[2]);
            xmpGenerator.BuildXMPDirectory(2, args[3]);
            xmpGenerator.BuildXMPDirectory(3, args[4]);
            xmpGenerator.SetRelativeXMPFile(0, args[5]);
            xmpGenerator.SetRelativeXMPFile(1, args[6]);
            xmpGenerator.SetRelativeXMPFile(2, args[7]);
            xmpGenerator.SetRelativeXMPFile(3, args[8]);
            xmpGenerator.BuildRelXMPFile();
            return;
        }
Example #3
0
        public void BuildCSVFile_Lerp(string imgFolder)
        {
            if (imgFolder.Length < 3)
            {
                Program.AddLog("BuildCSVFile_Lerp: wrong Path." + imgFolder);
                return;
            }
            if (!Directory.Exists(imgFolder))
            {
                Program.AddLog("BuildCSVFile_Lerp: No Path." + imgFolder);
                return;
            }
            if (m_gps_data.Count < 1)
            {
                return;
            }
            string[]     files        = Directory.GetFiles(imgFolder);
            string       srcFilename  = Path.GetFileNameWithoutExtension(gps_csv_filename);
            string       destPath     = Path.GetDirectoryName(gps_csv_filename);
            string       destFilename = Path.Combine(destPath, srcFilename + "_lerp.csv");
            StreamWriter writer       = new StreamWriter(destFilename);

            writer.WriteLine("imagename,X,Y,Z");
            GPSData firstGPSData = m_gps_data.First().Value;

            foreach (var file in files)
            {
                string ext = Path.GetExtension(file);
                ext = ext.ToLower();
                if (ext == ".jpg")
                {
                    string filename   = Path.GetFileNameWithoutExtension(file);
                    string keyword    = "";
                    int    idx        = 0;
                    bool   isFilename = XMPGenerator.GetIndexAndKeyword(out keyword, out idx, filename);
                    if (!isFilename)
                    {
                        continue;
                    }
                    idx -= 1;
                    int gpsIdx     = idx / 30;
                    int gpsSecStep = idx % 30;
                    gpsIdx += 1;
                    int gpsIdxNext = gpsIdx + 1;
                    if (!m_gps_data.ContainsKey(gpsIdx))
                    {
                        continue;
                    }
                    if (!m_gps_data.ContainsKey(gpsIdxNext))
                    {
                        continue;
                    }
                    GPSData gpsData  = m_gps_data[gpsIdx];
                    GPSData gpsData2 = m_gps_data[gpsIdxNext];
                    double  p        = gpsSecStep / 30.0;
                    double  posX     = (gpsData2.posX - gpsData.posX) * p + gpsData.posX;
                    double  posY     = (gpsData2.posY - gpsData.posY) * p + gpsData.posY;
                    double  altitude = (gpsData2.altitude - gpsData.altitude) * p + gpsData.altitude;

                    string line_data = string.Format("{0},{1},{2},{3}", Path.GetFileName(file), posX, posY, altitude);
                    writer.WriteLine(line_data);
                }
            }

            writer.Close();
        }
Example #4
0
        public void BuildXMPFile_LerpGPSData(string imgFolder)
        {
            if (imgFolder.Length < 3)
            {
                Program.AddLog("BuildXMPFile_LerpGPSData: wrong Path." + imgFolder);
                return;
            }
            if (!Directory.Exists(imgFolder))
            {
                Program.AddLog("BuildXMPFile_LerpGPSData: No Path." + imgFolder);
                return;
            }
            if (m_gps_data.Count < 1)
            {
                return;
            }
            string[] files = Directory.GetFiles(imgFolder);

            GPSData firstGPSData = m_gps_data.First().Value;

            foreach (var file in files)
            {
                string ext = Path.GetExtension(file);
                ext = ext.ToLower();
                if (ext == ".jpg")
                {
                    string filename   = Path.GetFileNameWithoutExtension(file);
                    string keyword    = "";
                    int    idx        = 0;
                    bool   isFilename = XMPGenerator.GetIndexAndKeyword(out keyword, out idx, filename);
                    if (!isFilename)
                    {
                        continue;
                    }
                    string xmpFileName = Path.ChangeExtension(file, "xmp");
                    if (File.Exists(xmpFileName))
                    {
                        File.Delete(xmpFileName);
                    }
                    idx -= 1;
                    int gpsIdx     = idx / 30;
                    int gpsSecStep = idx % 30;
                    gpsIdx += 1;
                    int gpsIdxNext = gpsIdx + 1;
                    if (!m_gps_data.ContainsKey(gpsIdx))
                    {
                        continue;
                    }
                    if (!m_gps_data.ContainsKey(gpsIdxNext))
                    {
                        continue;
                    }
                    GPSData gpsData  = m_gps_data[gpsIdx];
                    GPSData gpsData2 = m_gps_data[gpsIdxNext];
                    double  p        = gpsSecStep / 30.0;
                    double  posX     = (gpsData2.posX - gpsData.posX) * p + gpsData.posX;
                    double  posY     = (gpsData2.posY - gpsData.posY) * p + gpsData.posY;
                    double  altitude = (gpsData2.altitude - gpsData.altitude) * p + gpsData.altitude;

                    XMPFile xmp_file = new XMPFile();
                    xmp_file.LoadXML("Sample.xmp");
                    xmp_file.RemoveNode(100);
                    xmp_file.RemoveNode(102);
                    xmp_file.RemoveAttribute(1);
                    xmp_file.SetPosition(posX, posY, altitude);
                    xmp_file.SaveXML(xmpFileName);
                }
            }
        }