Example #1
0
        /// <summary>
        /// Get a new bitmap and thermography image from the camera
        /// </summary>
        public bool GetImage(out Bitmap bitmap, out float[] thermImage)
        {
            thermImage = null;
            bitmap     = null;
            SwReturnCode seekRet = SwReturnCode.BadParam;

            if (IsOpen)
            {
                byte[] displayBuffer = new byte[ImageWidth * ImageHeight * 4];
                thermImage = new float[ImageWidth * ImageHeight];
                GCHandle displayBufferHandle = GCHandle.Alloc(displayBuffer, GCHandleType.Pinned);
                GCHandle thermImageHandle    = GCHandle.Alloc(thermImage, GCHandleType.Pinned);

                // get the bitmap and thermography image. The binary image buffer is set to 0(null) because we are not going to use it
                seekRet = Seekware_GetImage(mHandle, IntPtr.Zero, thermImageHandle.AddrOfPinnedObject(), displayBufferHandle.AddrOfPinnedObject());
                if (seekRet == SwReturnCode.None)
                {
                    // Create bitmap from RGBA data
                    bitmap = new Bitmap(ImageWidth, ImageHeight, PixelFormat.Format32bppArgb);
                    if (bitmap == null)
                    {
                        return(false);
                    }
                    BitmapData bmData  = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.WriteOnly, bitmap.PixelFormat);
                    IntPtr     pNative = bmData.Scan0;
                    Marshal.Copy(displayBuffer, 0, pNative, (bitmap.Width * bitmap.Height * 4));
                    bitmap.UnlockBits(bmData);
                }

                displayBufferHandle.Free();
                thermImageHandle.Free();
            }

            return(seekRet == SwReturnCode.None);
        }
Example #2
0
        /// <summary>
        /// Gets the Seekware SDK version
        /// </summary>
        /// <returns></returns>
        public static SdkInfoStruct GetSdkInfo()
        {
            SdkInfoStruct sdkInfo       = new SdkInfoStruct();
            GCHandle      sdkInfoHandle = GCHandle.Alloc(sdkInfo, GCHandleType.Pinned);

            SwReturnCode swReturn = Seekware_GetSdkInfo(ref sdkInfo);

            sdkInfoHandle.Free();
            return(sdkInfo);
        }
Example #3
0
        /// <summary>
        /// Open the Seekware device
        /// </summary>
        /// <returns></returns>
        public bool Open()
        {
            if (IsOpen == false)
            {
                SwReturnCode retCode = Seekware_Open(mHandle);
                if (retCode == SwReturnCode.None || retCode == SwReturnCode.OpenEx)
                {
                    IsOpen = true;
                }
            }

            return(IsOpen);
        }