コード例 #1
0
        public TutorialDataStep()
        {
            ArrowStartPosition = new FloatVector3();
            ArrowEndPosition   = new FloatVector3();

            JaneText           = string.Empty;
            SoundName          = string.Empty;
            EmotionDescription = string.Empty;
            AvailableCard      = string.Empty;

            DelayToPlaySound = 0f;

            IsFocusing                       = false;
            IsArrowEnabled                   = false;
            CanMoveToNextStepByClick         = false;
            CanMoveToNextStepByClickInPaused = false;
            ShouldStopTurn                   = false;
            IsShowNextButtonFocusing         = false;
            IsShowNextButton                 = false;
            IsShowQuestion                   = false;
            CanProceedWithEndStepManually    = false;
            HasDelayToPlaySound              = false;
            CanUseBoardSkill                 = false;
            CanClickEndTurn                  = false;
            IsManuallyHideBubble             = false;
            IsPauseTutorial                  = false;
            CanHandleInput                   = false;
            IsLaunchAIBrain                  = false;
            UnitsCanAttack                   = false;
            BoardArrowCantUsableOnUnit       = false;
            BoardArrowCanUsableOnPlayer      = false;
        }
コード例 #2
0
        public string GetStatusUpdate()
        {
            FloatVector3 cp = currentPTZPosition.Copy();

            cp.Y = cp.Y / (float)(panoramaVerticalDegrees / 90.0);
            return("newpos " + cp.X + " " + cp.Y + " " + cp.Z);
        }
コード例 #3
0
ファイル: HikvisionPTZ.cs プロジェクト: zyh329/cameraproxy
        private IntVector3 PercentagePosToCameraPos(FloatVector3 percentagePos)
        {
            IntVector3 camPos = new IntVector3();

            camPos.X = Util.Modulus(Util.PercentageToRangeValueInt(percentagePos.X, 0, 3600) + (this.absoluteXOffset * 10), 3600);
            camPos.Y = Util.PercentageToRangeValueInt(percentagePos.Y, cs.ptz_tiltlimit_high, cs.ptz_tiltlimit_low);
            camPos.Z = Util.PercentageToRangeValueInt(percentagePos.Z, 10, cs.ptz_magnification * 10);

            return(camPos);
        }
コード例 #4
0
ファイル: HikvisionPTZ.cs プロジェクト: zyh329/cameraproxy
        private FloatVector3 CameraPosToPercentagePos(IntVector3 camPos)
        {
            FloatVector3 percentagePos = new FloatVector3();

            percentagePos.X = (float)Util.RangeValueToPercentage(Util.Modulus(camPos.X - (this.absoluteXOffset * 10), 3600), 0, 3600);
            percentagePos.Y = (float)Util.RangeValueToPercentage(camPos.Y, cs.ptz_tiltlimit_high, cs.ptz_tiltlimit_low);
            percentagePos.Z = (float)Util.RangeValueToPercentage(camPos.Z, 10, cs.ptz_magnification * 10);

            return(percentagePos);
        }
コード例 #5
0
ファイル: HikvisionPTZ.cs プロジェクト: zyh329/cameraproxy
        public string GetStatusUpdate()
        {
            FloatVector3 cp      = currentPTZPosition.Copy();
            double       maxTilt = cs.ptz_tiltlimit_low - cs.ptz_tiltlimit_high;

            if (maxTilt > 0)
            {
                cp.Y = cp.Y / (float)((panoramaVerticalDegrees * 10) / maxTilt);
            }
            return("newpos " + cp.X + " " + cp.Y + " " + cp.Z);
        }
コード例 #6
0
        private IntVector3 PercentagePosToCameraPos(FloatVector3 percentagePos)
        {
            IntVector3 camPos = new IntVector3();

            camPos.X = Util.Modulus(Util.PercentageToRangeValueInt(percentagePos.X, 3600, 0) + (this.absoluteXOffset * 10), 3600);
            camPos.Y = Util.PercentageToRangeValueInt(percentagePos.Y, 0, 900);
            double magnification = Util.PercentageToRangeValueDouble(percentagePos.Z, 1, cs.ptz_magnification);

            camPos.Z = Util.DahuaZoomCalc(magnification, cs.ptz_magnification);

            return(camPos);
        }
