Exemplo n.º 1
0
        ///// <summary>
        ///// This function returnes number if pixels in image according to format, width and height.
        ///// </summary>
        ///// <param name="pf">Image data format in integer format</param>
        ///// <returns>Dot NET pixel format appropriate to the selected data format</returns>
        //internal PixelFormat XiDataFormatToNETPixelFormatInternal(int pf)
        //{
        //  PixelFormat pixelFormat = PixelFormat.Undefined;
        //  switch (pf)
        //  {
        //    case 0:
        //    case 5:
        //      return PixelFormat.Format8bppIndexed;
        //    case 1:
        //    case 6:
        //      return PixelFormat.Format16bppGrayScale;
        //    case 2:
        //    case 4:
        //      return PixelFormat.Format24bppRgb;
        //    case 3:
        //      return PixelFormat.Format32bppRgb;
        //    default:
        //      throw new xiExc(108, "XiDataFormatToNETPixelFormatInternal");
        //  }
        //}

        /// <summary>
        /// This function acquires image and returns XI_IMG structure.
        /// </summary>
        /// <param name="timeout">Time interval required to wait for the image (in milliseconds)</param>
        /// <returns>XI_IMG structure with information about acquired image.</returns>
        public XI_IMG GetXI_IMG(int timeout)
        {
            XI_IMG image = default(XI_IMG);

            image.Clear();
            GetXI_IMG(ref image, timeout);
            return(image);
        }
