Browse Source

Added a GpuMat constructor that accepts user-allocated data.

pull/910/head
Canming Huang 2 years ago
parent
commit
2c4d8212ad
  1. 19
      Emgu.CV.Cuda/GpuMat.cs
  2. 12
      Emgu.CV.Extern/core/core_cuda_c.cpp
  3. 2
      Emgu.CV.Extern/core/core_cuda_c.h

19
Emgu.CV.Cuda/GpuMat.cs

@ -33,6 +33,20 @@ namespace Emgu.CV.Cuda
{
}
/// <summary>
/// Create a GpuMat pointing to user-allocated data
/// </summary>
/// <param name="rows">The number of rows (height)</param>
/// <param name="cols">The number of columns (width)</param>
/// <param name="channels">The number of channels</param>
/// <param name="depthType">The type of depth</param>
/// <param name="data">User allocated data</param>
/// <param name="step">Use 0 for auto matically calculated step. Or specify the data step here.</param>
public GpuMat(int rows, int cols, DepthType depthType, int channels, IntPtr data, int step=0)
: this(CudaInvoke.gpuMatCreateFromData(rows, cols, CvInvoke.MakeType(depthType, channels), data, step), true)
{
}
/// <summary>
/// Create a GpuMat of the specified size
/// </summary>
@ -542,6 +556,11 @@ namespace Emgu.CV.Cuda
[DllImport(CvInvoke.ExternCudaLibrary, CallingConvention = CvInvoke.CvCallingConvention)]
internal static extern IntPtr gpuMatCreateDefault();
/// <summary>
/// Create an new GpuMat pointing to user-allocated data
/// </summary>
[DllImport(CvInvoke.ExternCudaLibrary, CallingConvention = CvInvoke.CvCallingConvention)]
internal static extern IntPtr gpuMatCreateFromData(int rows, int cols, int type, IntPtr data, int step);
/// <summary>
/// Convert a CvArr to a GpuMat

12
Emgu.CV.Extern/core/core_cuda_c.cpp

@ -163,13 +163,23 @@ bool targetArchsHasEqualOrGreaterBin(int major, int minor)
//
//----------------------------------------------------------------------------
cv::cuda::GpuMat* gpuMatCreateDefault() { return new cv::cuda::GpuMat(); }
cv::cuda::GpuMat* gpuMatCreateDefault()
{
return new cv::cuda::GpuMat();
}
cv::cuda::GpuMat* gpuMatCreateFromData(int rows, int cols, int type, void* data, int step)
{
return new cv::cuda::GpuMat(rows, cols, type, data, step);
}
void gpuMatCreate(cv::cuda::GpuMat* m, int rows, int cols, int type)
{
m->create(rows, cols, type);
}
cv::cuda::GpuMat* gpuMatCreateContinuous(int rows, int cols, int type)
{
cv::cuda::GpuMat* result = new cv::cuda::GpuMat();

2
Emgu.CV.Extern/core/core_cuda_c.h

@ -82,6 +82,8 @@ CVAPI(bool) targetArchsHasEqualOrGreaterBin(int major, int minor);
CVAPI(cv::cuda::GpuMat*) gpuMatCreateDefault();
CVAPI(cv::cuda::GpuMat*) gpuMatCreateFromData(int rows, int cols, int type, void* data, int step);
CVAPI(void) gpuMatCreate(cv::cuda::GpuMat* m, int rows, int cols, int type);
CVAPI(cv::cuda::GpuMat*) gpuMatCreateContinuous(int rows, int cols, int type);

Loading…
Cancel
Save