@@ -18,7 +18,6 @@ namespace StyleTransferEffectComponent
1818 public sealed class StyleTransferVideoEffect : IBasicVideoEffect
1919 {
2020
21- private LearningModel _model = null ;
2221 private LearningModelSession _session ;
2322 private LearningModelBinding _binding ;
2423 string _inputImageDescription ;
@@ -27,19 +26,14 @@ public sealed class StyleTransferVideoEffect : IBasicVideoEffect
2726 public void Close ( MediaEffectClosedReason reason )
2827 {
2928 // Dispose of effect resources
30- if ( _model != null ) { _model = null ; }
3129 if ( _session != null ) { _session = null ; }
3230 if ( _binding != null ) { _binding = null ; }
3331 if ( _inputImageDescription != null ) { _inputImageDescription = null ; }
3432 if ( _outputImageDescription != null ) { _outputImageDescription = null ; }
3533 }
3634
3735
38- private int frameCount ;
39- public void DiscardQueuedFrames ( )
40- {
41- frameCount = 0 ;
42- }
36+ public void DiscardQueuedFrames ( ) { }
4337 public bool IsReadOnly { get { return false ; } }
4438
4539 private VideoEncodingProperties encodingProperties ;
@@ -71,20 +65,20 @@ public void SetProperties(IPropertySet configuration)
7165 this . configuration = configuration ;
7266 }
7367
74-
75- public LearningModel Model
68+ public LearningModelBinding Binding
7669 {
7770 get
7871 { // TODO: Read in model from configuration
7972 // If null, then fail.
8073 object val ;
81- if ( configuration != null && configuration . TryGetValue ( "Model " , out val ) )
74+ if ( configuration != null && configuration . TryGetValue ( "Binding " , out val ) )
8275 {
83- return ( LearningModel ) val ;
76+ return ( LearningModelBinding ) val ;
8477 }
8578 return null ; // Different default value/ raise exception
8679 }
8780 }
81+
8882 public LearningModelSession Session
8983 {
9084 get
@@ -128,18 +122,16 @@ public string OutputImageDescription
128122 }
129123
130124
131-
132125 public void ProcessFrame ( ProcessVideoFrameContext context )
133126 {
134127 using ( VideoFrame inputVideoFrame = context . InputFrame )
135128 using ( VideoFrame outputVideoFrame = context . OutputFrame )
136129 {
137- _model = Model ; // Don't even need to pass model, just session
130+ _binding = Binding ;
138131 _session = Session ;
139132 _inputImageDescription = InputImageDescription ;
140133 _outputImageDescription = OutputImageDescription ;
141134
142- _binding = new LearningModelBinding ( _session ) ;
143135 _binding . Bind ( _inputImageDescription , ImageFeatureValue . CreateFromVideoFrame ( inputVideoFrame ) ) ;
144136 _binding . Bind ( _outputImageDescription , ImageFeatureValue . CreateFromVideoFrame ( outputVideoFrame ) ) ; // Check if this correctly sets the context output
145137
0 commit comments