-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
8,909 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup Label="ProjectConfigurations"> | ||
<ProjectConfiguration Include="Debug|Win32"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>Win32</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|Win32"> | ||
<Configuration>Release</Configuration> | ||
<Platform>Win32</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Debug|x64"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|x64"> | ||
<Configuration>Release</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
</ItemGroup> | ||
<PropertyGroup Label="Globals"> | ||
<VCProjectVersion>15.0</VCProjectVersion> | ||
<ProjectGuid>{8A8A9E6F-B5D4-4679-A4CB-88DD72747306}</ProjectGuid> | ||
<RootNamespace>libtorchdetection</RootNamespace> | ||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>v141</PlatformToolset> | ||
<CharacterSet>MultiByte</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<PlatformToolset>v141</PlatformToolset> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
<CharacterSet>MultiByte</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>v141</PlatformToolset> | ||
<CharacterSet>MultiByte</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<PlatformToolset>v141</PlatformToolset> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
<CharacterSet>MultiByte</CharacterSet> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
<ImportGroup Label="ExtensionSettings"> | ||
</ImportGroup> | ||
<ImportGroup Label="Shared"> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<PropertyGroup Label="UserMacros" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<OutDir>$(SolutionDir)bin\$(Platform)_$(Configuration)\</OutDir> | ||
<IntDir>$(SolutionDir)bin\intermediates\$(Platform)_$(Configuration)\</IntDir> | ||
<IncludePath>D:\AllentFiles\code\dependency\opencv-4.5.0-vc14_vc15\opencv\build\include;D:\AllentFiles\code\dependency\libtorch17release\include;D:\AllentFiles\code\dependency\libtorch17release\include\torch\csrc\api\include;$(IncludePath)</IncludePath> | ||
<LibraryPath>D:\AllentFiles\code\dependency\opencv-4.5.0-vc14_vc15\opencv\build\x64\vc14\lib;D:\AllentFiles\code\dependency\libtorch17release\lib;$(LibraryPath)</LibraryPath> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<OutDir>$(SolutionDir)bin\$(Platform)_$(Configuration)\</OutDir> | ||
<IntDir>$(SolutionDir)bin\intermediates\$(Platform)_$(Configuration)\</IntDir> | ||
<IncludePath>D:\AllentFiles\code\dependency\opencv-4.5.0-vc14_vc15\opencv\build\include;D:\AllentFiles\code\dependency\libtorch17release\include;D:\AllentFiles\code\dependency\libtorch17release\include\torch\csrc\api\include;$(IncludePath)</IncludePath> | ||
<LibraryPath>D:\AllentFiles\code\dependency\opencv-4.5.0-vc14_vc15\opencv\build\x64\vc14\lib;D:\AllentFiles\code\dependency\libtorch17release\lib;$(LibraryPath)</LibraryPath> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<OutDir>$(SolutionDir)bin\$(Platform)_$(Configuration)\</OutDir> | ||
<IntDir>$(SolutionDir)bin\intermediates\$(Platform)_$(Configuration)\</IntDir> | ||
<IncludePath>D:\AllentFiles\code\dependency\opencv-4.5.0-vc14_vc15\opencv\build\include;D:\AllentFiles\code\dependency\libtorch17release\include;D:\AllentFiles\code\dependency\libtorch17release\include\torch\csrc\api\include;$(IncludePath)</IncludePath> | ||
<LibraryPath>D:\AllentFiles\code\dependency\opencv-4.5.0-vc14_vc15\opencv\build\x64\vc14\lib;D:\AllentFiles\code\dependency\libtorch17release\lib;$(LibraryPath)</LibraryPath> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<OutDir>$(SolutionDir)bin\$(Platform)_$(Configuration)\</OutDir> | ||
<IntDir>$(SolutionDir)bin\intermediates\$(Platform)_$(Configuration)\</IntDir> | ||
<IncludePath>D:\AllentFiles\code\dependency\opencv-4.5.0-vc14_vc15\opencv\build\include;D:\AllentFiles\code\dependency\libtorch17release\include;D:\AllentFiles\code\dependency\libtorch17release\include\torch\csrc\api\include;$(IncludePath)</IncludePath> | ||
<LibraryPath>D:\AllentFiles\code\dependency\opencv-4.5.0-vc14_vc15\opencv\build\x64\vc14\lib;D:\AllentFiles\code\dependency\libtorch17release\lib;$(LibraryPath)</LibraryPath> | ||
</PropertyGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<Optimization>Disabled</Optimization> | ||
<SDLCheck>true</SDLCheck> | ||
<ConformanceMode>false</ConformanceMode> | ||
<PreprocessorDefinitions /> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<AdditionalDependencies>opencv_world450.lib;asmjit.lib;c10.lib;c10d.lib;c10_cuda.lib;caffe2_detectron_ops_gpu.lib;caffe2_module_test_dynamic.lib;caffe2_nvrtc.lib;clog.lib;cpuinfo.lib;dnnl.lib;fbgemm.lib;gloo.lib;gloo_cuda.lib;libprotobuf-lite.lib;libprotobuf.lib;libprotoc.lib;mkldnn.lib;torch.lib;torch_cpu.lib;torch_cuda.lib;/INCLUDE:?warp_size@cuda@at@@YAHXZ;%(AdditionalDependencies)</AdditionalDependencies> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<Optimization>Disabled</Optimization> | ||
<SDLCheck>true</SDLCheck> | ||
<ConformanceMode>false</ConformanceMode> | ||
<PreprocessorDefinitions /> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<AdditionalDependencies>opencv_world450.lib;asmjit.lib;c10.lib;c10d.lib;c10_cuda.lib;caffe2_detectron_ops_gpu.lib;caffe2_module_test_dynamic.lib;caffe2_nvrtc.lib;clog.lib;cpuinfo.lib;dnnl.lib;fbgemm.lib;gloo.lib;gloo_cuda.lib;libprotobuf-lite.lib;libprotobuf.lib;libprotoc.lib;mkldnn.lib;torch.lib;torch_cpu.lib;torch_cuda.lib;/INCLUDE:?warp_size@cuda@at@@YAHXZ;%(AdditionalDependencies)</AdditionalDependencies> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<Optimization>MaxSpeed</Optimization> | ||
<FunctionLevelLinking>true</FunctionLevelLinking> | ||
<IntrinsicFunctions>true</IntrinsicFunctions> | ||
<SDLCheck>true</SDLCheck> | ||
<ConformanceMode>false</ConformanceMode> | ||
<PreprocessorDefinitions /> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
<OptimizeReferences>true</OptimizeReferences> | ||
<AdditionalDependencies>opencv_world450.lib;asmjit.lib;c10.lib;c10d.lib;c10_cuda.lib;caffe2_detectron_ops_gpu.lib;caffe2_module_test_dynamic.lib;caffe2_nvrtc.lib;clog.lib;cpuinfo.lib;dnnl.lib;fbgemm.lib;gloo.lib;gloo_cuda.lib;libprotobuf-lite.lib;libprotobuf.lib;libprotoc.lib;mkldnn.lib;torch.lib;torch_cpu.lib;torch_cuda.lib;/INCLUDE:?warp_size@cuda@at@@YAHXZ;%(AdditionalDependencies)</AdditionalDependencies> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<Optimization>MaxSpeed</Optimization> | ||
<FunctionLevelLinking>true</FunctionLevelLinking> | ||
<IntrinsicFunctions>true</IntrinsicFunctions> | ||
<SDLCheck>true</SDLCheck> | ||
<ConformanceMode>false</ConformanceMode> | ||
<PreprocessorDefinitions /> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
<OptimizeReferences>true</OptimizeReferences> | ||
<AdditionalDependencies>opencv_world450.lib;asmjit.lib;c10.lib;c10d.lib;c10_cuda.lib;caffe2_detectron_ops_gpu.lib;caffe2_module_test_dynamic.lib;caffe2_nvrtc.lib;clog.lib;cpuinfo.lib;dnnl.lib;fbgemm.lib;gloo.lib;gloo_cuda.lib;libprotobuf-lite.lib;libprotobuf.lib;libprotoc.lib;mkldnn.lib;torch.lib;torch_cpu.lib;torch_cuda.lib;/INCLUDE:?warp_size@cuda@at@@YAHXZ;%(AdditionalDependencies)</AdditionalDependencies> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemGroup> | ||
<ClCompile Include="src\utils\Augmentations.cpp" /> | ||
<ClCompile Include="src\DetDataset.cpp" /> | ||
<ClCompile Include="src\Detector.cpp" /> | ||
<ClCompile Include="src\models\CSPdarknet53_tiny.cpp" /> | ||
<ClCompile Include="src\main.cpp" /> | ||
<ClCompile Include="src\utils\tinystr.cpp" /> | ||
<ClCompile Include="src\utils\tinyxml.cpp" /> | ||
<ClCompile Include="src\utils\tinyxmlerror.cpp" /> | ||
<ClCompile Include="src\utils\tinyxmlparser.cpp" /> | ||
<ClCompile Include="src\utils\util.cpp" /> | ||
<ClCompile Include="src\models\yolo4_tiny.cpp" /> | ||
<ClCompile Include="src\models\yolo_training.cpp" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="src\utils\Augmentations.h" /> | ||
<ClInclude Include="src\DetDataset.h" /> | ||
<ClInclude Include="src\Detector.h" /> | ||
<ClInclude Include="src\models\CSPdarknet53_tiny.h" /> | ||
<ClInclude Include="src\utils\readfile.h" /> | ||
<ClInclude Include="src\utils\tinystr.h" /> | ||
<ClInclude Include="src\utils\tinyxml.h" /> | ||
<ClInclude Include="src\utils\util.h" /> | ||
<ClInclude Include="src\utils\_dirent.h" /> | ||
<ClInclude Include="src\models\yolo4_tiny.h" /> | ||
<ClInclude Include="src\models\yolo_training.h" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="weights\detector.pt" /> | ||
<None Include="weights\yolo4_tiny.pt" /> | ||
</ItemGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
<ImportGroup Label="ExtensionTargets"> | ||
</ImportGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup> | ||
<Filter Include="Source Files"> | ||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> | ||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> | ||
</Filter> | ||
<Filter Include="Header Files"> | ||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> | ||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions> | ||
</Filter> | ||
<Filter Include="Resource Files"> | ||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> | ||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> | ||
</Filter> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="src\main.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
<ClCompile Include="src\utils\util.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
<ClCompile Include="src\models\CSPdarknet53_tiny.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
<ClCompile Include="src\models\yolo4_tiny.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
<ClCompile Include="src\models\yolo_training.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
<ClCompile Include="src\Detector.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
<ClCompile Include="src\DetDataset.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
<ClCompile Include="src\utils\tinystr.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
<ClCompile Include="src\utils\tinyxml.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
<ClCompile Include="src\utils\tinyxmlerror.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
<ClCompile Include="src\utils\tinyxmlparser.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
<ClCompile Include="src\utils\Augmentations.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="src\utils\util.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="src\utils\_dirent.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="src\utils\readfile.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="src\models\CSPdarknet53_tiny.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="src\models\yolo4_tiny.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="src\models\yolo_training.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="src\Detector.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="src\DetDataset.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="src\utils\tinystr.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="src\utils\tinyxml.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="src\utils\Augmentations.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="weights\yolo4_tiny.pt" /> | ||
<None Include="weights\detector.pt" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<ShowAllFiles>true</ShowAllFiles> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#include "DetDataset.h" | ||
#include"utils/tinyxml.h" | ||
#include "utils/readfile.h" | ||
|
||
std::vector<BBox> loadXML(std::string xml_path) | ||
{ | ||
std::vector<BBox> objects; | ||
// XML文档 | ||
TiXmlDocument doc; | ||
// 加载XML文档 | ||
if (!doc.LoadFile(xml_path.c_str())) | ||
{ | ||
std::cerr << doc.ErrorDesc() << std::endl; | ||
return objects; | ||
} | ||
|
||
// 定义根节点变量并赋值为文档的第一个根节点 | ||
TiXmlElement *root = doc.FirstChildElement(); | ||
// 如果没有找到根节点,说明是空XML文档或者非XML文档 | ||
if (root == NULL) | ||
{ | ||
std::cerr << "Failed to load file: No root element." << std::endl; | ||
// 清理内存 | ||
doc.Clear(); | ||
return objects; | ||
} | ||
|
||
// 遍历子节点 | ||
for (TiXmlElement *elem = root->FirstChildElement(); elem != NULL; elem = elem->NextSiblingElement()) | ||
{ | ||
// 获取元素名 | ||
std::string elemName = elem->Value(); | ||
std::string name = ""; | ||
// 获取元素属性值 | ||
if (strcmp(elemName.data(), "object") == 0) | ||
{ | ||
for (TiXmlNode *object = elem->FirstChildElement(); object != NULL; object = object->NextSiblingElement()) | ||
{ | ||
if (strcmp(object->Value(), "name") == 0) | ||
{ | ||
name = object->FirstChild()->Value(); | ||
} | ||
|
||
if (strcmp(object->Value(), "bndbox") == 0) | ||
{ | ||
BBox obj; | ||
TiXmlElement * xmin = object->FirstChildElement("xmin"); | ||
TiXmlElement * ymin = object->FirstChildElement("ymin"); | ||
TiXmlElement * xmax = object->FirstChildElement("xmax"); | ||
TiXmlElement * ymax = object->FirstChildElement("ymax"); | ||
|
||
obj.xmin = atoi(std::string(xmin->FirstChild()->Value()).c_str()); | ||
obj.xmax = atoi(std::string(xmax->FirstChild()->Value()).c_str()); | ||
obj.ymin = atoi(std::string(ymin->FirstChild()->Value()).c_str()); | ||
obj.ymax = atoi(std::string(ymax->FirstChild()->Value()).c_str()); | ||
obj.name = name; | ||
objects.push_back(obj); | ||
} | ||
|
||
//cout << bndbox->Value() << endl; | ||
} | ||
} | ||
} | ||
//std::cout << xml_path << std::endl; | ||
// 清理内存 | ||
doc.Clear(); | ||
return objects; | ||
} | ||
|
||
//遍历该目录下的.xml文件,并且找到对应的 | ||
void load_det_data_from_folder(std::string folder, std::string image_type, | ||
std::vector<std::string> &list_images, std::vector<std::string> &list_labels) | ||
{ | ||
for_each_file(folder, | ||
// filter函数,lambda表达式 | ||
[&](const char*path, const char* name) { | ||
auto full_path = std::string(path).append({ file_sepator() }).append(name); | ||
std::string lower_name = tolower1(name); | ||
|
||
//判断是否为jpeg文件 | ||
if (end_with(lower_name, ".xml")) { | ||
list_labels.push_back(full_path); | ||
std::string image_path = replace_all_distinct(full_path, ".xml", image_type); | ||
image_path = replace_all_distinct(image_path, "\\labels\\", "\\images\\"); | ||
list_images.push_back(image_path); | ||
} | ||
//因为文件已经已经在lambda表达式中处理了, | ||
//不需要for_each_file返回文件列表,所以这里返回false | ||
return false; | ||
} | ||
, true//递归子目录 | ||
); | ||
} |
Oops, something went wrong.