You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.8 KiB

13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
12 years ago
13 years ago
12 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
12 years ago
13 years ago
12 years ago
13 years ago
  1. //----------------------------------------------------------------------------
  2. // Copyright (C) 2004-2020 by EMGU Corporation. All rights reserved.
  3. //----------------------------------------------------------------------------
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Diagnostics;
  7. using System.Runtime.InteropServices;
  8. using System.Text;
  9. using Emgu.Util;
  10. namespace Emgu.CV.Cuda
  11. {
  12. /// <summary>
  13. /// Encapculates Cuda Stream. Provides interface for async coping.
  14. /// Passed to each function that supports async kernel execution.
  15. /// Reference counting is enabled
  16. /// </summary>
  17. public class Stream : UnmanagedObject
  18. {
  19. /// <summary>
  20. /// Create a new Cuda Stream
  21. /// </summary>
  22. public Stream()
  23. {
  24. _ptr = CudaInvoke.streamCreate();
  25. }
  26. /// <summary>
  27. /// Wait for the completion
  28. /// </summary>
  29. public void WaitForCompletion()
  30. {
  31. CudaInvoke.streamWaitForCompletion(_ptr);
  32. }
  33. /// <summary>
  34. /// Check if the stream is completed
  35. /// </summary>
  36. public bool Completed
  37. {
  38. get { return CudaInvoke.streamQueryIfComplete(_ptr); }
  39. }
  40. /*
  41. /// <summary>
  42. /// Copy the src GpuMat to dst GpuMat asyncronously
  43. /// </summary>
  44. /// <typeparam name="TDepth">The type of depth for the GpuMat</typeparam>
  45. /// <param name="src">The source matrix</param>
  46. /// <param name="dst">The destination matrix. Must be the same size and same number of channels</param>
  47. public void Copy<TDepth>(GpuMat<TDepth> src, GpuMat<TDepth> dst) where TDepth : new()
  48. {
  49. GpuInvoke.streamEnqueueCopy(_ptr, src, dst);
  50. }*/
  51. /// <summary>
  52. /// Release the stream
  53. /// </summary>
  54. protected override void DisposeObject()
  55. {
  56. CudaInvoke.streamRelease(ref _ptr);
  57. }
  58. }
  59. public static partial class CudaInvoke
  60. {
  61. [DllImport(CvInvoke.ExternCudaLibrary, CallingConvention = CvInvoke.CvCallingConvention)]
  62. internal static extern IntPtr streamCreate();
  63. [DllImport(CvInvoke.ExternCudaLibrary, CallingConvention = CvInvoke.CvCallingConvention)]
  64. internal static extern void streamRelease(ref IntPtr stream);
  65. [DllImport(CvInvoke.ExternCudaLibrary, CallingConvention = CvInvoke.CvCallingConvention)]
  66. internal static extern void streamWaitForCompletion(IntPtr stream);
  67. [DllImport(CvInvoke.ExternCudaLibrary, CallingConvention = CvInvoke.CvCallingConvention)]
  68. [return: MarshalAs(CvInvoke.BoolMarshalType)]
  69. internal static extern bool streamQueryIfComplete(IntPtr stream);
  70. /*
  71. [DllImport(CvInvoke.EXTERN_GPU_LIBRARY, CallingConvention = CvInvoke.CvCallingConvention)]
  72. internal static extern void streamEnqueueCopy(IntPtr stream, IntPtr src, IntPtr dst);
  73. */
  74. }
  75. }