コード例 #7
0
        private FloatVector3 CameraPosToPercentagePos(IntVector3 camPos)
        {
            FloatVector3 percentagePos = new FloatVector3();

            percentagePos.X = (float)Util.RangeValueToPercentage(Util.Modulus(camPos.X - (this.absoluteXOffset * 10), 3600), 3600, 0);
            percentagePos.Y = (float)Util.RangeValueToPercentage(camPos.Y, 0, 900);
            double approxMagnification = Util.DahuaMagnificationCalc(camPos.Z, cs.ptz_magnification);

            percentagePos.Z = (float)Util.RangeValueToPercentage(approxMagnification, 1, cs.ptz_magnification);

            return(percentagePos);
        }
コード例 #8
0
        /// <summary>
        /// Positions the camera to center on the specified location, with the specified zoom change.
        /// </summary>
        /// <param name="x">Number between 0 and 1 indicating the X position on the camera view that is the center of the user's drawn rectangle.</param>
        /// <param name="y">Number between 0 and 1 indicating the Y position on the camera view that is the center of the user's drawn rectangle.</param>
        /// <param name="z">Number between -1 and 1 indicating the size of the rectangle drawn relative to the size of the camera.  Negative values indicate the zoom should be out, positive values indicate the zoom should be in.</param>
        public void Position3D(float x, float y, float z)
        {
            x -= 0.5f;
            y -= 0.5f;

            FloatVector3 percentagePosition = currentPTZPosition.Copy();
            IntVector3   camPosition        = PercentagePosToCameraPos(percentagePosition);

            int currentMagnification = Util.PercentageToRangeValueInt(percentagePosition.Z, 1, cs.ptz_magnification);

            double hfov = cs.ptz_fov_horizontal / currentMagnification;
            double vfov = cs.ptz_fov_vertical / currentMagnification;

            double offsetDegreesX = hfov * x;
            double offsetDegreesY = vfov * y;

            IntVector3 newCamPosition = new IntVector3();

            newCamPosition.X = camPosition.X + (int)Math.Round(offsetDegreesX * -10);
            newCamPosition.Y = camPosition.Y + (int)Math.Round(offsetDegreesY * 10);

            // Calculate new zoom position
            if (z == 0)
            {
                newCamPosition.Z = camPosition.Z;
            }
            else
            {
                double offsetMultiplierZ;
                if (z > 0)
                {
                    offsetMultiplierZ = 1.0 / z;
                }
                else
                {
                    offsetMultiplierZ = -z;
                }
                double newMagnification = currentMagnification * offsetMultiplierZ;
                if (newMagnification < 1)
                {
                    newMagnification = 1;
                }
                else if (newMagnification > cs.ptz_magnification)
                {
                    newMagnification = cs.ptz_magnification;
                }
                double newPercentMag = Util.DahuaZoomCalc(newMagnification, cs.ptz_magnification);
                newCamPosition.Z = (int)Math.Round(newPercentMag);
            }

            PositionABS_CamPosition(newCamPosition);
        }
コード例 #9
0
        public void PositionABS_CamPosition(IntVector3 camPosition)
        {
            camPosition.X = Util.Modulus(camPosition.X, 3600);

            camPosition.Y = Util.Clamp(camPosition.Y, 0, 900);

            camPosition.Z = Util.Clamp(camPosition.Z, 1, 128);

            FloatVector3 percentPos = CameraPosToPercentagePos(camPosition);

            currentPTZPosition.X = percentPos.X;
            currentPTZPosition.Y = percentPos.Y;
            currentPTZPosition.Z = percentPos.Z;

            DoAbsPos(camPosition.X, camPosition.Y, camPosition.Z);
        }
