11#include " pch.h"
22#include " SampleHelper.h"
3-
43#include " Windows.AI.MachineLearning.Native.h"
54#include < MemoryBuffer.h>
65#include < windows.h>
@@ -15,27 +14,9 @@ using namespace winrt::Windows::Graphics::Imaging;
1514using namespace winrt ::Windows::Storage::Streams;
1615using namespace winrt ::Windows::Storage;
1716
18- EXTERN_C IMAGE_DOS_HEADER __ImageBase;
19-
2017#define BATCH_SIZE 3
2118
2219namespace SampleHelper {
23- std::wstring GetModulePath () {
24- std::wstring val;
25- wchar_t modulePath[MAX_PATH] = {0 };
26- GetModuleFileNameW ((HINSTANCE)&__ImageBase, modulePath, _countof (modulePath));
27- wchar_t drive[_MAX_DRIVE];
28- wchar_t dir[_MAX_DIR];
29- wchar_t filename[_MAX_FNAME];
30- wchar_t ext[_MAX_EXT];
31- _wsplitpath_s (modulePath, drive, _MAX_DRIVE, dir, _MAX_DIR, filename,
32- _MAX_FNAME, ext, _MAX_EXT);
33-
34- val = drive;
35- val += dir;
36-
37- return val;
38- }
3920
4021std::vector<float >
4122SoftwareBitmapToFloatVector (SoftwareBitmap softwareBitmap) {
@@ -110,10 +91,10 @@ hstring GetModelPath(std::string modelType) {
11091 hstring modelPath;
11192 if (modelType == " fixedBatchSize" ) {
11293 modelPath =
113- static_cast <hstring>(GetModulePath ().c_str ()) + L" SqueezeNet_batch3.onnx" ;
94+ static_cast <hstring>(FileHelper:: GetModulePath ().c_str ()) + L" SqueezeNet_batch3.onnx" ;
11495 } else {
11596 modelPath =
116- static_cast <hstring>(GetModulePath ().c_str ()) + L" SqueezeNet_free.onnx" ;
97+ static_cast <hstring>(FileHelper:: GetModulePath ().c_str ()) + L" SqueezeNet_free.onnx" ;
11798 }
11899 return modelPath;
119100}
@@ -122,7 +103,7 @@ TensorFloat CreateInputTensorFloat() {
122103 std::vector<hstring> imageNames = {L" fish.png" , L" kitten_224.png" , L" fish.png" };
123104 std::vector<float > inputVector = {};
124105 for (hstring imageName : imageNames) {
125- auto imagePath = static_cast <hstring>(GetModulePath ().c_str ()) + imageName;
106+ auto imagePath = static_cast <hstring>(FileHelper:: GetModulePath ().c_str ()) + imageName;
126107 auto imageFrame = LoadImageFile (imagePath);
127108 std::vector<float > imageVector =
128109 SoftwareBitmapToFloatVector (imageFrame.SoftwareBitmap ());
@@ -142,7 +123,7 @@ IVector<VideoFrame> CreateVideoFrames() {
142123 std::vector<hstring> imageNames = { L" fish.png" , L" kitten_224.png" , L" fish.png" };
143124 std::vector<VideoFrame> inputFrames = {};
144125 for (hstring imageName : imageNames) {
145- auto imagePath = static_cast <hstring>(GetModulePath ().c_str ()) + imageName;
126+ auto imagePath = static_cast <hstring>(FileHelper:: GetModulePath ().c_str ()) + imageName;
146127 auto imageFrame = LoadImageFile (imagePath);
147128 inputFrames.emplace_back (imageFrame);
148129 }
@@ -177,7 +158,7 @@ std::vector<std::string> LoadLabels(std::string labelsFilePath) {
177158
178159void PrintResults (IVectorView<float > results) {
179160 // load the labels
180- auto modulePath = GetModulePath ();
161+ auto modulePath = FileHelper:: GetModulePath ();
181162 std::string labelsFilePath =
182163 std::string (modulePath.begin (), modulePath.end ()) + " Labels.txt" ;
183164 std::vector<std::string> labels = LoadLabels (labelsFilePath);
0 commit comments