Exemplo n.º 1
0
        /// <summary>
        /// 行列とスカラーのxor演算子。cvXorSにより求める。
        /// </summary>
        /// <param name="a">行列</param>
        /// <param name="b">スカラー</param>
        /// <returns></returns>
#else
        /// <summary>
        /// Bitwise XOR operator (cvXorS)
        /// </summary>
        /// <param name="a">matrix</param>
        /// <param name="b">scalar</param>
        /// <returns></returns>
#endif
        public static CvSparseMat operator ^(CvSparseMat a, CvScalar b)
        {
            if (a == null)
            {
                throw new ArgumentNullException("a");
            }
            CvSparseMat result = a.Clone();

            Cv.XorS(a, b, result);
            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 行列とスカラーの乗算演算子。aの要素ごとにbをかけた結果をcvAddWeightedにより求める。
        /// </summary>
        /// <param name="a">行列</param>
        /// <param name="b">スカラー</param>
        /// <returns></returns>
#else
        /// <summary>
        /// Multiplicative operator (cvAddWeighted)
        /// </summary>
        /// <param name="a">matrix</param>
        /// <param name="b">scalar</param>
        /// <returns></returns>
#endif
        public static CvSparseMat operator *(CvSparseMat a, Double b)
        {
            if (a == null)
            {
                throw new ArgumentNullException("a");
            }
            CvSparseMat result = a.Clone();

            Cv.AddWeighted(a, b, a, 0, 0, result);
            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 行列の単項not演算子
        /// </summary>
        /// <param name="a">行列</param>
        /// <returns></returns>
#else
        /// <summary>
        /// Logical nagation operator
        /// </summary>
        /// <param name="a">matrix</param>
        /// <returns></returns>
#endif
        public static CvSparseMat operator ~(CvSparseMat a)
        {
            if (a == null)
            {
                throw new ArgumentNullException("a");
            }
            CvSparseMat result = a.Clone();

            Cv.Not(a, result);
            return(result);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 指定した2つの行列のデータタイプが等しければtrueを返す
        /// </summary>
        /// <param name="mat1">1つ目の入力行列</param>
        /// <param name="mat2">2つ目の入力行列</param>
        /// <returns></returns>
#else
        /// <summary>
        ///
        /// </summary>
        /// <param name="mat1"></param>
        /// <param name="mat2"></param>
        /// <returns></returns>
#endif
        public static bool ARE_TYPES_EQ(CvSparseMat mat1, CvSparseMat mat2)
        {
            if (mat1 == null)
            {
                throw new ArgumentNullException("mat1");
            }
            if (mat2 == null)
            {
                throw new ArgumentNullException("mat2");
            }
            return(((mat1.Type ^ mat2.Type) & CvConst.CV_MAT_TYPE_MASK) == 0);
        }
Exemplo n.º 5
0
        /// <summary>
        /// CV_NODE_VAL
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="mat"></param>
        /// <param name="node"></param>
        /// <returns></returns>
#else
        /// <summary>
        /// CV_NODE_VAL
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="mat"></param>
        /// <param name="node"></param>
        /// <returns></returns>
#endif
        public static T NODE_VAL <T>(CvSparseMat mat, CvSparseNode node) where T : struct
        {
            if (mat == null)
            {
                throw new ArgumentNullException("mat");
            }
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            IntPtr p = NODE_VAL(mat, node);

            return(Util.ToObject <T>(p));
        }
Exemplo n.º 6
0
        /// <summary>
        /// 疎な配列要素のイテレータを初期化する (cvInitSparseMatIterator)
        /// </summary>
        /// <param name="m">入力配列</param>
        /// <returns>疎な配列の先頭要素</returns>
#else
        /// <summary>
        /// Initializes sparse array elements iterator
        /// </summary>
        /// <param name="m">Input array</param>
        /// <returns>the first sparse matrix element</returns>
#endif
        public CvSparseNode Init(CvSparseMat m)
        {
            if (m == null)
            {
                throw new ArgumentNullException("m");
            }
            mat = m;
            IntPtr result = NativeMethods.cvInitSparseMatIterator(mat.CvPtr, CvPtr);

            if (result == IntPtr.Zero)
            {
                return(null);
            }
            return(new CvSparseNode(result));
        }
Exemplo n.º 7
0
        /// <summary>
        /// 行列と行列のor演算子。cvOrにより求める。
        /// </summary>
        /// <param name="a">行列</param>
        /// <param name="b">行列</param>
        /// <returns></returns>
#else
        /// <summary>
        /// Bitwise OR operator (cvOr)
        /// </summary>
        /// <param name="a">matrix</param>
        /// <param name="b">matrix</param>
        /// <returns></returns>
#endif
        public static CvSparseMat operator |(CvSparseMat a, CvSparseMat b)
        {
            if (a == null)
            {
                throw new ArgumentNullException("a");
            }
            if (b == null)
            {
                throw new ArgumentNullException("b");
            }
            CvSparseMat result = a.Clone();

            Cv.Or(a, b, result);
            return(result);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 行列とスカラーの除算演算子。aの要素ごとにbで割った結果をcvAddWeightedにより求める。
        /// </summary>
        /// <param name="a">行列</param>
        /// <param name="b">スカラー</param>
        /// <returns></returns>
#else
        /// <summary>
        /// Division operator (cvAddWeighted)
        /// </summary>
        /// <param name="a">matrix</param>
        /// <param name="b">scalar</param>
        /// <returns></returns>
#endif
        public static CvSparseMat operator /(CvSparseMat a, double b)
        {
            if (a == null)
            {
                throw new ArgumentNullException("a");
            }
            if (b == 0)
            {
                throw new DivideByZeroException();
            }
            CvSparseMat result = a.Clone();

            Cv.AddWeighted(a, 1.0 / b, a, 0, 0, result);
            return(result);
        }
Exemplo n.º 9
0
        /// <summary>
        /// CV_NODE_VAL
        /// </summary>
        /// <param name="mat"></param>
        /// <param name="node"></param>
        /// <returns></returns>
#else
        /// <summary>
        /// CV_NODE_VAL
        /// </summary>
        /// <param name="mat"></param>
        /// <param name="node"></param>
        /// <returns></returns>
#endif
        public static IntPtr NODE_VAL(CvSparseMat mat, CvSparseNode node)
        {
            if (mat == null)
            {
                throw new ArgumentNullException("mat");
            }
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            unsafe
            {
                return(new IntPtr(((byte *)node.CvPtr + mat.ValOffset)));
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// CV_NODE_IDX
        /// </summary>
        /// <param name="mat"></param>
        /// <param name="node"></param>
        /// <returns></returns>
#else
        /// <summary>
        /// CV_NODE_IDX
        /// </summary>
        /// <param name="mat"></param>
        /// <param name="node"></param>
        /// <returns></returns>
#endif
        public static PointerAccessor1D_Int32 NODE_IDX(CvSparseMat mat, CvSparseNode node)
        {
            if (mat == null)
            {
                throw new ArgumentNullException("mat");
            }
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            unsafe
            {
                int *p = (int *)((byte *)node.CvPtr + mat.IdxOffset);
                return(new PointerAccessor1D_Int32(p));
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// 対象のCvSparseMatを指定して初期化
        /// </summary>
        /// <param name="mat">入力配列</param>
#else
        /// <summary>
        /// Initializes with CvSparseMat
        /// </summary>
        /// <param name="mat">Input array</param>
#endif
        public CvSparseMatIterator(CvSparseMat mat)
        {
            ptr = AllocMemory(SizeOf);
            Init(mat);
        }