Exemple #1
0
        public override ARESULT Initialize(Dictionary <string, object> arguments)
        {
            device = arguments["device"] as IDevice;

            // 读取配置信息
            if (!device.Read(ReadMode.IrCameraParameters, null, out object outData, out _))
            {
                return(ARESULT.E_INVALIDARG);
            }

            // 创建资源
            Repository.Entities.Configuration.IrCameraParameters irCameraParameters = outData as Repository.Entities.Configuration.IrCameraParameters;
            temperature = PinnedBuffer <float> .Alloc(irCameraParameters.temperatureWidth *irCameraParameters.temperatureHeight);

            irImage = PinnedBuffer <byte> .Alloc(irCameraParameters.width *irCameraParameters.height * 3 / 2);

            tempertureDuration = 1000 / irCameraParameters.temperatureFrameRate;

            // 读取配置信息
            if (!device.Read(ReadMode.CameraParameters, null, out outData, out _))
            {
                return(ARESULT.E_INVALIDARG);
            }

            // 创建资源
            Repository.Entities.Configuration.CameraParameters cameraParameters = outData as Repository.Entities.Configuration.CameraParameters;
            image = PinnedBuffer <byte> .Alloc(cameraParameters.width *cameraParameters.height * 3 / 2);

            videoDuration = 1000 / cameraParameters.videoFrameRate;

            return(base.Initialize(arguments));
        }
Exemple #2
0
        /// <summary>
        /// 克隆数组
        /// </summary>
        /// <typeparam name="T">类型</typeparam>
        /// <param name="from">原数组</param>
        /// <param name="to">目标数组</param>
        /// <returns>数组</returns>
        public static PinnedBuffer <T> Clone <T>(T[] from, PinnedBuffer <T> to)
        {
            var result = to;

            if ((to == null) || (to.Length != from.Length))
            {
                result = PinnedBuffer <T> .Alloc(from.Length);
            }

            lock (result) {
                Buffer.BlockCopy(from, 0, result.buffer, 0, from.Length);
            }

            return(result);
        }
Exemple #3
0
        /// <summary>
        /// 克隆数组
        /// </summary>
        /// <typeparam name="T">类型</typeparam>
        /// <param name="from">原数组</param>
        /// <param name="to">目标数组</param>
        /// <param name="size">元素大小</param>
        /// <returns>数组</returns>
        public static PinnedBuffer <T> Clone <T>(PinnedBuffer <T> from, PinnedBuffer <T> to, int size)
        {
            if (from == null)
            {
                return(to);
            }

            var result = to;

            if ((to == null) || (to.Length != from.Length))
            {
                result = PinnedBuffer <T> .Alloc(from.Length);

                result.width  = from.width;
                result.height = from.height;
            }

            lock (result) {
                Buffer.BlockCopy(from.buffer, 0, result.buffer, 0, from.Length * size);
            }

            return(result);
        }