php - 如何从 xml 文件中显示图像上的边界框
问题描述
我有一个用于图像标签管理的页面。图像的标签取自 xml 文件。
我试过类似的东西:
<?php
if (isset($_POST['img_url'])) {
$img = $_POST['img_url'];
?>
<div class="container container-flex">
<div class="left imgappend left-sec">
<div class="img_text">
<?php
$link = $_POST['img_url'];
$link_array = explode('/',$link);
$imgpath = end($link_array);
$ext = substr($imgpath, strrpos($imgpath, "."));
$imgname= str_replace($ext,'',$imgpath);
$dire="Annotated Dataset/data/";
$file = $dire.$imgname.'.xml';
$xml = simplexml_load_file($file);
foreach($xml->object as $object){ ?>
<div class='dynamic_text <?php echo $object->name; ?>' style='display:none;'><?php echo $object->name; ?></div>
<?php } ?>
</div>
<img src="<?php echo "$img"; ?>" id="scale_img">
</div>
<div class="right right-sec">
<div class="input-container">
<form action="validationxml.php" method="post" id="img_data" name="validationform">
<span class="right-sec-text">Existing Tags in the image</span>
<div class="exits_tags">
<?php
$link = $_POST['img_url'];
$link_array = explode('/',$link);
$imgpath = end($link_array)
$ext = substr($imgpath, strrpos($imgpath, "."));
$imgname= str_replace($ext,'',$imgpath);
$dire="Annotated Dataset/data/";
$file = $dire.$imgname.'.xml';
$xml = simplexml_load_file($file);
foreach($xml->object as $object){ ?>
<div class='inputtag'>
<i class='fa fa-trash-o' aria-hidden='true'></i>
<span><?php echo $object->name; ?></span>
<input type='hidden' name='tag_name[]' value='<?php echo $object->name; ?>'>
<input type='hidden' name='xmin[]' value='<?php echo $object->bndbox->xmin; ?>'>
<input type='hidden' name='ymin[]' value='<?php echo $object->bndbox->ymin; ?>'>
<input type='hidden' name='xmax[]' value='<?php echo $object->bndbox->xmax; ?>'>
<input type='hidden' name='ymax[]' value='<?php echo $object->bndbox->ymax; ?>'>
</div>
<?php } ?>
</div>
上面显示了图像和其中存在的标签。标签是从 xml 文件中获取的。
xml 文件如下所示:
-<foto>
<folder>images/fashion/MAN_BACKSTAGE_SHOW_FW18</folder>
<scenario>Fashion</scenario>
<filename>MAN_BACKSTAGE_SHOW_FW1833.jpg</filename>
-<size>
<width>1620</width>
<height>1080</height>
</size>
-<object>
<type>highlevel</type>
<name>Tie</name>
<created>auto</created>
-<bndbox>
<xmin>289</xmin>
<ymin>0</ymin>
<xmax>1167</xmax>
<ymax>1059</ymax>
</bndbox>
</fotoinmotion>
xml 文件保存标签边界框的位置。现在,上面的代码显示图像和其中存在的标签。我想获得图像上的边界框。有人可以说怎么做。
解决方案
推荐阅读
- domain-driven-design - 可以删除域事件吗?
- android - 什么用(API 28)替换不推荐使用的 getFragmentManager() 方法?
- react-native - 无法从 react-native 取消链接 Testfairy
- javascript - 单词搜索游戏。如何搜索网格并突出显示结果?
- node.js - 谷歌云功能 - Firestore 查询快照大小返回未定义
- java - 客户端只能在同一台计算机上连接到服务器
- java - Ract-Native Android 构建失败 - 无法找到请求目标的有效认证路径
- javascript - 如何将对象包装在代理中以进行调试?
- python - 在 python 中捕获特定错误
- ios - 覆盖“shouldPerformSegueWithIdentifier”函数抛出错误