public void TestCudaPyr() { if (!CudaInvoke.HasCuda) { return; } Image <Gray, Byte> img = new Image <Gray, byte>(640, 480); img.SetRandUniform(new MCvScalar(), new MCvScalar(255, 255, 255)); Image <Gray, Byte> down = img.PyrDown(); Image <Gray, Byte> up = down.PyrUp(); CudaImage <Gray, Byte> gImg = new CudaImage <Gray, byte>(img); CudaImage <Gray, Byte> gDown = new CudaImage <Gray, byte>(img.Size.Width >> 1, img.Size.Height >> 1); CudaImage <Gray, Byte> gUp = new CudaImage <Gray, byte>(img.Size); CudaInvoke.PyrDown(gImg, gDown, null); CudaInvoke.PyrUp(gDown, gUp, null); CvInvoke.AbsDiff(down, gDown.ToImage(), down); CvInvoke.AbsDiff(up, gUp.ToImage(), up); double[] minVals, maxVals; Point[] minLocs, maxLocs; down.MinMax(out minVals, out maxVals, out minLocs, out maxLocs); double maxVal = 0.0; for (int i = 0; i < maxVals.Length; i++) { if (maxVals[i] > maxVal) { maxVal = maxVals[i]; } } Trace.WriteLine(String.Format("Max diff: {0}", maxVal)); EmguAssert.IsTrue(maxVal <= 1.0); //Assert.LessOrEqual(maxVal, 1.0); up.MinMax(out minVals, out maxVals, out minLocs, out maxLocs); maxVal = 0.0; for (int i = 0; i < maxVals.Length; i++) { if (maxVals[i] > maxVal) { maxVal = maxVals[i]; } } Trace.WriteLine(String.Format("Max diff: {0}", maxVal)); EmguAssert.IsTrue(maxVal <= 1.0); //Assert.LessOrEqual(maxVal, 1.0); }