コード例 #10
0
ファイル: HikvisionPTZ.cs プロジェクト: zyh329/cameraproxy
        public void PositionABS_CamPosition(IntVector3 camPosition)
        {
            camPosition.X = Util.Modulus(camPosition.X, 3600);

            camPosition.Y = Util.Clamp(camPosition.Y, cs.ptz_tiltlimit_high, cs.ptz_tiltlimit_low);

            camPosition.Z = Util.Clamp(camPosition.Z, 10, (int)(cs.ptz_magnification * 10));

            FloatVector3 percentPos = CameraPosToPercentagePos(camPosition);

            currentPTZPosition.X = percentPos.X;
            currentPTZPosition.Y = percentPos.Y;
            currentPTZPosition.Z = percentPos.Z;

            DoAbsPos(camPosition.X, camPosition.Y, camPosition.Z);
        }
コード例 #11
0
ファイル: HikvisionPTZ.cs プロジェクト: zyh329/cameraproxy
        /// <summary>
        /// Position the camera to center upon the specified point, relative to the current camera position.  Optionally may zoom the camera in or out.
        /// </summary>
        /// <param name="x">The percentage [0.0 ~ 1.0] that specifies the horizontal position, where 0 is the left side of the view.</param>
        /// <param name="y">The percentage [0.0 ~ 1.0] that specifies the vertical position, where 0 is the top of the view.</param>
        /// <param name="z">The percentage [-1.0 ~ 1.0] that specifies the size of the drawn box.  0 would indicate no box was drawn, -1 would indicate the largest possible zoom-out box was drawn, and 1 would indicate the largest possible zoom-in box was drawn.</param>
        public void Position3D(float x, float y, float z)
        {
            // Calculate new X/Y position
            x -= 0.5f;
            y -= 0.5f;

            FloatVector3 percentagePosition = GetCurrentPosition();
            IntVector3   camPosition        = PercentagePosToCameraPos(percentagePosition);

            double zoomMultiplier = camPosition.Z / 10.0;
            double hfov           = cs.ptz_fov_horizontal / zoomMultiplier;
            double vfov           = cs.ptz_fov_vertical / zoomMultiplier;

            double offsetDegreesX = hfov * x;
            double offsetDegreesY = vfov * y;

            IntVector3 newCamPosition = new IntVector3();

            newCamPosition.X = camPosition.X + (int)Math.Round(offsetDegreesX * 10);
            newCamPosition.Y = camPosition.Y + (int)Math.Round(offsetDegreesY * 10);

            // Calculate new zoom position
            if (z == 0)
            {
                newCamPosition.Z = camPosition.Z;
            }
            else
            {
                int zoomOffset = 10;
                int zoomRange  = (int)(cs.ptz_magnification * 10) - zoomOffset;
                if (z > 0)
                {
                    double offsetMultiplierZ = 1.0 / z;
                    newCamPosition.Z = (int)Math.Round(camPosition.Z * offsetMultiplierZ);
                }
                else
                {
                    //double offsetMultiplierZ = 1.0 / z;
                    newCamPosition.Z = (int)Math.Round(camPosition.Z * -z);
                }
            }

            PositionABS_CamPosition(newCamPosition);
        }
