Generate XML from object

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace AddTestResult
{
    public class XML
    {
        public void Output(string classname, string testmethod, string testresult)
        {
            nextlabsTestExecution myNext = new nextlabsTestExecution();
            myNext.testlink.testProject = "Endpoints";
            myNext.testlink.testPlan = "Adobe PCV";
            myNext.testlink.platform = "Window 7 + Acrobat XI";


            myNext.build.name = "WDE 6.2.0.0 (7)";
            myNext.build.notes = "for adobe pep testing";
            myNext.build.releaseDate = "2013/5/4";


            myNext.testCases.TestCase.name = testmethod;
            myNext.testCases.TestCase.path = classname;
            myNext.testCases.TestCase.executionStatus = testresult;
            myNext.testCases.TestCase.notes = "well done";


            System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(myNext.GetType());
            System.IO.StreamWriter file =new System.IO.StreamWriter(@"c:\test.xml");


            writer.Serialize(file, myNext);
            file.Close();
        }
                
    }


    public class nextlabsTestExecution
    {
        public testLink testlink = new testLink();
        public build build = new build();
        public testCases testCases = new testCases();
    }


    public class testcase
    {
       public string name {get;set;}
       public string path { get; set; }
       public string executionStatus { get; set; }
       public string notes { get; set; }
    }


    public class testCases
    {
        public testcase TestCase = new testcase();
    }


    public class build
    {
       public string name { get; set; }
       public  string notes { get; set; }
       public string releaseDate { get; set; }
    }


    public class testLink
    {
       public string testProject {get;set;}
       public string testPlan {get;set;}
       public string platform { get; set; }
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
首先,我们需要将Kitti Raw Data的3D点云数据转化为Paddle3D训练格式所需要的多个txt文件。这个过程可以通过以下步骤完成: 1. 解析tracklet_labels.xml文件,获取每个tracklet的信息,包括对象ID、对象类型、起始帧和结束帧等。 2. 打开对应的frame_list.txt文件,获取该tracklet中对应的所有点云文件名。 3. 将每个点云文件中的点信息提取出来,并根据对象ID和帧数进行分类,生成多个txt文件。每个txt文件以“对象ID_帧数.txt”命名,其中包含该帧中该对象ID对应的点云信息。 下面是一个示例代码,实现了上述步骤: ```python import os import xml.etree.ElementTree as ET # 解析tracklet_labels.xml文件,获取每个tracklet的信息 def parse_xml(xml_file): tree = ET.parse(xml_file) root = tree.getroot() tracklets = {} for tracklet in root: object_type = tracklet.attrib['object_type'] object_id = tracklet.attrib['id'] frames = [] for attribute in tracklet: if attribute.tag == 'first_frame': first_frame = int(attribute.text) elif attribute.tag == 'poses': for pose in attribute: frame_num = int(pose.attrib['frame']) translation = pose.find('tx').text + ' ' + pose.find('ty').text + ' ' + pose.find('tz').text rotation = pose.find('rx').text + ' ' + pose.find('ry').text + ' ' + pose.find('rz').text frames.append((frame_num, translation, rotation)) tracklets[object_id] = {'object_type': object_type, 'first_frame': first_frame, 'frames': frames} return tracklets # 获取每个tracklet中对应的所有点云文件名 def get_cloud_files(tracklet, cloud_dir): cloud_files = [] for frame in tracklet['frames']: frame_num = frame[0] cloud_file = os.path.join(cloud_dir, '{:06d}.bin'.format(frame_num)) cloud_files.append(cloud_file) return cloud_files # 将每个点云文件中的点信息提取出来,并根据对象ID和帧数进行分类,生成多个txt文件 def generate_txt_files(tracklets, cloud_dir, output_dir): for object_id in tracklets: tracklet = tracklets[object_id] object_type = tracklet['object_type'] first_frame = tracklet['first_frame'] cloud_files = get_cloud_files(tracklet, cloud_dir) for i, cloud_file in enumerate(cloud_files): with open(cloud_file, 'rb') as f: cloud_points = np.fromfile(f, dtype=np.float32).reshape(-1, 4) output_file = os.path.join(output_dir, '{}_{:06d}.txt'.format(object_id, first_frame + i)) with open(output_file, 'w') as f: for point in cloud_points: line = '{} {} {} {} {}\n'.format(point[0], point[1], point[2], point[3], object_type) f.write(line) if __name__ == '__main__': xml_file = 'path/to/tracklet_labels.xml' cloud_dir = 'path/to/cloud/files' output_dir = 'path/to/output/dir' tracklets = parse_xml(xml_file) generate_txt_files(tracklets, cloud_dir, output_dir) ``` 该代码中使用了numpy库来读取点云文件,并将点信息写入txt文件。 需要注意的是,该代码仅适用于Kitti Raw Data的3D点云数据,如果需要处理其他格式的数据,需要根据实际情况进行修改。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值