Exemplo n.º 2
0
        ///// <summary>
        ///// Gets processed image from processing chain.
        ///// </summary>
        ///// <param name="image">Bitmap image to be returned.</param>
        ///// <param name="timeout">Time interval required to wait for the image (in milliseconds)</param>
        //public void ProcPullImage(out Bitmap image, int timeout)
        //{
        //  XI_IMG img = default(XI_IMG);
        //  img.Clear();
        //  ProcPullImageInternal(out img, timeout);
        //  xiImg xiImg = new xiImg(img);
        //  xiImg.GetBitmapByRef(out image);
        //}

        ///// <summary>
        ///// Gets processed image from processing chain.
        ///// </summary>
        ///// <param name="image">BitmapSource image to be returned.</param>
        ///// <param name="timeout">Time interval required to wait for the image (in milliseconds)</param>
        //public void ProcPullImage(out BitmapSource image, int timeout)
        //{
        //  XI_IMG img = default(XI_IMG);
        //  img.Clear();
        //  ProcPullImageInternal(out img, timeout);
        //  xiImg xiImg = new xiImg(img);
        //  xiImg.GetBitmapSourceByRef(out image);
        //}

        ///// <summary>
        ///// Gets processed image from processing chain.
        ///// </summary>
        ///// <param name="val">WriteableBitmap image to be returned.</param>
        ///// <param name="timeout">Time interval required to wait for the image (in milliseconds)</param>
        //public void ProcPullImage(out WriteableBitmap image, int timeout)
        //{
        //  XI_IMG img = default(XI_IMG);
        //  img.Clear();
        //  ProcPullImageInternal(out img, timeout);
        //  xiImg xiImg = new xiImg(img);
        //  xiImg.GetWriteableBitmapByRef(out image);
        //}

        /// <summary>
        /// Gets processed image from processing chain.
        /// </summary>
        /// <param name="img_arr">Byte array image data to be returned.</param>
        /// <param name="timeout">Time interval required to wait for the image (in milliseconds)</param>
        public void ProcPullImage(out byte[] img_arr, int timeout)
        {
            XI_IMG img = default(XI_IMG);

            img.Clear();
            ProcPullImageInternal(out img, timeout);
            xiImg xiImg = new xiImg(img);

            xiImg.GetByteArrayByRef(out img_arr);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Set unprocessed image to processing chain, XI_IMG members will be used in processing chain.
        /// </summary>
        /// <param name="image">XI_IMG structure with image data.</param>
        public unsafe void ProcPushXiImg(XI_IMG image)
        {
            int num = 0;

            num = ximeaApi.xiProcPushXiImg((void *)handle, &image);
            if (num != 0)
            {
                throw new xiExc(num, "xiProcPushXiImg ");
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Set unprocessed image to processing chain, only pointer to data in XI_IMG will be used.
        /// </summary>
        /// <param name="image">Byte array of pixels of image to be processed.</param>
        public unsafe void ProcPushImage(XI_IMG image)
        {
            int num = 0;

            num = ximeaApi.xiProcPushImage((void *)handle, image.bp);
            if (num != 0)
            {
                throw new xiExc(num, "xiProcPushImage ");
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// This function acquires image into a byte array. Supports UNSAFE buffer policy mode.
        /// </summary>
        /// <param name="img_arr">Preallocated byte array to be filled</param>
        /// <param name="timeout">Time interval required to wait for the image (in milliseconds)</param>
        public void GetImage(out byte[] img_arr, int timeout)
        {
            XI_IMG input_img = default(XI_IMG);

            input_img.Clear();
            input_img = GetImageInternal(input_img, timeout);
            xiImg xiImg = new xiImg(input_img);

            xiImg.GetByteArrayByRef(out img_arr);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Internal handler of xiProcPullImage for all instances in class.
        /// </summary>
        /// <param name="img">XI_IMG struct to be filled.</param>
        /// <param name="timeout">Time interval required to wait for the image (in milliseconds)</param>
        internal unsafe void ProcPullImageInternal(out XI_IMG img, int timeout)
        {
            int    num    = 0;
            XI_IMG xI_IMG = default(XI_IMG);

            xI_IMG.Clear();
            num = ximeaApi.xiProcPullImage((void *)handle, timeout, &xI_IMG);
            if (num != 0)
            {
                throw new xiExc(num, "xiProcPushImage ");
            }
            img = xI_IMG;
        }
Exemplo n.º 7
0
        /// <summary>
        /// This function acquires image into a byte array. Supports SAFE buffer policy mode.
        /// </summary>
        /// <param name="img_arr">Preallocated byte array to be filled</param>
        /// <param name="timeout">Time interval required to wait for the image (in milliseconds)</param>
        public unsafe void GetImage(byte[] img_arr, int timeout)
        {
            if (img_arr == null)
            {
                throw new xiExc(11, "GetImage");
            }
            int paramInt = GetParamInt("buffer_policy");

            if (paramInt == 1)
            {
                XI_IMG input_img = default(XI_IMG);
                input_img.Clear();
                fixed(byte *bp = &img_arr[0])
                {
                    input_img.bp = bp;
                }

                input_img.bp_size = img_arr.Length;
                input_img         = GetImageInternal(input_img, timeout);
                return;
            }
            throw new xiExc(106, "ERROR: This function supports only UNSAFE buffer policy(BUFF_POLICY.SAFE).");
        }
Exemplo n.º 8
0
        /// <summary>
        /// Internal handler of xiGetImage for all instances in class.
        /// </summary>
        /// <param name="input_img">XI_IMG structure to be filled</param>
        /// <param name="timeout">Time interval required to wait for the image (in milliseconds)</param>
        internal unsafe XI_IMG GetImageInternal(XI_IMG input_img, int timeout)
        {
            int    num    = 0;
            XI_IMG xI_IMG = input_img;

            try
            {
                num = ximeaApi.xiGetImage((void *)handle, timeout, &xI_IMG);
            }
            catch (AccessViolationException)
            {
                throw new xiExc(9, "GetImage");
            }
            catch
            {
                num = 1;
            }
            if (num != 0)
            {
                throw new xiExc(num, "GetImage");
            }
            img_params.UpdateValues(xI_IMG);
            return(xI_IMG);
        }
 /// <summary>
 /// Update internal XI_IMG structure for image creation.
 /// </summary>
 /// <param name="image_struc">XI_IMG structure to be used for image geneartion.</param>
 public void SetImageData(XI_IMG image_struct)
 {
     img = image_struct;
 }
Exemplo n.º 10
0
 /// <summary>
 /// xiImg constructor passing XI_IMG structure.
 /// </summary>
 /// <param name="image_struc">XI_IMG structure to be used for image geneartion.</param>
 public xiImg(XI_IMG image_struc)
 {
     img.Clear();
     img = image_struc;
 }
Exemplo n.º 11
0
 /// <summary>
 /// Update internal data.
 /// </summary>
 internal void UpdateValues(XI_IMG update_struc)
 {
     image_params = update_struc;
 }
Exemplo n.º 12
0
 /// <summary>
 /// Constructor to initialize internal structure.
 /// </summary>
 public ImgParams()
 {
     image_params = default(XI_IMG);
     image_params.Clear();
 }
Exemplo n.º 13
0
 /// <summary>
 /// This function acquires image and returns XI_IMG structure.
 /// </summary>
 /// <param name="image">XI_IMG structure to be filled</param>
 /// <param name="timeout">Time interval required to wait for the image (in milliseconds)</param>
 public void GetXI_IMG(ref XI_IMG image, int timeout)
 {
     image = GetImageInternal(image, timeout);
 }