コード例 #12
0
        public void GeneratePseudoPanorama(bool overlap, bool fullSizeImages = false)
        {
            IPCameraBase cam           = MJpegServer.cm.GetCamera(cs.id);
            bool         isFirstTime   = true;
            double       hfov          = cs.ptz_fov_horizontal == 0 ? 60 : cs.ptz_fov_horizontal;
            double       vfov          = cs.ptz_fov_vertical == 0 ? 34 : cs.ptz_fov_vertical;
            int          numImagesWide = overlap ? (int)Math.Round((360 / hfov) * 2) : 6;
            int          numImagesHigh = overlap ? (int)Math.Round(((cs.ptz_tiltlimit_low - cs.ptz_tiltlimit_high) / (vfov * 10)) * 2) : 3;

            for (int j = 0; j < numImagesHigh; j++)
            {
                for (int i = 0; i < numImagesWide; i++)
                {
                    FloatVector3 percentPos = new FloatVector3((float)i / (float)numImagesWide, (float)j / (float)numImagesHigh, 0);
                    PositionABS_PercentPosition(percentPos);
                    Thread.Sleep(isFirstTime ? 7000 : 4500);
                    isFirstTime = false;
                    try
                    {
                        byte[] input = cam.LastFrame;
                        if (input.Length > 0)
                        {
                            if (!fullSizeImages)
                            {
                                input = ImageConverter.ConvertImage(input, maxWidth: 240, maxHeight: 160);
                            }
                            FileInfo file = new FileInfo(CameraProxyGlobals.ThumbsDirectoryBase + cam.cameraSpec.id.ToLower() + (i + (j * numImagesWide)) + ".jpg");
                            Util.EnsureDirectoryExists(file.Directory.FullName);
                            File.WriteAllBytes(file.FullName, input);
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Debug(ex);
                    }
                }
            }
        }
コード例 #13
0
ファイル: HikvisionPTZ.cs プロジェクト: zyh329/cameraproxy
        public FloatVector3 GetCurrentPosition()
        {
            string posResponse = DoXmlPTZAction("status", null);

            IntVector3 camPos = new IntVector3();
            Match      m      = rxGetElevation.Match(posResponse);

            if (!m.Success || !int.TryParse(m.Groups[1].Value, out camPos.Y))
            {
                camPos.Y = 0;
            }

            m = rxGetAzimuth.Match(posResponse);
            if (!m.Success || !int.TryParse(m.Groups[1].Value, out camPos.X))
            {
                camPos.X = 0;
            }

            m = rxGetAbsoluteZoom.Match(posResponse);
            if (!m.Success || !int.TryParse(m.Groups[1].Value, out camPos.Z))
            {
                camPos.Z = 0;
            }

            if (camPos.Z <= 0)
            {
                camPos.Z = 10;
            }

            FloatVector3 percentagePos = CameraPosToPercentagePos(camPos);

            currentPTZPosition.X = percentagePos.X;
            currentPTZPosition.Y = percentagePos.Y;
            currentPTZPosition.Z = percentagePos.Z;

            return(percentagePos);
        }
コード例 #14
0
 public GridSettings(FloatVector3 startPos, FloatVector2 cellSpacing)
 {
     this.startPos    = startPos;
     this.cellSpacing = cellSpacing;
 }
コード例 #15
0
        public void PositionABS_PercentPosition(FloatVector3 percentagePosition)
        {
            IntVector3 camPosition = PercentagePosToCameraPos(percentagePosition);

            PositionABS_CamPosition(camPosition);
        }
コード例 #16
0
        public void ptzWorkerLoop(object arg)
        {
            bool[] abortFlag = (bool[])arg;
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(Thread.CurrentThread.Name + " Started");
            Console.ResetColor();
            try
            {
                DoLogin();
                while (!abortFlag[0])
                {
                    try
                    {
                        if (generatePanoramaSourceFrames)
                        {
                            generatePanoramaSourceFrames = false;
                            GeneratePseudoPanorama(true, true);
                            SetNewIdleTime();
                        }
                        if (generatePseudoPanorama)
                        {
                            generatePseudoPanorama = false;
                            GeneratePseudoPanorama(false, false);
                            SetNewIdleTime();
                        }
                        FloatVector3 desiredAbsPos = (FloatVector3)Interlocked.Exchange(ref desiredPTZPosition, null);
                        if (desiredAbsPos != null)
                        {
                            SetNewIdleTime();

                            desiredAbsPos.Y = Util.Clamp(desiredAbsPos.Y, 0, 1);
                            desiredAbsPos.Y = desiredAbsPos.Y * (float)(panoramaVerticalDegrees / 90.0);
                            desiredAbsPos.Z = Util.Clamp(desiredAbsPos.Z, 0, 1);

                            PositionABS_PercentPosition(desiredAbsPos);
                            BroadcastStatusUpdate();
                            Thread.Sleep(1000);

                            //if ("grapefruit" == false.ToString().ToLower())
                            //{
                            //    GeneratePseudoPanorama(14, 6, true);
                            //}
                        }

                        double[] desiredZoom = (double[])Interlocked.Exchange(ref desiredZoomPosition, null);
                        if (desiredZoom != null)
                        {
                            SetNewIdleTime();
                            FloatVector3 percentPos = currentPTZPosition.Copy();
                            float        newZ       = (float)Util.Clamp(desiredZoom[0], 0, 1);
                            float        diffZ      = Math.Abs(newZ - percentPos.Z);
                            percentPos.Z = newZ;
                            PositionABS_PercentPosition(percentPos);
                            BroadcastStatusUpdate();
                            Thread.Sleep((int)(diffZ * 1000));
                        }

                        Pos3d desired3d = (Pos3d)Interlocked.Exchange(ref desired3dPosition, null);
                        if (desired3d != null)
                        {
                            SetNewIdleTime();

                            float x   = desired3d.X;
                            float y   = desired3d.Y;
                            float w   = desired3d.W;
                            float h   = desired3d.H;
                            bool  zIn = desired3d.zoomIn;
                            float z   = Math.Max(w, h);
                            if (!zIn)
                            {
                                z *= -1;
                            }
                            this.Position3D(x, y, z);
                            Broadcast3dPosition(x, y, w, h, zIn);
                            BroadcastStatusUpdate();
                            Thread.Sleep(500);
                        }
                        Thread.Sleep(10);
                        if (DateTime.Now > willBeIdleAt)
                        {
                            willBeIdleAt    = DateTime.MaxValue;
                            desiredAbsPos   = new FloatVector3((float)cs.ptz_idleresetpositionX, (float)cs.ptz_idleresetpositionY, (float)cs.ptz_idleresetpositionZ);
                            desiredAbsPos.Y = Util.Clamp(desiredAbsPos.Y, 0, 1);
                            desiredAbsPos.Z = Util.Clamp(desiredAbsPos.Z, 0, 1);

                            PositionABS_PercentPosition(desiredAbsPos);
                            BroadcastStatusUpdate();
                            Thread.Sleep(1000);
                        }
                    }
                    catch (ThreadAbortException ex)
                    {
                        throw ex;
                    }
                    catch (Exception ex)
                    {
                        Logger.Debug(ex);
                    }
                }
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(Thread.CurrentThread.Name + " Stopping");
                Console.ResetColor();
            }
            catch (ThreadAbortException)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(Thread.CurrentThread.Name + " Aborted");
                Console.ResetColor();
            }
            catch (Exception ex)
            {
                Logger.Debug(ex);
            }
            ptzWorkerThread         = null;
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine(Thread.CurrentThread.Name + " Exiting");
            Console.ResetColor();
        }
