private static void ConvertColor(IntPtr src, IntPtr dest, Type srcColor, Type destColor, Size size)
 {
     try
     {
         // if the direct conversion exist, apply the conversion
         OclInvoke.CvtColor(src, dest, CvToolbox.GetColorCvtCode(srcColor, destColor));
     }
     catch
     {
         try
         {
             //if a direct conversion doesn't exist, apply a two step conversion
             //in this case, needs to wait for the completion of the stream because a temporary local image buffer is used
             //we don't want the tmp image to be released before the operation is completed.
             using (OclImage <Bgr, TDepth> tmp = new OclImage <Bgr, TDepth>(size))
             {
                 OclInvoke.CvtColor(src, tmp.Ptr, CvToolbox.GetColorCvtCode(srcColor, typeof(Bgr)));
                 OclInvoke.CvtColor(tmp.Ptr, dest, CvToolbox.GetColorCvtCode(typeof(Bgr), destColor));
             }
         }
         catch
         {
             throw new NotSupportedException(String.Format(
                                                 "Convertion from OclImage<{0}, {1}> to OclImage<{2}, {3}> is not supported by OpenCV",
                                                 srcColor.ToString(),
                                                 typeof(TDepth).ToString(),
                                                 destColor.ToString(),
                                                 typeof(TDepth).ToString()));
         }
     }
 }