Skip to content

Commit c4de9cc

Browse files
it works! kinda
1 parent a83b5ff commit c4de9cc

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

Samples/StyleTransfer/VideoEffect/StyleTransferEffectCpp/StyleTransferEffect.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,9 @@ namespace winrt::StyleTransferEffectCpp::implementation
6767

6868
// bind the input and the output buffers by name
6969
bindings[swapchaindex].binding.Bind(InputImageDescription, input);
70-
bindings[swapchaindex].binding.Bind(OutputImageDescription, outputTransformed);
7170
// submit an eval and wait for it to finish submitting work
72-
std::lock_guard<mutex> guard{ Processing };
73-
bindings[swapchaindex].activetask = Session.EvaluateAsync(bindings[swapchaindex].binding, L"0");
71+
std::lock_guard<mutex> guard{ Processing }; // Is this still happening inside of Complete?
72+
bindings[swapchaindex].activetask = Session.EvaluateAsync(bindings[swapchaindex].binding, ss.str().c_str());
7473
bindings[swapchaindex].activetask.Completed([&](auto&& asyncInfo, winrt::Windows::Foundation::AsyncStatus const args) {
7574
OutputDebugString(L"PF Eval completed | ");
7675
//OutputDebugString(ss.str().c_str());
@@ -153,7 +152,9 @@ namespace winrt::StyleTransferEffectCpp::implementation
153152

154153
// Create set of bindings to cycle through
155154
for (int i = 0; i < swapChainEntryCount; i++) {
156-
bindings[swapChainIndex].binding = LearningModelBinding{ Session };
155+
bindings[i].binding = LearningModelBinding(Session);
156+
bindings[i].binding.Bind(OutputImageDescription, VideoFrame(Windows::Graphics::Imaging::BitmapPixelFormat::Bgra8, 720, 720));
157+
157158
}
158159
}
159160
}

Samples/StyleTransfer/VideoEffect/StyleTransferEffectCpp/StyleTransferEffect.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ namespace winrt::StyleTransferEffectCpp::implementation
1414
struct SwapChainEntry {
1515
LearningModelBinding binding;
1616
Windows::Foundation::IAsyncOperation<LearningModelEvaluationResult> activetask;
17-
SwapChainEntry() : binding(nullptr), activetask(nullptr) {}
17+
VideoFrame transformOutput;
18+
SwapChainEntry() :
19+
binding(nullptr),
20+
activetask(nullptr),
21+
transformOutput(Windows::Graphics::Imaging::BitmapPixelFormat::Bgra8, 720, 720) {}
1822
};
1923

2024
struct StyleTransferEffect : StyleTransferEffectT<StyleTransferEffect>
@@ -40,6 +44,8 @@ namespace winrt::StyleTransferEffectCpp::implementation
4044

4145
VideoEncodingProperties encodingProperties;
4246
std::mutex Processing;
47+
std::mutex Copy;
48+
4349
StyleTransferEffectNotifier Notifier;
4450
std::chrono::time_point<std::chrono::steady_clock> m_StartTime;
4551
bool firstProcessFrameCall = true;
@@ -50,7 +56,7 @@ namespace winrt::StyleTransferEffectCpp::implementation
5056
hstring InputImageDescription;
5157
hstring OutputImageDescription;
5258
int swapChainIndex = 0;
53-
static const int swapChainEntryCount = 1;
59+
static const int swapChainEntryCount = 10;
5460
SwapChainEntry bindings[swapChainEntryCount];
5561

5662
void EvaluateComplete(VideoFrame);

0 commit comments

Comments
 (0)