Example #1
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 #2
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);
                }
            }
        }