从多个XML文件的值中减去固定量

时间:2019-07-02 05:03:39

标签: java python xml notepad++ notepad

我目前正在为多个文件进行图像标记,并且标记以XML保存。原来所有标签的高度都需要缩短,因为标签上部的细节与其他无关图片相似。因此,我想将所有XML文件中所有<ymax>(number)</ymax>的值减去某个值。有没有办法使用notepad ++或python做到这一点?

下面是完整XML文件的示例。所有文件都具有相同的格式。

<annotation>
    <folder>01</folder>
    <filename>S249.jpeg</filename>
    <path>D:\databs\01\01\S249.jpeg</path>
    <source>
        <database>Unknown</database>
    </source>
    <size>
        <width>375</width>
        <height>500</height>
        <depth>3</depth>
    </size>
    <segmented>0</segmented>
    <object>
        <name>A</name>
        <pose>Unspecified</pose>
        <truncated>0</truncated>
        <difficult>0</difficult>
        <bndbox>
            <xmin>116</xmin>
            <ymin>280</ymin>
            <xmax>141</xmax>
            <ymax>325</ymax>
        </bndbox>
    </object>
    <object>
        <name>A</name>
        <pose>Unspecified</pose>
        <truncated>0</truncated>
        <difficult>0</difficult>
        <bndbox>
            <xmin>143</xmin>
            <ymin>280</ymin>
            <xmax>169</xmax>
            <ymax>324</ymax>
        </bndbox>
    </object>
    <object>
        <name>A</name>
        <pose>Unspecified</pose>
        <truncated>0</truncated>
        <difficult>0</difficult>
        <bndbox>
            <xmin>169</xmin>
            <ymin>280</ymin>
            <xmax>195</xmax>
            <ymax>324</ymax>
        </bndbox>
    </object>
    <object>
        <name>A</name>
        <pose>Unspecified</pose>
        <truncated>0</truncated>
        <difficult>0</difficult>
        <bndbox>
            <xmin>220</xmin>
            <ymin>280</ymin>
            <xmax>241</xmax>
            <ymax>324</ymax>
        </bndbox>
    </object>
    <object>
        <name>B</name>
        <pose>Unspecified</pose>
        <truncated>0</truncated>
        <difficult>0</difficult>
        <bndbox>
            <xmin>206</xmin>
            <ymin>396</ymin>
            <xmax>229</xmax>
            <ymax>431</ymax>
        </bndbox>
    </object>
    <object>
        <name>B</name>
        <pose>Unspecified</pose>
        <truncated>0</truncated>
        <difficult>0</difficult>
        <bndbox>
            <xmin>230</xmin>
            <ymin>396</ymin>
            <xmax>260</xmax>
            <ymax>428</ymax>
        </bndbox>
    </object>
    <object>
        <name>B</name>
        <pose>Unspecified</pose>
        <truncated>0</truncated>
        <difficult>0</difficult>
        <bndbox>
            <xmin>261</xmin>
            <ymin>391</ymin>
            <xmax>285</xmax>
            <ymax>428</ymax>
        </bndbox>
    </object>
</annotation>

0 个答案:

没有答案