Specs:
IDE: Visual Studio Premium 2013
Language: C#
OpenCV: EmguCV v.2.4.2.1777
GPU: GeForce GTS 250
CPU: Intel Core i7-930
I'm seeing an issue where the CPU results seem to be more accurate than the GPU results using the same settings. Am I setting this up wrong or is this expected?
Variable setup:
Image<Emgu.CV.Structure.Bgr, byte> scene_img = new Image<Emgu.CV.Structure.Bgr, byte>(scene_org);
Image<Emgu.CV.Structure.Bgr, byte> match_img = new Image<Emgu.CV.Structure.Bgr, byte>(match_org);
GpuImage<Emgu.CV.Structure.Bgr, byte> scene_gpu = new GpuImage<Emgu.CV.Structure.Bgr, byte>(scene_img);
GpuImage<Emgu.CV.Structure.Bgr, byte> match_gpu = new GpuImage<Emgu.CV.Structure.Bgr, byte>(match_img);
GpuImage<Emgu.CV.Structure.Gray, float> result_gpu =
new GpuImage<Emgu.CV.Structure.Gray, float>(
(scene_img.Width - match_img.Width) + 1, (scene_img.Height - match_img.Height) + 1
);
Point minLoc = new Point(), maxLoc = new Point();
double minVal = 0, maxVal = 0;
GPU Code:
GpuInvoke.MatchTemplate(scene_gpu, match_gpu, result_gpu, TM_TYPE.CV_TM_CCOEFF_NORMED, IntPtr.Zero, IntPtr.Zero);
GpuInvoke.MinMaxLoc(result_gpu, ref minVal, ref maxVal, ref minLoc, ref maxLoc, IntPtr.Zero);
Console.WriteLine("minVal: " + minVal.ToString() + " maxVal: " + maxVal.ToString() + " minLoc: " + minLoc.ToString()
+ " maxLoc: " + maxLoc.ToString());
CPU Code:
Emgu.CV.Image<Emgu.CV.Structure.Gray, float> result_img =
new Image<Emgu.CV.Structure.Gray, float>(
(scene_img.Width - match_img.Width) + 1, (scene_img.Height - match_img.Height) + 1
);
Emgu.CV.CvInvoke.cvMatchTemplate(scene_img, match_img, result_img, TM_TYPE.CV_TM_CCOEFF_NORMED);
Emgu.CV.CvInvoke.cvMinMaxLoc(result_img, ref minVal, ref maxVal, ref minLoc, ref maxLoc, IntPtr.Zero);
Console.WriteLine("minVal: " + minVal.ToString() + " maxVal: " + maxVal.ToString() + " minLoc: " + minLoc.ToString()
+ " maxLoc: " + maxLoc.ToString());
GPU Results:
minVal: 0 maxVal: 0 minLoc: {X=224,Y=208} maxLoc: {X=224,Y=208}
CPU Results:
minVal: -0.199123710393906 maxVal: 1 minLoc: {X=1573,Y=9} maxLoc: {X=1360,Y=44}