public bool Load(string filename)
        {
            csv_file = new CSVFile();
            csv_file.Load(filename);
            char[] charSeparators = new char[] { '_' };
            foreach (var csv_data in csv_file.m_csv_data)
            {
                string[] data = csv_data.Value.values;
                if (data.Length < 4)
                {
                    continue;
                }
                string image_name = convert_string(data[0]);
                var    values     = image_name.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries);
                if (values.Length < 2)
                {
                    continue;
                }
                bool isContainKey = image_info_map.ContainsKey(values[0]);
                if (!isContainKey)
                {
                    ImageInfo imgInfo = new ImageInfo();
                    imgInfo.keyword           = values[0];
                    imgInfo.idxMin            = 9999;
                    imgInfo.idxMax            = 0;
                    imgInfo.count             = 0;
                    image_info_map[values[0]] = imgInfo;
                }


                int       cur_index = Convert.ToInt32(values[1]);
                ImageInfo img_info  = image_info_map[values[0]];
                if (img_info.idxMin > cur_index)
                {
                    img_info.idxMin = cur_index;
                }
                if (img_info.idxMax < cur_index)
                {
                    img_info.idxMax = cur_index;
                }
                img_info.count++;
                image_info_map[values[0]] = img_info;


                ImageListNode node = new ImageListNode();
                node.values  = data;
                node.index   = cur_index;
                node.keyword = values[0];
                image_nodes.Add(node);
            }

            image_nodes.Sort();
            return(true);
        }
        private void generateResultList()
        {
            //string format_string_images = "{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12}";
            string format_string_images = "{0},{1},{2},{3},{4},{5},{6}";
            //string path = Path.Combine(workingDir, sceneName + "_project", "undistorted");
            string path = Path.Combine(@"D:\testGroundVU", "xmp");
            string resultListFilePath = Path.Combine(ImgDir, sceneName + "List.csv");

            string[] filePaths = Directory.GetFiles(path, "*.xmp");

            CSVFile csv = new CSVFile();

            csv.BuildFile(resultListFilePath, "ImageName,X,Y,Z,Yaw,Pitch,Roll");
            for (int i = 0; i < filePaths.Length; i++)
            {
                /*XMPFile xmp = new XMPFile();
                 * xmp.LoadXML(filePaths[i]);
                 * XMPGenerator xmpGen = new XMPGenerator();
                 *
                 *
                 *
                 *
                 * //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(format_string_images, Path.GetFileNameWithoutExtension(filePaths[i]), Positions[0], Positions[1], Positions[2], xmpYawPitchAndRoll.Roll, xmpYawPitchAndRoll.Pitch, xmpYawPitchAndRoll.Yaw);
                 *
                 * csv.AddLineWithoutIdx(statement);*/
                makeCSVFromXmpWithCertainFormat(filePaths[i], format_string_images, csv);
                Program.AddLog(filePaths[i]);
            }
            csv.Save();
        }
Exemple #3
0
 public void BuildRoadInfoFromImageList(ImageList imgListFile, string[] keywords, string src_filename)
 {
     csv_file = new CSVFile();
     csv_file.BuildFile(src_filename, head_string);
     foreach (var node in imgListFile.image_nodes)
     {
         if (node.keyword.Contains(keywords[0]))
         {
             if (keywords.Length == 4)
             {
                 string newStr = string.Format(format_string_images, node.values[0], node.values[1], node.values[2], node.values[3]);
                 csv_file.AddLine(newStr);
             }
             else
             {
                 string newStr = FormatLineData(node.values[0], node.values[1], node.values[2], node.values[3]);
                 csv_file.AddLine(newStr);
             }
         }
     }
     csv_file.Save();
 }
        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);
        }
 public void Load(string filename)
 {
     csv_file = new CSVFile();
     csv_file.Load(filename);
 }