Browse Source

Added CudaColumnSumFilter, CudaDerivFilter, CudaMedianFilter, CudaRowSumFilter, CudaScharrFilter, CudaSeparableLinearFilter.

pull/84/head
Canming Huang 8 years ago
parent
commit
6cbb05ca73
  1. 4
      Emgu.CV.Contrib/BgSegm/BackgroundSubtractorCNT.cs
  2. 2
      Emgu.CV.Cuda/Bgsegm/CudaBackgroundSubtractorMOG2.cs
  3. 35
      Emgu.CV.Cuda/Filters/CudaColumnSumFilter.cs
  4. 45
      Emgu.CV.Cuda/Filters/CudaDerivFilter.cs
  5. 17
      Emgu.CV.Cuda/Filters/CudaFilter.cs
  6. 32
      Emgu.CV.Cuda/Filters/CudaMedianFilter.cs
  7. 31
      Emgu.CV.Cuda/Filters/CudaRowSumFilter.cs
  8. 43
      Emgu.CV.Cuda/Filters/CudaScharrFilter.cs
  9. 47
      Emgu.CV.Cuda/Filters/CudaSeparableLinearFilter.cs
  10. 48
      Emgu.CV.Extern/cudafilters/cudafilters_c.cpp
  11. 19
      Emgu.CV.Extern/cudafilters/cudafilters_c.h

4
Emgu.CV.Contrib/BgSegm/BackgroundSubtractorCNT.cs

@ -29,8 +29,8 @@ namespace Emgu.CV.BgSegm
useHistory,
maxPixelStability,
isParallel,
ref bgSubtractor,
ref algorithm);
ref _backgroundSubtractorPtr,
ref _algorithmPtr);
}
/// <summary>

2
Emgu.CV.Cuda/Bgsegm/CudaBackgroundSubtractorMOG2.cs

@ -62,7 +62,7 @@ namespace Emgu.CV.Cuda
int history,
double varThreshold,
[MarshalAs(CvInvoke.BoolMarshalType)]
bool detectShadows,
bool detectShadows,
ref IntPtr bgSubtractor,
ref IntPtr algorithm);

35
Emgu.CV.Cuda/Filters/CudaColumnSumFilter.cs

@ -0,0 +1,35 @@
//----------------------------------------------------------------------------
// Copyright (C) 2004-2017 by EMGU Corporation. All rights reserved.
//----------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using System.Drawing;
using Emgu.CV.CvEnum;
using Emgu.CV.Features2D;
using Emgu.CV.Structure;
using Emgu.CV.Util;
using Emgu.Util;
namespace Emgu.CV.Cuda
{
public class ColumnSumFilter : CudaFilter
{
public ColumnSumFilter(
DepthType srcDepth, int srcChannels,
DepthType dstDepth, int dstChannels,
int ksize, int anchor,
CvEnum.BorderType borderType = BorderType.Default, MCvScalar borderValue = new MCvScalar())
{
_ptr = CudaInvoke.cudaCreateColumnSumFilter(CvInvoke.MakeType(srcDepth, srcChannels), CvInvoke.MakeType(dstDepth, dstChannels), ksize, anchor, borderType, ref borderValue);
}
}
public static partial class CudaInvoke
{
[DllImport(CvInvoke.ExternCudaLibrary, CallingConvention = CvInvoke.CvCallingConvention)]
internal static extern IntPtr cudaCreateColumnSumFilter(int srcType, int dstType, int ksize, int anchor, CvEnum.BorderType borderMode, ref MCvScalar borderVal);
}
}

45
Emgu.CV.Cuda/Filters/CudaDerivFilter.cs

