private CvtColor ( |
||
src | ||
dst | ||
code | CvEnum | |
stream | ||
return | void |
private static void ConvertColor(IntPtr src, IntPtr dest, Type srcColor, Type destColor, Size size, Stream stream) { try { // if the direct conversion exist, apply the conversion GpuInvoke.CvtColor(src, dest, CvToolbox.GetColorCvtCode(srcColor, destColor), stream); } 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 (GpuImage <Bgr, TDepth> tmp = new GpuImage <Bgr, TDepth>(size)) { GpuInvoke.CvtColor(src, tmp.Ptr, CvToolbox.GetColorCvtCode(srcColor, typeof(Bgr)), stream); GpuInvoke.CvtColor(tmp.Ptr, dest, CvToolbox.GetColorCvtCode(typeof(Bgr), destColor), stream); stream.WaitForCompletion(); } } catch { throw new NotSupportedException(String.Format( "Convertion from Image<{0}, {1}> to Image<{2}, {3}> is not supported by OpenCV", srcColor.ToString(), typeof(TDepth).ToString(), destColor.ToString(), typeof(TDepth).ToString())); } } }
private static void ConvertColor(IntPtr src, IntPtr dest, Type srcColor, Type destColor, Size size, Stream stream) { try { // if the direct conversion exist, apply the conversion GpuInvoke.CvtColor(src, dest, CvToolbox.GetColorCvtCode(srcColor, destColor), stream); } catch { try { //if a direct conversion doesn't exist, apply a two step conversion using (GpuImage <Bgr, TDepth> tmp = new GpuImage <Bgr, TDepth>(size)) { GpuInvoke.CvtColor(src, tmp.Ptr, CvToolbox.GetColorCvtCode(srcColor, typeof(Bgr)), stream); GpuInvoke.CvtColor(tmp.Ptr, dest, CvToolbox.GetColorCvtCode(typeof(Bgr), destColor), stream); } } catch { throw new NotSupportedException(String.Format( "Convertion from Image<{0}, {1}> to Image<{2}, {3}> is not supported by OpenCV", srcColor.ToString(), typeof(TDepth).ToString(), destColor.ToString(), typeof(TDepth).ToString())); } } }