本文整理汇总了C#中GpuMat.ToMat方法的典型用法代码示例。如果您正苦于以下问题:C# GpuMat.ToMat方法的具体用法?C# GpuMat.ToMat怎么用?C# GpuMat.ToMat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GpuMat
的用法示例。
在下文中一共展示了GpuMat.ToMat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestCudaSURFKeypointDetection
public void TestCudaSURFKeypointDetection()
{
if (CudaInvoke.HasCuda)
{
Image<Gray, byte> image = new Image<Gray, byte>(200, 100);
image.SetRandUniform(new MCvScalar(), new MCvScalar(255));
GpuMat gpuMat = new GpuMat(image);
EmguAssert.IsTrue(gpuMat.ToMat().Equals(image.Mat));
CudaSURF cudaSurf = new CudaSURF(100.0f, 2, 4, false, 0.01f, false);
GpuMat cudaKpts = cudaSurf.DetectKeyPointsRaw(gpuMat, null);
VectorOfKeyPoint kpts = new VectorOfKeyPoint();
cudaSurf.DownloadKeypoints(cudaKpts, kpts);
}
}
示例2: TestErodeDilate
public void TestErodeDilate()
{
if (!CudaInvoke.HasCuda)
return;
int morphIter = 2;
Image<Gray, Byte> image = new Image<Gray, byte>(640, 320);
image.Draw(new CircleF(new PointF(200, 200), 30), new Gray(255.0), 4);
Size ksize = new Size(morphIter * 2 + 1, morphIter * 2 + 1);
using (GpuMat cudaImage = new GpuMat(image))
using (GpuMat cudaTemp = new GpuMat())
using (Stream stream = new Stream())
using (CudaBoxMaxFilter dilate = new CudaBoxMaxFilter(DepthType.Cv8U, 1, ksize, new Point(-1, -1), CvEnum.BorderType.Default, new MCvScalar()))
using (CudaBoxMinFilter erode = new CudaBoxMinFilter(DepthType.Cv8U, 1, ksize, new Point(-1, -1), CvEnum.BorderType.Default, new MCvScalar()))
{
//run the GPU version asyncrhonously with stream
erode.Apply(cudaImage, cudaTemp, stream);
dilate.Apply(cudaTemp, cudaImage, stream);
//run the CPU version in parallel to the gpu version.
using (Image<Gray, Byte> temp = new Image<Gray, byte>(image.Size))
{
CvInvoke.Erode(image, temp, null, new Point(-1, -1), morphIter, CvEnum.BorderType.Constant, new MCvScalar());
CvInvoke.Dilate(temp, image, null, new Point(-1, -1), morphIter, CvEnum.BorderType.Constant, new MCvScalar());
}
//syncrhonize with the GPU version
stream.WaitForCompletion();
Assert.IsTrue(cudaImage.ToMat().Equals(image.Mat));
}
}