ConfidenceImage.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using bbiwarg.Images;
  7. using bbiwarg.Output;
  8. using Emgu.CV;
  9. using Emgu.CV.Structure;
  10. using bbiwarg.Utility;
  11. namespace bbiwarg.Images
  12. {
  13. /// <summary>
  14. /// ConfidenceImage stores the raw confidence data read from the Camera as an <see cref="Image"/>.
  15. /// </summary>
  16. public class ConfidenceImage
  17. {
  18. /// <summary>
  19. /// the size of the confidence image
  20. /// </summary>
  21. public ImageSize Size { get; private set; }
  22. /// <summary>
  23. /// the confidence image
  24. /// </summary>
  25. public Image<Gray, Int16> Image { get; private set; }
  26. /// <summary>
  27. /// a mask image, which is 1 iff the the confidence value is greater than <see cref="Parameters.ConfidenceImageMinThreshold"/>
  28. /// </summary>
  29. public Image<Gray, byte> Mask { get; private set; }
  30. /// <summary>
  31. /// Constructs a new ConfidenceImage using the specified data and size.
  32. /// </summary>
  33. /// <param name="rawConfidenceData">pointer to raw confidence data</param>
  34. /// <param name="size">size of the confidence image</param>
  35. public ConfidenceImage(IntPtr rawConfidenceData, ImageSize size)
  36. {
  37. Size = size;
  38. Image = new Image<Gray, Int16>(Size.Width, Size.Height, size.Width * 2, rawConfidenceData);
  39. Mask = (Image.ThresholdBinary(new Gray(Parameters.ConfidenceImageMinThreshold), new Gray(1))).Convert<Gray, byte>();
  40. }
  41. }
  42. }