检测目标文件夹
python detect.py --source **path/**/ --weights **.pt --img 640
生成文本文件
加 --save-txt 参数即可
python detect.py --source **path/**/ --weights **.pt --img 640 --save-txt
文本文件转成数组
function fnTxt2Arr($fn,$iW,$iH){
$tStr = read2Str($fn);
$arr = explode("\r\n",$tStr);
$arr = array_filter($arr);//清除空字符
for($i=0;$i<count($arr);$i++){
$arrT = explode(" ",$arr[$i]);
$tArr[$i]["labId"] = $arrT[0];//种类标签序号
$tArr[$i]["xMax"] = ($arrT[1]*$iW*2 + $arrT[3]*$iW )/2;
$tArr[$i]["xMin"] = $arrT[1]*$iW*2 - $tArr[$i]["xMax"];
$tArr[$i]["yMax"] = ($arrT[2]*$iH*2 + $arrT[4]*$iH )/2;
$tArr[$i]["yMin"] = $arrT[2]*$iH*2 - $tArr[$i]["yMax"];
}
return $tArr;
}
返回种类标签,xmax,xmin,ymax,ymin的数组。
数组转成json字符串
function fnTxt2json($arr){//文本文件转成json
global $yEnArr, $arrImg, $arrColor;
for($i=0;$i<count($arr);$i++){
$t1Arr[0]["x"] = $arr[$i]["xMin"];
$t1Arr[0]["y"] = $arr[$i]["yMin"];
$t1Ar

本文介绍了一个从检测到标注的完整工作流程,包括使用Python脚本进行目标检测、将检测结果转换为文本文件、进一步将文本内容解析为数组及JSON格式,并最终生成XML标注文件的方法。
最低0.47元/天 解锁文章
3587

被折叠的 条评论
为什么被折叠?