コード例 #17
0
        private static float[][] CreateHillShadeT <T>(this IRaster raster, Func <int, int, T> getValue, IShadedRelief shadedRelief, ProgressMeter progressMeter)
            where T : IEquatable <T>, IComparable <T>
        {
            if (!raster.IsInRam)
            {
                return(null);
            }

            int          numCols          = raster.NumColumns;
            int          numRows          = raster.NumRows;
            var          noData           = Convert.ToSingle(raster.NoDataValue);
            float        extrusion        = shadedRelief.Extrusion;
            float        elevationFactor  = shadedRelief.ElevationFactor;
            float        lightIntensity   = shadedRelief.LightIntensity;
            float        ambientIntensity = shadedRelief.AmbientIntensity;
            FloatVector3 lightDirection   = shadedRelief.GetLightDirection();

            float[] aff = new float[6]; // affine coefficients converted to float format
            for (int i = 0; i < 6; i++)
            {
                aff[i] = Convert.ToSingle(raster.Bounds.AffineCoefficients[i]);
            }

            float[][] hillshade = new float[numRows][];
            if (progressMeter != null)
            {
                progressMeter.BaseMessage = "Creating Shaded Relief";
            }
            for (int row = 0; row < numRows; row++)
            {
                hillshade[row] = new float[numCols];

                for (int col = 0; col < numCols; col++)
                {
                    // 3D position vectors of three points to create a triangle.
                    FloatVector3 v1 = new FloatVector3(0f, 0f, 0f);
                    FloatVector3 v2 = new FloatVector3(0f, 0f, 0f);
                    FloatVector3 v3 = new FloatVector3(0f, 0f, 0f);

                    float val = Convert.ToSingle(getValue(row, col));

                    // Cannot compute polygon ... make the best guess)
                    if (col >= numCols - 1 || row <= 0)
                    {
                        if (col >= numCols - 1 && row <= 0)
                        {
                            v1.Z = val;
                            v2.Z = val;
                            v3.Z = val;
                        }
                        else if (col >= numCols - 1)
                        {
                            v1.Z = Convert.ToSingle(getValue(row, col - 1));     // 3 - 2
                            v2.Z = Convert.ToSingle(getValue(row - 1, col));     // | /
                            v3.Z = Convert.ToSingle(getValue(row - 1, col - 1)); // 1   *
                        }
                        else if (row <= 0)
                        {
                            v1.Z = Convert.ToSingle(getValue(row + 1, col)); // 3* 2
                            v2.Z = Convert.ToSingle(getValue(row, col + 1)); //  | /
                            v3.Z = val;                                      //  1
                        }
                    }
                    else
                    {
                        v1.Z = val;                                          // 3 - 2
                        v2.Z = Convert.ToSingle(getValue(row - 1, col + 1)); //  | /
                        v3.Z = Convert.ToSingle(getValue(row - 1, col));     //  1*
                    }

                    // Test for no-data values and don't calculate hillshade in that case
                    if (v1.Z == noData || v2.Z == noData || v3.Z == noData)
                    {
                        hillshade[row][col] = -1; // should never be negative otherwise.
                        continue;
                    }

                    // Apply the Conversion Factor to put elevation into the same range as lat/lon
                    v1.Z = v1.Z * elevationFactor * extrusion;
                    v2.Z = v2.Z * elevationFactor * extrusion;
                    v3.Z = v3.Z * elevationFactor * extrusion;

                    // Complete the vectors using the latitude/longitude coordinates
                    v1.X = aff[0] + (aff[1] * col) + (aff[2] * row);
                    v1.Y = aff[3] + (aff[4] * col) + (aff[5] * row);

                    v2.X = aff[0] + (aff[1] * (col + 1)) + (aff[2] * (row + 1));
                    v2.Y = aff[3] + (aff[4] * (col + 1)) + (aff[5] * (row + 1));

                    v3.X = aff[0] + (aff[1] * col) + (aff[2] * (row + 1));
                    v3.Y = aff[3] + (aff[4] * col) + (aff[5] * (row + 1));

                    // We need two direction vectors in order to obtain a cross product
                    FloatVector3 dir2 = FloatVector3.Subtract(v2, v1);          // points from 1 to 2
                    FloatVector3 dir3 = FloatVector3.Subtract(v3, v1);          // points from 1 to 3

                    FloatVector3 cross = FloatVector3.CrossProduct(dir3, dir2); // right hand rule - cross direction should point into page... reflecting more if light direction is in the same direction

                    // Normalizing this vector ensures that this vector is a pure direction and won't affect the intensity
                    cross.Normalize();

                    // Hillshade now has an "intensity" modifier that should be applied to the R, G and B values of the color found at each pixel.
                    hillshade[row][col] = (FloatVector3.Dot(cross, lightDirection) * lightIntensity) + ambientIntensity;
                }

                progressMeter?.Next();
            }

            // Setting this indicates that a hillshade has been created more recently than characteristics have been changed.
            shadedRelief.HasChanged = false;
            return(hillshade);
        }
コード例 #18
0
 public void SetAbsolutePTZPosition(FloatVector3 pos)
 {
     desiredPTZPosition = pos;
 }