private void UpdateImageContainer()
        {
            CameraDeviceImpl cameraDeviceImpl = (CameraDeviceImpl)CameraDevice.Instance;

            if (this.mNumImageHeaders != cameraDeviceImpl.GetAllImages().Count || (cameraDeviceImpl.GetAllImages().Count > 0 && this.mImageHeaderData == IntPtr.Zero))
            {
                this.mNumImageHeaders = cameraDeviceImpl.GetAllImages().Count;
                Marshal.FreeHGlobal(this.mImageHeaderData);
                this.mImageHeaderData = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(VuforiaManagerImpl.ImageHeaderData)) * this.mNumImageHeaders);
            }
            int num = 0;

            using (Dictionary <Image.PIXEL_FORMAT, Image> .ValueCollection.Enumerator enumerator = cameraDeviceImpl.GetAllImages().Values.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    ImageImpl imageImpl = (ImageImpl)enumerator.Current;
                    IntPtr    ptr       = new IntPtr(this.mImageHeaderData.ToInt64() + (long)(num * Marshal.SizeOf(typeof(VuforiaManagerImpl.ImageHeaderData))));
                    Marshal.StructureToPtr(new VuforiaManagerImpl.ImageHeaderData
                    {
                        width        = imageImpl.Width,
                        height       = imageImpl.Height,
                        stride       = imageImpl.Stride,
                        bufferWidth  = imageImpl.BufferWidth,
                        bufferHeight = imageImpl.BufferHeight,
                        format       = (int)imageImpl.PixelFormat,
                        reallocate   = 0,
                        updated      = 0,
                        data         = imageImpl.UnmanagedData
                    }, ptr, false);
                    num++;
                }
            }
        }
Beispiel #2
0
        public bool CheckForSurfaceChanges(out ScreenOrientation orientation)
        {
            int pixelHeightInt = this.mPrimaryCamera.GetPixelHeightInt();
            int pixelWidthInt  = this.mPrimaryCamera.GetPixelWidthInt();
            ScreenOrientation surfaceOrientation = SurfaceUtilities.GetSurfaceOrientation();
            bool result = false;

            if (pixelHeightInt != this.mCameraViewPortHeight || pixelWidthInt != this.mCameraViewPortWidth || this.mProjectionOrientation != surfaceOrientation)
            {
                this.mCameraViewPortHeight  = pixelHeightInt;
                this.mCameraViewPortWidth   = pixelWidthInt;
                this.mProjectionOrientation = surfaceOrientation;
                SurfaceUtilities.OnSurfaceChanged(this.mCameraViewPortWidth, this.mCameraViewPortHeight);
            }
            CameraDeviceImpl cameraDeviceImpl = (CameraDeviceImpl)CameraDevice.Instance;

            if (cameraDeviceImpl.CameraReady && (VuforiaUnity.IsRendererDirty() || this.CameraParameterChanged()))
            {
                this.ConfigureVideoBackground();
                cameraDeviceImpl.ResetDirtyFlag();
                result = true;
                this.mCameraParameterChanged = false;
            }
            orientation = this.mProjectionOrientation;
            return(result);
        }
Beispiel #3
0
        public static bool IsRendererDirty()
        {
            CameraDeviceImpl arg_16_0 = (CameraDeviceImpl)CameraDevice.Instance;
            bool             flag     = VuforiaUnityImpl.mRendererDirty;

            VuforiaUnityImpl.mRendererDirty = false;
            return(arg_16_0.IsDirty() | flag);
        }
        private void InjectCameraFrame()
        {
            CameraDeviceImpl cameraDeviceImpl = (CameraDeviceImpl)CameraDevice.Instance;
            GCHandle         gCHandle         = GCHandle.Alloc(cameraDeviceImpl.WebCam.GetPixels32AndBufferFrame(), GCHandleType.Pinned);
            IntPtr           pixels           = gCHandle.AddrOfPinnedObject();
            int actualWidth  = cameraDeviceImpl.WebCam.ActualWidth;
            int actualHeight = cameraDeviceImpl.WebCam.ActualHeight;

            VuforiaWrapper.Instance.QcarAddCameraFrame(pixels, actualWidth, actualHeight, 16, 4 * actualWidth, this.mInjectedFrameIdx, cameraDeviceImpl.WebCam.FlipHorizontally ? 1 : 0);
            this.mInjectedFrameIdx++;
            pixels = IntPtr.Zero;
            gCHandle.Free();
        }
