Example #1
0
        /// <summary>
        /// This function retrieve the Open CV structure sizes in unmanaged code
        /// </summary>
        /// <returns>The structure that will hold the Open CV structure sizes</returns>
        public static CvStructSizes GetCvStructSizes()
        {
            CvStructSizes sizes = new CvStructSizes();

            cveGetCvStructSizes(ref sizes);
            return(sizes);
        }
Example #2
0
        /*
         * private static int _CV_DepthType(int flag)
         * {
         * return flag & ((1 << 3) - 1);
         * }
         * private static int _CV_MAT_TYPE(int type)
         * {
         * return type & ((1 << 3) * 64 - 1);
         * }
         *
         * private static int _CV_MAT_CN(int flag)
         * {
         * return ((((flag) & ((64 - 1) << 3)) >> 3) + 1);
         * }
         * private static int _CV_ELEM_SIZE(int type)
         * {
         * return (_CV_MAT_CN(type) << ((((4 / 4 + 1) * 16384 | 0x3a50) >> _CV_DepthType(type) * 2) & 3));
         * }
         *
         * /// <summary>
         * /// Generate 4-character code of codec used to compress the frames. For example, CV_FOURCC('P','I','M','1') is MPEG-1 codec, CV_FOURCC('M','J','P','G') is motion-jpeg codec etc.
         * /// </summary>
         * /// <param name="c1"></param>
         * /// <param name="c2"></param>
         * /// <param name="c3"></param>
         * /// <param name="c4"></param>
         * /// <returns></returns>
         * public static int CV_FOURCC(char c1, char c2, char c3, char c4)
         * {
         * return (((c1) & 255) + (((c2) & 255) << 8) + (((c3) & 255) << 16) + (((c4) & 255) << 24));
         * }*/
        #endregion

        /// <summary>
        /// Check if the size of the C structures match those of C#
        /// </summary>
        /// <returns>True if the size matches</returns>
        public static bool SanityCheck()
        {
            bool sane = true;

            CvStructSizes sizes = new CvStructSizes();

            CvInvoke.GetCvStructSizes(ref sizes);

            sane &= (sizes.CvBox2D == Marshal.SizeOf(typeof(RotatedRect)));
            sane &= (sizes.CvContour == Marshal.SizeOf(typeof(MCvContour)));
            //sane &= (sizes.CvHistogram == Marshal.SizeOf(typeof(MCvHistogram)));
            sane &= (sizes.CvMat == Marshal.SizeOf(typeof(MCvMat)));
            sane &= (sizes.CvMatND == Marshal.SizeOf(typeof(MCvMatND)));
            sane &= (sizes.CvPoint == Marshal.SizeOf(typeof(System.Drawing.Point)));
            sane &= (sizes.CvPoint2D32f == Marshal.SizeOf(typeof(System.Drawing.PointF)));
            sane &= (sizes.CvPoint3D32f == Marshal.SizeOf(typeof(MCvPoint3D32f)));
            sane &= (sizes.CvRect == Marshal.SizeOf(typeof(System.Drawing.Rectangle)));
            sane &= (sizes.CvScalar == Marshal.SizeOf(typeof(MCvScalar)));
            sane &= (sizes.CvSeq == Marshal.SizeOf(typeof(MCvSeq)));
            sane &= (sizes.CvSize == Marshal.SizeOf(typeof(System.Drawing.Size)));
            sane &= (sizes.CvSize2D32f == Marshal.SizeOf(typeof(System.Drawing.SizeF)));
            sane &= (sizes.CvTermCriteria == Marshal.SizeOf(typeof(MCvTermCriteria)));
            sane &= (sizes.ERStat == Marshal.SizeOf(typeof(MCvERStat)));

            return(sane);
        }
Example #3
0
        /*
         * /// <summary>
         * /// Generate 4-character code of codec used to compress the frames. For example, CV_FOURCC('P','I','M','1') is MPEG-1 codec, CV_FOURCC('M','J','P','G') is motion-jpeg codec etc.
         * /// </summary>
         * /// <param name="c1"></param>
         * /// <param name="c2"></param>
         * /// <param name="c3"></param>
         * /// <param name="c4"></param>
         * /// <returns></returns>
         * public static int CV_FOURCC(char c1, char c2, char c3, char c4)
         * {
         * return (((c1) & 255) + (((c2) & 255) << 8) + (((c3) & 255) << 16) + (((c4) & 255) << 24));
         * }*/
        #endregion

        /// <summary>
        /// Check if the size of the C structures match those of C#
        /// </summary>
        /// <returns>True if the size matches</returns>
        public static bool SanityCheck()
        {
            bool sane = true;

            CvStructSizes sizes = CvInvoke.GetCvStructSizes();

            sane &= (sizes.CvBox2D == Toolbox.SizeOf <RotatedRect>());
            sane &= (sizes.CvMat == Toolbox.SizeOf <MCvMat>());
            sane &= (sizes.CvMatND == Toolbox.SizeOf <MCvMatND>());
            sane &= (sizes.CvPoint == Toolbox.SizeOf <System.Drawing.Point>());
            sane &= (sizes.CvPoint2D32f == Toolbox.SizeOf <System.Drawing.PointF>());
            sane &= (sizes.CvPoint3D32f == Toolbox.SizeOf <MCvPoint3D32f>());
            sane &= (sizes.CvRect == Toolbox.SizeOf <System.Drawing.Rectangle>());
            sane &= (sizes.CvScalar == Toolbox.SizeOf <MCvScalar>());
            sane &= (sizes.CvSize == Toolbox.SizeOf <System.Drawing.Size>());
            sane &= (sizes.CvSize2D32f == Toolbox.SizeOf <System.Drawing.SizeF>());
            sane &= (sizes.CvTermCriteria == Toolbox.SizeOf <MCvTermCriteria>());
            sane &= 2 * Toolbox.SizeOf <int>() == Toolbox.SizeOf <Range>();
            return(sane);
        }