@ -0,0 +1,45 @@
//----------------------------------------------------------------------------
// Copyright (C) 2004-2017 by EMGU Corporation. All rights reserved.
//----------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using System.Drawing;
using Emgu.CV.CvEnum;
using Emgu.CV.Features2D;
using Emgu.CV.Structure;
using Emgu.CV.Util;
using Emgu.Util;
namespace Emgu.CV.Cuda
{
public class CudaDerivFilter : CudaFilter
{
public CudaDerivFilter(
DepthType srcDepth, int srcChannels, DepthType dstDepth, int dstChannels,
int dx, int dy,
int ksize, bool normalize, double scale,
CvEnum.BorderType rowBorderType = BorderType.Default,
CvEnum.BorderType columnBorderType = BorderType.Default)
{
_ptr = CudaInvoke.cudaCreateDerivFilter(CvInvoke.MakeType(srcDepth, srcChannels), CvInvoke.MakeType(dstDepth, dstChannels), dx, dy, ksize, normalize, scale, rowBorderType, columnBorderType);
}
}
public static partial class CudaInvoke
{
[DllImport(CvInvoke.ExternCudaLibrary, CallingConvention = CvInvoke.CvCallingConvention)]
internal static extern IntPtr cudaCreateDerivFilter(
int srcType, int dstType,
int dx, int dy,
int ksize,
[MarshalAs(CvInvoke.BoolMarshalType)]
bool normalize,
double scale,
CvEnum.BorderType rowBorderMode, CvEnum.BorderType columnBorderMode);
}
}

17
Emgu.CV.Cuda/Filters/CudaFilter.cs

