public static void CopyImageConverted(CVImage source, CVImage target)
        {
            if (target.Size != source.Size)
            {
                target.Initialise(source.Size, target.NativeFormat);
            }

            COLOR_CONVERSION route = ConvertRoute(source.NativeFormat, target.NativeFormat);

            if (route == COLOR_CONVERSION.CV_COLORCVT_MAX)
            {
                CvInvoke.cvConvert(source.CvMat, target.CvMat);
            }
            else
            {
                try
                {
                    CvInvoke.cvCvtColor(source.CvMat, target.CvMat, route);
                }
                catch
                {
                    //CV likes to throw here sometimes, but the next frame it's fine
                }
            }
        }
Example #2
0
        public Picture DemosaickBayer8(COLOR_CONVERSION cc)
        {
            using (var bgr = new Picture(Width, Height))
            {
                var bgra = new Picture(Width, Height);

                CvInvoke.cvCvtColor(this.Gray.Ptr, bgr.Bgr.Ptr, cc);
                bgra.Bgra.ConvertFrom<Bgr, byte>(bgr.Bgr);

                return bgra;
            }
        }
Example #3
0
        public static void CopyImageConverted(CVImage source, CVImage target)
        {
            COLOR_CONVERSION route = ConvertRoute(source.NativeFormat, target.NativeFormat);

            if (route == COLOR_CONVERSION.CV_COLORCVT_MAX)
            {
                throw(new Exception("Unsupported conversion"));
            }

            try
            {
                CvInvoke.cvCvtColor(source.CvMat, target.CvMat, route);
            }
            catch
            {
                //CV likes to throw here sometimes, but the next frame it's fine
            }
        }