Exemple #1
0
        public void Fired(IOProxy proxy, List <AbstractProxyEventData> eventData)
        {
            SlamMapEventData    slamMapEvent    = (SlamMapEventData)eventData.FirstOrDefault(c => c is SlamMapEventData);
            SlamStatusEventData slamStatusEvent = (SlamStatusEventData)eventData.FirstOrDefault(c => c is SlamStatusEventData);

            if (slamMapEvent != null)
            {
                if (slamMapEvent.PublishType == SlamPublishType.Frame)
                {
                    SlamModel3D.AddNewFrame(slamMapEvent.Frame);
                    _FPSCounter.CountFrame();
                }
                else if (slamMapEvent.PublishType == SlamPublishType.KeyframeWithPoints)
                {
                    SlamModel3D.AddNewKeyFrame(slamMapEvent.KeyFrame);
                }
                else if (slamMapEvent.PublishType == SlamPublishType.Reset)
                {
                    SlamModel3D.Reset();
                }
            }
            if (slamStatusEvent != null)
            {
                Parent.SyncContext.Post(o =>
                {
                    Status = slamStatusEvent.Status;
                }, null);
            }
        }
 /// <summary>
 /// WorldSpaceの内容を描画します.
 /// </summary>
 public void Render()
 {
     if (WorldSpace == null || WorldSpace.IsDisposed)
     {
         return;
     }
     Context.SetRenderScreen(this);
     Context.ClearScreenTarget(BackgroundColor);
     Context.Timer.TickUpdater();
     fpsCounter.CountFrame();
     MoveCameraByCameraMotionProvider();
     WorldSpace.DrawAllResources(HitChecker);
     Context.DeviceManager.Context.Flush();
 }
Exemple #3
0
        public void Fired(IOProxy proxy, List <AbstractProxyEventData> eventData)
        {
            CameraEventData cameraEventData = (CameraEventData)eventData.FirstOrDefault(c => c is CameraEventData);

            if (cameraEventData != null)
            {
                Task.Factory.StartNew(() =>
                {
                    Mat mat = cameraEventData.Image;

                    bool undistort = false;

                    Parent.SyncContext.Send(o =>
                    {
                        undistort = Undistort;

                        if (GammaCorretion)
                        {
                            Mat result = new Mat(ImageWidth, ImageHeight, DepthType.Cv32F, 1);
                            int i      = 0;
                            Mat lut    = new Mat(1, 256, DepthType.Cv32F, 1);
                            foreach (double val in Parent.SettingContainer.Settings.CalibrationSettings.PhotometricCalibrationSettings.ResponseValues)
                            {
                                lut.SetValue(0, i++, (byte)val);
                            }
                            CvInvoke.LUT(mat, lut, result);
                            result.ConvertTo(mat, DepthType.Cv8U);
                        }

                        if (VignetteCorretion)
                        {
                            Mat invVignette = new Mat(ImageWidth, ImageHeight, DepthType.Cv32F, 1);
                            Mat result      = new Mat(ImageWidth, ImageHeight, DepthType.Cv32F, 1);
                            CvInvoke.Divide(Mat.Ones(ImageWidth, ImageHeight, DepthType.Cv32F, 1), Parent.CalibrationViewModel.PhotometricCalibrationViewModel.Vignette.CvImage, invVignette, 255, DepthType.Cv32F);
                            CvInvoke.Multiply(mat, invVignette, result, 1, DepthType.Cv32F);
                            result.ConvertTo(mat, DepthType.Cv8U);
                        }
                    }
                                            , null);

                    if (undistort)
                    {
                        Mat matUndist = new Mat(ImageWidth, ImageHeight, DepthType.Cv8U, 1);

                        if (FishEyeCalibration)
                        {
                            Mat map1 = new Mat();
                            Mat map2 = new Mat();
                            Fisheye.InitUndistorRectifyMap(OrginalCameraMatrix, DistortionCoefficients, Mat.Eye(3, 3, DepthType.Cv64F, 1), CenteredCameraMatrix, new System.Drawing.Size(ImageWidth, ImageHeight), DepthType.Cv32F, map1, map2);
                            CvInvoke.Remap(mat, matUndist, map1, map2, Inter.Linear, BorderType.Constant);
                        }
                        else
                        {
                            CvInvoke.Undistort(mat, matUndist, CenteredCameraMatrix, DistortionCoefficients);
                        }
                        mat = matUndist;
                    }

                    _FPSCounter.CountFrame();
                    Parent.SyncContext.Post(o =>
                    {
                        ExposureTime = (eventData[0] as CameraEventData).ExposureTime;
                        Image        = new CvImageContainer();

                        Image.CvImage = mat;
                    }
                                            , null);
                });
            }
        }