private void UpdateCameraFrame()
        {
            int num = 0;

            using (Dictionary <Image.PIXEL_FORMAT, Image> .ValueCollection.Enumerator enumerator = ((CameraDeviceImpl)CameraDevice.Instance).GetAllImages().Values.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    ImageImpl imageImpl = (ImageImpl)enumerator.Current;
                    VuforiaManagerImpl.ImageHeaderData imageHeaderData = (VuforiaManagerImpl.ImageHeaderData)Marshal.PtrToStructure(new IntPtr(this.mImageHeaderData.ToInt64() + (long)(num * Marshal.SizeOf(typeof(VuforiaManagerImpl.ImageHeaderData)))), typeof(VuforiaManagerImpl.ImageHeaderData));
                    imageImpl.Width        = imageHeaderData.width;
                    imageImpl.Height       = imageHeaderData.height;
                    imageImpl.Stride       = imageHeaderData.stride;
                    imageImpl.BufferWidth  = imageHeaderData.bufferWidth;
                    imageImpl.BufferHeight = imageHeaderData.bufferHeight;
                    imageImpl.PixelFormat  = (Image.PIXEL_FORMAT)imageHeaderData.format;
                    if (imageHeaderData.reallocate == 1)
                    {
                        imageImpl.Pixels = new byte[VuforiaWrapper.Instance.QcarGetBufferSize(imageImpl.BufferWidth, imageImpl.BufferHeight, (int)imageImpl.PixelFormat)];
                        Marshal.FreeHGlobal(imageImpl.UnmanagedData);
                        imageImpl.UnmanagedData = Marshal.AllocHGlobal(VuforiaWrapper.Instance.QcarGetBufferSize(imageImpl.BufferWidth, imageImpl.BufferHeight, (int)imageImpl.PixelFormat));
                    }
                    else if (imageHeaderData.updated == 1)
                    {
                        imageImpl.CopyPixelsFromUnmanagedBuffer();
                    }
                    num++;
                }
            }
        }
        private void CreateInstanceImage()
        {
            this.mInstanceImageHeader        = default(VuforiaManagerImpl.ImageHeaderData);
            this.mInstanceImageHeader.width  = 0;
            this.mInstanceImageHeader.height = 0;
            this.mInstanceImageHeader.format = 16;
            if (this.CallNativeGetInstanceImage() == 0)
            {
                Debug.LogWarning("Not able to create VuMark instance image.");
                return;
            }
            this.mInstanceImage = new ImageImpl();
            ImageImpl imageImpl = (ImageImpl)this.mInstanceImage;

            VuMarkTargetImpl.SetImageValues(this.mInstanceImageHeader, imageImpl);
            VuMarkTargetImpl.AllocateImage(imageImpl);
            this.mInstanceImageHeader.data = imageImpl.UnmanagedData;
            if (this.CallNativeGetInstanceImage() == 0)
            {
                Debug.LogWarning("Not able to create VuMark instance image.");
                return;
            }
            imageImpl.CopyPixelsFromUnmanagedBuffer();
            this.mInstanceImage = imageImpl;
        }
Beispiel #3
0
 private void InitImageHeader()
 {
     this.mLetterImageHeader        = default(VuforiaManagerImpl.ImageHeaderData);
     this.mLetterImageHeader.width  = (this.mLetterImageHeader.bufferWidth = (int)(this.Size.x + 1f));
     this.mLetterImageHeader.height = (this.mLetterImageHeader.bufferHeight = (int)(this.Size.y + 1f));
     this.mLetterImageHeader.format = 4;
     this.mLetterMask = new ImageImpl();
 }
 private static void SetImageValues(VuforiaManagerImpl.ImageHeaderData imageHeader, ImageImpl image)
 {
     image.Width        = imageHeader.width;
     image.Height       = imageHeader.height;
     image.Stride       = imageHeader.stride;
     image.BufferWidth  = imageHeader.bufferWidth;
     image.BufferHeight = imageHeader.bufferHeight;
     image.PixelFormat  = (Image.PIXEL_FORMAT)imageHeader.format;
 }
        private int CallNativeGetInstanceImage()
        {
            IntPtr intPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(VuforiaManagerImpl.ImageHeaderData)));

            Marshal.StructureToPtr(this.mInstanceImageHeader, intPtr, false);
            int arg_59_0 = VuforiaWrapper.Instance.VuMarkTargetGetInstanceImage(this.ID, intPtr);

            this.mInstanceImageHeader = (VuforiaManagerImpl.ImageHeaderData)Marshal.PtrToStructure(intPtr, typeof(VuforiaManagerImpl.ImageHeaderData));
            Marshal.FreeHGlobal(intPtr);
            return(arg_59_0);
        }
Beispiel #6
0
        private void CreateLetterMask()
        {
            this.InitImageHeader();
            ImageImpl imageImpl = (ImageImpl)this.mLetterMask;

            WordImpl.SetImageValues(this.mLetterImageHeader, imageImpl);
            WordImpl.AllocateImage(imageImpl);
            this.mLetterImageHeader.data = imageImpl.UnmanagedData;
            IntPtr intPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(VuforiaManagerImpl.ImageHeaderData)));

            Marshal.StructureToPtr(this.mLetterImageHeader, intPtr, false);
            VuforiaWrapper.Instance.WordGetLetterMask(base.ID, intPtr);
            this.mLetterImageHeader = (VuforiaManagerImpl.ImageHeaderData)Marshal.PtrToStructure(intPtr, typeof(VuforiaManagerImpl.ImageHeaderData));
            if (this.mLetterImageHeader.reallocate == 1)
            {
                Debug.LogWarning("image wasn't allocated correctly");
                return;
            }
            imageImpl.CopyPixelsFromUnmanagedBuffer();
            this.mLetterMask = imageImpl;
            Marshal.FreeHGlobal(intPtr);
        }