Beispiel #5
0
        public bool CheckForSurfaceChanges(out ScreenOrientation orientation)
        {
            ScreenOrientation surfaceOrientation = SurfaceUtilities.GetSurfaceOrientation();
            bool result = false;

            if (Screen.height != this.mScreenHeight || Screen.width != this.mScreenWidth || this.mProjectionOrientation != surfaceOrientation)
            {
                this.mScreenWidth           = Screen.width;
                this.mScreenHeight          = Screen.height;
                this.mProjectionOrientation = surfaceOrientation;
                SurfaceUtilities.OnSurfaceChanged(this.mScreenWidth, this.mScreenHeight);
            }
            CameraDeviceImpl cameraDeviceImpl = (CameraDeviceImpl)CameraDevice.Instance;

            if (cameraDeviceImpl.CameraReady && (VuforiaUnity.IsRendererDirty() || this.CameraParameterChanged()))
            {
                this.ConfigureVideoBackground();
                cameraDeviceImpl.ResetDirtyFlag();
                result = true;
                this.mCameraParameterChanged = false;
            }
            orientation = this.mProjectionOrientation;
            if (Math.Abs(this.mSecondaryCamera.fieldOfView - this.mPrimaryCamera.fieldOfView) > 0.01f)
            {
                Debug.LogWarning("Field of view values of left and right camera are not identical. This is currently not supported by Vuforia!");
            }
            if (Math.Abs(this.mSecondaryCamera.nearClipPlane - this.mPrimaryCamera.nearClipPlane) > 0.01f || Math.Abs(this.mSecondaryCamera.farClipPlane - this.mPrimaryCamera.farClipPlane) > 0.01f)
            {
                Debug.LogWarning("Clip plane positions of left and right camera are not identical. This is currently not supported by Vuforia!");
            }
            if (this.mNeedToCheckStereo && this.mEyewearDevice.IsDualDisplay() && !this.mEyewearDevice.IsDisplayExtended())
            {
                if (this.mSecondaryCamera != null)
                {
                    Debug.Log("Detecting stereo camera setup, setting stereo mode.");
                    this.mEyewearDevice.SetDisplayExtended(true);
                }
                else
                {
                    Debug.LogWarning("Device is a stereo capable eyewear device, but only one camera has been set up.");
                }
                this.mNeedToCheckStereo = false;
            }
            return(result);
        }
        public virtual bool CheckForSurfaceChanges(out ScreenOrientation orientation)
        {
            ScreenOrientation surfaceOrientation = SurfaceUtilities.GetSurfaceOrientation();
            bool result = false;

            if (Screen.height != this.mScreenHeight || Screen.width != this.mScreenWidth || this.mProjectionOrientation != surfaceOrientation)
            {
                this.mScreenWidth           = Screen.width;
                this.mScreenHeight          = Screen.height;
                this.mProjectionOrientation = surfaceOrientation;
                SurfaceUtilities.OnSurfaceChanged(this.mScreenWidth, this.mScreenHeight);
            }
            CameraDeviceImpl cameraDeviceImpl = (CameraDeviceImpl)CameraDevice.Instance;

            if (cameraDeviceImpl.CameraReady && (VuforiaUnity.IsRendererDirty() || this.CameraParameterChanged()))
            {
                this.ConfigureVideoBackground();
                cameraDeviceImpl.ResetDirtyFlag();
                result = true;
                this.mCameraParameterChanged = false;
            }
            orientation = this.mProjectionOrientation;
            return(result);
        }