Example #4
0
        /*
         * private static int _CV_DepthType(int flag)
         * {
         * return flag & ((1 << 3) - 1);
         * }
         * private static int _CV_MAT_TYPE(int type)
         * {
         * return type & ((1 << 3) * 64 - 1);
         * }
         *
         * private static int _CV_MAT_CN(int flag)
         * {
         * return ((((flag) & ((64 - 1) << 3)) >> 3) + 1);
         * }
         * private static int _CV_ELEM_SIZE(int type)
         * {
         * return (_CV_MAT_CN(type) << ((((4 / 4 + 1) * 16384 | 0x3a50) >> _CV_DepthType(type) * 2) & 3));
         * }
         *
         * /// <summary>
         * /// Generate 4-character code of codec used to compress the frames. For example, CV_FOURCC('P','I','M','1') is MPEG-1 codec, CV_FOURCC('M','J','P','G') is motion-jpeg codec etc.
         * /// </summary>
         * /// <param name="c1"></param>
         * /// <param name="c2"></param>
         * /// <param name="c3"></param>
         * /// <param name="c4"></param>
         * /// <returns></returns>
         * public static int CV_FOURCC(char c1, char c2, char c3, char c4)
         * {
         * return (((c1) & 255) + (((c2) & 255) << 8) + (((c3) & 255) << 16) + (((c4) & 255) << 24));
         * }*/
        #endregion

        /// <summary>
        /// Check if the size of the C structures match those of C#
        /// </summary>
        /// <returns>True if the size matches</returns>
        public static bool SanityCheck()
        {
            bool sane = true;

            CvStructSizes sizes = CvInvoke.GetCvStructSizes();

#if NETFX_CORE
            sane &= (sizes.CvBox2D == Marshal.SizeOf <RotatedRect>());
            sane &= (sizes.CvContour == Marshal.SizeOf <MCvContour>());
            //sane &= (sizes.CvHistogram == Marshal.SizeOf(typeof(MCvHistogram)));
            sane &= (sizes.CvMat == Marshal.SizeOf <MCvMat>());
            sane &= (sizes.CvMatND == Marshal.SizeOf <MCvMatND>());
            sane &= (sizes.CvPoint == Marshal.SizeOf <System.Drawing.Point>());
            sane &= (sizes.CvPoint2D32f == Marshal.SizeOf <System.Drawing.PointF>());
            sane &= (sizes.CvPoint3D32f == Marshal.SizeOf <MCvPoint3D32f>());
            sane &= (sizes.CvRect == Marshal.SizeOf <System.Drawing.Rectangle>());
            sane &= (sizes.CvScalar == Marshal.SizeOf <MCvScalar>());
            sane &= (sizes.CvSeq == Marshal.SizeOf <MCvSeq>());
            sane &= (sizes.CvSize == Marshal.SizeOf <System.Drawing.Size>());
            sane &= (sizes.CvSize2D32f == Marshal.SizeOf <System.Drawing.SizeF>());
            sane &= (sizes.CvTermCriteria == Marshal.SizeOf <MCvTermCriteria>());
#else
            sane &= (sizes.CvBox2D == Marshal.SizeOf(typeof(RotatedRect)));
            sane &= (sizes.CvContour == Marshal.SizeOf(typeof(MCvContour)));
            //sane &= (sizes.CvHistogram == Marshal.SizeOf(typeof(MCvHistogram)));
            sane &= (sizes.CvMat == Marshal.SizeOf(typeof(MCvMat)));
            sane &= (sizes.CvMatND == Marshal.SizeOf(typeof(MCvMatND)));
            sane &= (sizes.CvPoint == Marshal.SizeOf(typeof(System.Drawing.Point)));
            sane &= (sizes.CvPoint2D32f == Marshal.SizeOf(typeof(System.Drawing.PointF)));
            sane &= (sizes.CvPoint3D32f == Marshal.SizeOf(typeof(MCvPoint3D32f)));
            sane &= (sizes.CvRect == Marshal.SizeOf(typeof(System.Drawing.Rectangle)));
            sane &= (sizes.CvScalar == Marshal.SizeOf(typeof(MCvScalar)));
            sane &= (sizes.CvSeq == Marshal.SizeOf(typeof(MCvSeq)));
            sane &= (sizes.CvSize == Marshal.SizeOf(typeof(System.Drawing.Size)));
            sane &= (sizes.CvSize2D32f == Marshal.SizeOf(typeof(System.Drawing.SizeF)));
            sane &= (sizes.CvTermCriteria == Marshal.SizeOf(typeof(MCvTermCriteria)));
#endif

            return(sane);
        }
Example #5
0
 private static extern void cveGetCvStructSizes(ref CvStructSizes sizes);
Example #6
0
 public static extern void GetCvStructSizes(ref CvStructSizes sizes);