@ -19,23 +19,6 @@ namespace Emgu.CV.Cuda
/// </summary>
public abstract class CudaFilter : UnmanagedObject
{
/*
/// <summary>
/// The MatType for CudaImage&lt; TColor, TDepth &gt;
/// </summary>
protected static int _matType;
/// <summary>
/// dummy code to make sure the _matType value is setup properly
/// </summary>
static CudaFilter()
{
using (CudaImage<TColor, TDepth> tmp = new CudaImage<TColor, TDepth>(4, 4))
{
_matType = tmp.Type;
}
}*/
/// <summary>
/// Release all the unmanaged memory associated with this gpu filter
/// </summary>

32
Emgu.CV.Cuda/Filters/CudaMedianFilter.cs

@ -0,0 +1,32 @@
//----------------------------------------------------------------------------
// Copyright (C) 2004-2017 by EMGU Corporation. All rights reserved.
//----------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using System.Drawing;
using Emgu.CV.CvEnum;
using Emgu.CV.Features2D;
using Emgu.CV.Structure;
using Emgu.CV.Util;
using Emgu.Util;
namespace Emgu.CV.Cuda
{
public class MedianFilter : CudaFilter
{
public MedianFilter(DepthType srcDepth, int srcChannels, int windowSize, int partition)
{
_ptr = CudaInvoke.cudaCreateMedianFilter(CvInvoke.MakeType(srcDepth, srcChannels), windowSize, partition);
}
}
public static partial class CudaInvoke
{
[DllImport(CvInvoke.ExternCudaLibrary, CallingConvention = CvInvoke.CvCallingConvention)]
internal static extern IntPtr cudaCreateMedianFilter(int srcType, int windowSize, int partition);
}
}

31
Emgu.CV.Cuda/Filters/CudaRowSumFilter.cs

@ -0,0 +1,31 @@
//----------------------------------------------------------------------------
// Copyright (C) 2004-2017 by EMGU Corporation. All rights reserved.
//----------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using System.Drawing;
using Emgu.CV.CvEnum;
using Emgu.CV.Features2D;
using Emgu.CV.Structure;
using Emgu.CV.Util;
using Emgu.Util;
namespace Emgu.CV.Cuda
{
public class RowSumFilter : CudaFilter
{
public RowSumFilter(DepthType srcDepth, int srcChannels, DepthType dstDepth, int dstChannels, int ksize, int anchor, CvEnum.BorderType borderType = BorderType.Default, MCvScalar borderValue = new MCvScalar())
{
_ptr = CudaInvoke.cudaCreateRowSumFilter(CvInvoke.MakeType(srcDepth, srcChannels), CvInvoke.MakeType(dstDepth, dstChannels), ksize, anchor, borderType, ref borderValue);
}
}
public static partial class CudaInvoke
{
[DllImport(CvInvoke.ExternCudaLibrary, CallingConvention = CvInvoke.CvCallingConvention)]
internal static extern IntPtr cudaCreateRowSumFilter(int srcType, int dstType, int ksize, int anchor, CvEnum.BorderType borderMode, ref MCvScalar borderVal);
}
}

43
Emgu.CV.Cuda/Filters/CudaScharrFilter.cs

@ -0,0 +1,43 @@
//----------------------------------------------------------------------------
// Copyright (C) 2004-2017 by EMGU Corporation. All rights reserved.
//----------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using System.Drawing;
using Emgu.CV.CvEnum;
using Emgu.CV.Features2D;
using Emgu.CV.Structure;
using Emgu.CV.Util;
using Emgu.Util;
namespace Emgu.CV.Cuda
{
public class ScharrFilter : CudaFilter
{
public ScharrFilter(
DepthType srcDepth, int srcChannels,
DepthType dstDepth, int dstChannels,
int dx, int dy,
double scale,
CvEnum.BorderType rowBorderMode = BorderType.Default,
CvEnum.BorderType columnBorderMode = BorderType.Default)
{
_ptr = CudaInvoke.cudaCreateScharrFilter(
CvInvoke.MakeType(srcDepth, srcChannels), CvInvoke.MakeType(dstDepth, dstChannels),
dx, dy, scale, rowBorderMode, columnBorderMode);
}
}
public static partial class CudaInvoke
{
[DllImport(CvInvoke.ExternCudaLibrary, CallingConvention = CvInvoke.CvCallingConvention)]
internal static extern IntPtr cudaCreateScharrFilter(
int srcType, int dstType, int dx, int dy,
double scale,
CvEnum.BorderType rowBorderMode, CvEnum.BorderType columnBorderMode);
}
}

47
Emgu.CV.Cuda/Filters/CudaSeparableLinearFilter.cs

@ -0,0 +1,47 @@
//----------------------------------------------------------------------------
// Copyright (C) 2004-2017 by EMGU Corporation. All rights reserved.
//----------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using System.Drawing;
using Emgu.CV.CvEnum;
using Emgu.CV.Features2D;
using Emgu.CV.Structure;
using Emgu.CV.Util;
using Emgu.CV;
using Emgu.Util;
namespace Emgu.CV.Cuda
{
/// <summary>
/// SeparableLinearFilter
/// </summary>
public class SeparableLinearFilter : CudaFilter
{
public SeparableLinearFilter(
DepthType srcDepth, int srcChannels,
DepthType dstDepth, int dstChannels,
IInputArray rowKernel,
IInputArray columnKernel,
Point anchor,
CvEnum.BorderType rowBorderType = BorderType.Default,
CvEnum.BorderType columnBorderType = BorderType.Default)
{
using (InputArray iaRowKernel = rowKernel.GetInputArray())
using (InputArray iaColumnKernel = columnKernel.GetInputArray())
_ptr = CudaInvoke.cudaCreateSeparableLinearFilter(CvInvoke.MakeType(srcDepth, srcChannels), CvInvoke.MakeType(dstDepth, dstChannels), iaRowKernel, iaColumnKernel, ref anchor, rowBorderType, columnBorderType);
}
}
public static partial class CudaInvoke
{
[DllImport(CvInvoke.ExternCudaLibrary, CallingConvention = CvInvoke.CvCallingConvention)]
internal static extern IntPtr cudaCreateSeparableLinearFilter(
int srcType, int dstType, IntPtr rowKernel, IntPtr columnKernel,
ref Point anchor, CvEnum.BorderType rowBorderMode, CvEnum.BorderType columnBorderMode);
}
}

48
Emgu.CV.Extern/cudafilters/cudafilters_c.cpp

@ -65,6 +65,54 @@ cv::cuda::Filter* cudaCreateMorphologyFilter( int op, int srcType, cv::_InputArr
return ptr.get();
}
cv::cuda::Filter* cudaCreateSeparableLinearFilter(
int srcType, int dstType, cv::_InputArray* rowKernel, cv::_InputArray* columnKernel,
CvPoint* anchor, int rowBorderMode, int columnBorderMode)
{
cv::Ptr<cv::cuda::Filter> ptr = cv::cuda::createSeparableLinearFilter(srcType, dstType, *rowKernel, *columnKernel, *anchor, rowBorderMode, columnBorderMode);
ptr.addref();
return ptr.get();
}
cv::cuda::Filter* cudaCreateDerivFilter(int srcType, int dstType, int dx, int dy,
int ksize, bool normalize, double scale,
int rowBorderMode, int columnBorderMode)
{
cv::Ptr<cv::cuda::Filter> ptr = cv::cuda::createDerivFilter(srcType, dstType, dx, dy, ksize, normalize, scale, rowBorderMode, columnBorderMode);
ptr.addref();
return ptr.get();
}
cv::cuda::Filter* cudaCreateScharrFilter(int srcType, int dstType, int dx, int dy,
double scale, int rowBorderMode, int columnBorderMode)
{
cv::Ptr<cv::cuda::Filter> ptr = cv::cuda::createScharrFilter(srcType, dstType, dx, dy, scale, rowBorderMode, columnBorderMode);
ptr.addref();
return ptr.get();
}
cv::cuda::Filter* cudaCreateRowSumFilter(int srcType, int dstType, int ksize, int anchor, int borderMode, CvScalar* borderVal)
{
cv::Ptr<cv::cuda::Filter> ptr = cv::cuda::createRowSumFilter(srcType, dstType, ksize, anchor, borderMode, *borderVal );
ptr.addref();
return ptr.get();
}
cv::cuda::Filter* cudaCreateColumnSumFilter(int srcType, int dstType, int ksize, int anchor, int borderMode, CvScalar* borderVal)
{
cv::Ptr<cv::cuda::Filter> ptr = cv::cuda::createColumnSumFilter(srcType, dstType, ksize, anchor, borderMode, *borderVal);
ptr.addref();
return ptr.get();
}
cv::cuda::Filter* cudaCreateMedianFilter(int srcType, int windowSize, int partition)
{
cv::Ptr<cv::cuda::Filter> ptr = cv::cuda::createMedianFilter(srcType, windowSize, partition);
ptr.addref();
return ptr.get();
}
//----------------------------------------------------------------------------
//
// CudaFilter

19
Emgu.CV.Extern/cudafilters/cudafilters_c.h

@ -31,6 +31,25 @@ CVAPI(cv::cuda::Filter*) cudaCreateBoxMinFilter( int srcType, CvSize* ksize, CvP
CVAPI(cv::cuda::Filter*) cudaCreateMorphologyFilter( int op, int srcType, cv::_InputArray* kernel, CvPoint* anchor, int iterations);
CVAPI(cv::cuda::Filter*) cudaCreateSeparableLinearFilter(
int srcType, int dstType, cv::_InputArray* rowKernel, cv::_InputArray* columnKernel,
CvPoint* anchor, int rowBorderMode, int columnBorderMode);
CVAPI(cv::cuda::Filter*) cudaCreateDerivFilter(int srcType, int dstType, int dx, int dy,
int ksize, bool normalize, double scale,
int rowBorderMode, int columnBorderMode);
CVAPI(cv::cuda::Filter*) cudaCreateScharrFilter(
int srcType, int dstType, int dx, int dy,
double scale, int rowBorderMode, int columnBorderMode);
CVAPI(cv::cuda::Filter*) cudaCreateRowSumFilter(int srcType, int dstType, int ksize, int anchor, int borderMode, CvScalar* borderVal);
CVAPI(cv::cuda::Filter*) cudaCreateColumnSumFilter(int srcType, int dstType, int ksize, int anchor, int borderMode, CvScalar* borderVal);
CVAPI(cv::cuda::Filter*) cudaCreateMedianFilter(int srcType, int windowSize, int partition);
//----------------------------------------------------------------------------
//
// CudaFilter

Loading…
Cancel
Save