title: Win10 UWP Custom Video Effect, IBasicVideoEffect
body: <p>I am trying to write my own implementation of <a href="https://msdn.microsoft.com/en-us/library/windows/apps/windows.media.effects.ibasicvideoeffect" rel="nofollow">IBasicVideoEffect</a> to analyze video frames in a Windows 10 UWP application, the end goal is using the Zxing.NET library to scan qr codes.</p>
  
  <p>I cannot add the video effect to the instance of <a href="https://msdn.microsoft.com/en-us/library/windows/apps/windows.media.capture.mediacapture.aspx" rel="nofollow">MediaCapture</a> in my code. The line <code>var effect = await _mediaCapture.AddVideoEffectAsync(new VideoEffectDefinition(typeof(MyVideoEffect).FullName), MediaStreamType.VideoPreview);</code> in Win10QR.MainPage.cs throws an exception stating <code>"Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))"</code></p>
  
  <p>MyVideoEffect.cs:</p>
  
  <pre><code>namespace Win10QR
  {
      public class MyVideoEffect : IBasicVideoEffect
      {
          public bool IsReadOnly
          {
              get
              {
                  return false;
              }
          }
  
          public IReadOnlyList&lt;VideoEncodingProperties&gt; SupportedEncodingProperties
          {
              get
              {
                  var properties = new List&lt;VideoEncodingProperties&gt;();
                  properties.Add(VideoEncodingProperties.CreateUncompressed("ARGB32", 640, 480));
                  return properties;
              }
          }
  
          public MediaMemoryTypes SupportedMemoryTypes
          {
              get
              {
                  return MediaMemoryTypes.GpuAndCpu;
              }
          }
  
          public bool TimeIndependent
          {
              get
              {
                  return false;
              }
          }
  
          public void Close(MediaEffectClosedReason reason)
          {
  
          }
  
          public void DiscardQueuedFrames()
          {
  
          }
  
          public void ProcessFrame(ProcessVideoFrameContext context)
          {
              var resultString = AnalyzeBitmap(context.InputFrame.SoftwareBitmap);
  
              if (resultString != null)
              {
                  Debug.WriteLine(resultString);
              }
          }
  
          public void SetEncodingProperties(VideoEncodingProperties encodingProperties, IDirect3DDevice device)
          {
  
          }
  
          public void SetProperties(IPropertySet configuration)
          {
  
          }
  
          private string AnalyzeBitmap(SoftwareBitmap bitmap)
          {
              var reader = new BarcodeReader();
              var writableBitmap = new WriteableBitmap(bitmap.PixelWidth, bitmap.PixelHeight);
              bitmap.CopyToBuffer(writableBitmap.PixelBuffer);
  
              var result = reader.Decode(writableBitmap);
  
              if (result != null)
              {
                  return result.Text;
              }
  
              return null;
          }
      }
  }
  </code></pre>
  
  <p>I have tried <code>var effect = await _mediaCapture.AddVideoEffectAsync(new VideoEffectDefinition("MyVideoEffect", MediaStreamType.VideoPreview);</code> and <code>var effect = await _mediaCapture.AddVideoEffectAsync(new VideoEffectDefinition("Win10QR.MyVideoEffect", MediaStreamType.VideoPreview);</code>, both throw the same exception as above.</p>
  
  <p>However, <code>var effect = await _mediaCapture.AddVideoEffectAsync(new VideoEffectDefinition("Windows.Media.VideoStabilizationEffect", MediaStreamType.VideoPreview);</code> seems to work for video stabilization.</p>
  
  <p>Out of curiosity, I tried putting any old class in, ex: <code>var effect = await _mediaCapture.AddVideoEffectAsync(new VideoEffectDefinition("Windows.UI.Xaml.DataTemplate", MediaStreamType.VideoPreview);</code> and a different exception was thrown: <code>"No such interface supported\r\n\r\nFailed to activate video effect"</code>, which makes sense. This leads me to believe that my implementation of the interface is not the problem.</p>
  
  <p>Is there something in my Package.appxmanifest or elsewhere that I need to do to get it to find my video effect class? Both classes are in the Win10QR namespace.</p>
  
  <p>Thanks for looking.</p>