예제 #1
0
        void Update(float[] values, int index, Vec3f distToCamera, Vec4f lightRgba, float rotX, float rotY, float rotZ)
        {
            Mat4f.Identity(tmpMat);

            Mat4f.Translate(tmpMat, tmpMat, distToCamera.X, distToCamera.Y, distToCamera.Z);

            Mat4f.Translate(tmpMat, tmpMat, 0.5f, 0.5f, 0.5f);

            quat[0] = 0;
            quat[1] = 0;
            quat[2] = 0;
            quat[3] = 1;
            Quaterniond.RotateX(quat, quat, rotX);
            Quaterniond.RotateY(quat, quat, rotY);
            Quaterniond.RotateZ(quat, quat, rotZ);

            for (int i = 0; i < quat.Length; i++)
            {
                qf[i] = (float)quat[i];
            }
            Mat4f.Mul(tmpMat, tmpMat, Mat4f.FromQuat(rotMat, qf));

            Mat4f.Translate(tmpMat, tmpMat, -0.5f, -0.5f, -0.5f);


            values[index * 20]     = lightRgba.R;
            values[index * 20 + 1] = lightRgba.G;
            values[index * 20 + 2] = lightRgba.B;
            values[index * 20 + 3] = lightRgba.A;

            for (int i = 0; i < 16; i++)
            {
                values[index * 20 + i + 4] = tmpMat[i];
            }
        }
예제 #2
0
파일: Mat4f.cs 프로젝트: abdalmoez/amathlib
 public Mat4f()
 {
     for (int i = 0; i < Size; i++)
     {
         cols[i] = new Vec4f();
     }
 }
예제 #3
0
        public void OnRenderFrame(float deltaTime, EnumRenderStage stage)
        {
            if (Level <= 0 || TextureName == null)
            {
                return;
            }

            int voxelY = (int)GameMath.Clamp(Level, 0, fillQuadsByLevel.Length - 1);

            IRenderAPI           rpi         = api.Render;
            IClientWorldAccessor worldAccess = api.World;
            EntityPos            plrPos      = worldAccess.Player.Entity.Pos;
            Vec3d camPos = worldAccess.Player.Entity.CameraPos;

            rpi.GlDisableCullFace();
            IStandardShaderProgram prog = rpi.StandardShader;

            prog.Use();
            prog.RgbaAmbientIn = rpi.AmbientColor;
            prog.RgbaFogIn     = rpi.FogColor;
            prog.FogMinIn      = rpi.FogMin;
            prog.FogDensityIn  = rpi.FogDensity;
            prog.RgbaTint      = ColorUtil.WhiteArgbVec;
            prog.WaterWave     = 0;

            Vec4f lightrgbs = api.World.BlockAccessor.GetLightRGBs(pos.X, pos.Y, pos.Z);

            float[] glowColor = ColorUtil.GetIncandescenceColorAsColor4f((int)Temperature);
            lightrgbs.R += 2 * glowColor[0];
            lightrgbs.G += 2 * glowColor[1];
            lightrgbs.B += 2 * glowColor[2];

            prog.RgbaLightIn = lightrgbs;
            prog.RgbaBlockIn = ColorUtil.WhiteArgbVec;
            prog.ExtraGlow   = (int)GameMath.Clamp((Temperature - 500) / 4, 0, 255);

            int     texid = api.Render.GetOrLoadTexture(TextureName);
            Cuboidf rect  = fillQuadsByLevel[voxelY];

            rpi.BindTexture2d(texid);

            prog.ModelMatrix = ModelMat
                               .Identity()
                               .Translate(pos.X - camPos.X, pos.Y - camPos.Y, pos.Z - camPos.Z)
                               .Translate(1 - rect.X1 / 16f, 1.01f / 16f + Math.Max(0, Level / 16f - 0.0625f / 3), 1 - rect.Z1 / 16f)
                               .RotateX(90 * GameMath.DEG2RAD)
                               .Scale(0.5f * rect.Width / 16f, 0.5f * rect.Length / 16f, 0.5f)
                               .Translate(-1, -1, 0)
                               .Values
            ;

            prog.ViewMatrix       = rpi.CameraMatrixOriginf;
            prog.ProjectionMatrix = rpi.CurrentProjectionMatrix;

            rpi.RenderMesh(quadModelRefs[voxelY]);

            prog.Stop();

            rpi.GlEnableCullFace();
        }
예제 #4
0
        public bool TryClickChoiceOne(Mat viewportMat, RECT viewportRect)
        {
            var threshold = 0.7;
            var rectRate  = new Vec4f(0.2525f, 0.1531f, 0.4469f, 0.3134f);

            return(TryClickButton(viewportMat, viewportRect, "choice_pink_tag.png", rectRate, threshold));
        }
예제 #5
0
        public bool TryClickConfirmReceiveButton(Mat viewportMat, RECT viewportRect)
        {
            var threshold = 0.8;
            var rectRate  = new Vec4f(0.5080f, 0.8453f, 0.6978f, 0.9311f);

            return(TryClickButton(viewportMat, viewportRect, "confirm_receive_present.png", rectRate, threshold));
        }
예제 #6
0
        public bool TryClickBox(Mat viewportMat, RECT viewportRect, string imgName)
        {
            var rectRate = new Vec4f(0, 0, 1, 1);

            var clicked    = false;
            var left2right = false;

            for (int i = 0; i < 3; i++)
            {
                if (!TryClickTemplateRect(viewportMat, viewportRect, imgName, rectRate))
                {
                    break;
                }
                clicked = true;
                var matchRes     = lastMatchResult;
                var absoluteRect = matchRes.GetMatchedAbsoluteRect(viewportRect, rectRate);
                if (i == 0)
                {
                    left2right = absoluteRect.GetCenterPos().X < 1.0f * viewportRect.Width / 2;
                }
                if (left2right) //左半部分
                {
                    rectRate.Item0 = 1.0f * absoluteRect.x2 / viewportRect.Width;
                }
                else
                {
                    rectRate.Item2 = 1.0f * absoluteRect.x1 / viewportRect.Width;
                }

                Thread.Sleep(360);
            }

            return(clicked);
        }
예제 #7
0
        public bool HasSkipConfirmButton(Mat viewportMat, RECT viewportRect)
        {
            var skipConfirmButtonRectRate = new Vec4f(0.5364f, 0.6254f, 0.6674f, 0.7493f);
            var matchRes = MatchImage(viewportMat, viewportRect, skipConfirmButtonRectRate, "skip_confirm_button.png");

            return(matchRes.Success);
        }
예제 #8
0
        public bool TryClickReceiveAllButton(Mat viewportMat, RECT viewportRect)
        {
            var threshold = 0.8;
            var rectRate  = new Vec4f(0.7094f, 0.8447f, 0.9007f, 0.9303f);

            return(TryClickButton(viewportMat, viewportRect, "receive_all_present.png", rectRate, threshold));
        }
예제 #9
0
        public bool HasMenuButton(Mat viewportMat, RECT viewportRect)
        {
            var menuButtonRectRate = new Vec4f(0.8523f, 0.0058f, 0.9636f, 0.1633f);
            var matchRes           = MatchImage(viewportMat, viewportRect, menuButtonRectRate, "menu_button.png");

            return(matchRes.Success);
        }
예제 #10
0
        public bool HasSkipButton(Mat viewportMat, RECT viewportRect)
        {
            var skipButtonRectRate = new Vec4f(0.7365f, 0.0087f, 0.8748f, 0.1487f);
            var matchRes           = MatchImage(viewportMat, viewportRect, skipButtonRectRate, "skip_button.png");

            return(matchRes.Success);
        }
예제 #11
0
        public bool IsStoryMainScene(Mat viewportMat, RECT viewportRect)
        {
            var mainsceneTagRectRate = new Vec4f(0.5400f, 0.1210f, 0.8057f, 0.3965f);
            var matchRes             = MatchImage(viewportMat, viewportRect, mainsceneTagRectRate, "story_main_scene_tag.png");

            return(matchRes.Success);
        }
예제 #12
0
        public bool IsStoryListScene(Mat viewportMat, RECT viewportRect)
        {
            var listsceneTagRectRate = new Vec4f(0.9207f, 0.0190f, 0.9840f, 0.1108f);
            var matchRes             = MatchImage(viewportMat, viewportRect, listsceneTagRectRate, "story_list_scene_tag.png", listSceneTagThreshold);

            return(matchRes.Success);
        }
예제 #13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="viewportMat"></param>
        /// <param name="viewportRect"></param>
        /// <param name="depth">主线剧情界面这种算第一层</param>
        public void DoListSceneThings(Mat viewportMat, RECT viewportRect, int depth)
        {
            if (depth >= 3)
            {
                return;
            }

            logTools.Info($"DoListSceneThings; CurStory: {CurStory}; Depth: {depth}");

            var listRectRate = new Vec4f(0.5342f, 0.1210f, 0.9789f, 0.8790f);
            var matchRes     = MatchImage(viewportMat, viewportRect, listRectRate, "story_new_tag_inner.png", listItemNewTagThreshold);

            if (matchRes.Success)
            {
                ClickListItem(viewportRect, listRectRate, matchRes.MatchedRect);
                Thread.Sleep(2000);
                var newViewportRect    = MumuState.ViewportRect;
                var newViewportCapture = MumuState.DoCapture(newViewportRect);
                DoListSceneThings(newViewportCapture.ToOpenCvMat(), viewportRect, depth + 1);
            }
            else
            {
                if (DragListTimes > 10)
                {
                    MumuState.ClickBack(viewportRect);
                }
                else
                {
                    MumuState.DoDrag(viewportRect, new Vec2f(0.7700f, 0.7012f), new Vec2f(0.7700f, 0.2332f), 1200);
                    DragListTimes += 1;
                }
            }
        }
예제 #14
0
        public bool IsStoryTabSelected(Mat viewportMat, RECT viewportRect)
        {
            var tabRectRate = new Vec4f(0.3108f, 0.9417f, 0.4243f, 0.9985f);
            var matchRes    = MatchImage(viewportMat, viewportRect, tabRectRate, "story_tab_selected.png");

            return(matchRes.Success);
        }
예제 #15
0
파일: Mat4f.cs 프로젝트: abdalmoez/amathlib
 public Mat4f(Vec4f[] columns)
 {
     for (int i = 0; i < Size; i++)
     {
         cols[i] = new Vec4f(columns[i]);
     }
 }
예제 #16
0
        protected override MeshData genMesh(ItemStack stack, int index)
        {
            BlockCrock crockblock = stack.Collectible as BlockCrock;
            BlockMeal  mealblock  = stack.Collectible as BlockMeal;
            MeshData   mesh;

            if (crockblock != null)
            {
                Vec3f rot = new Vec3f(0, block.Shape.rotateY, 0);
                mesh = BlockEntityCrock.GetMesh(capi.Tesselator, Api, crockblock, crockblock.GetContents(Api.World, stack), crockblock.GetRecipeCode(Api.World, stack), rot).Clone();
            }
            else if (mealblock != null)
            {
                ICoreClientAPI capi      = Api as ICoreClientAPI;
                MealMeshCache  meshCache = capi.ModLoader.GetModSystem <MealMeshCache>();
                mesh = meshCache.GenMealInContainerMesh(mealblock, mealblock.GetCookingRecipe(capi.World, stack), mealblock.GetNonEmptyContents(capi.World, stack));
            }
            else
            {
                ICoreClientAPI capi = Api as ICoreClientAPI;
                if (stack.Class == EnumItemClass.Block)
                {
                    mesh = capi.TesselatorManager.GetDefaultBlockMesh(stack.Block).Clone();
                }
                else
                {
                    nowTesselatingItem  = stack.Item;
                    nowTesselatingShape = capi.TesselatorManager.GetCachedShape(stack.Item.Shape.Base);
                    capi.Tesselator.TesselateItem(stack.Item, out mesh, this);

                    mesh.RenderPasses.Fill((short)EnumChunkRenderPass.BlendNoCull);
                }
            }

            if (stack.Collectible.Attributes?["onDisplayTransform"].Exists == true)
            {
                ModelTransform transform = stack.Collectible.Attributes?["onDisplayTransform"].AsObject <ModelTransform>();
                transform.EnsureDefaultValues();
                mesh.ModelTransform(transform);
            }


            if (stack.Class == EnumItemClass.Item && (stack.Item.Shape == null || stack.Item.Shape.VoxelizeTexture))
            {
                mesh.Rotate(new Vec3f(0.5f, 0.5f, 0.5f), GameMath.PIHALF, 0, 0);
                mesh.Scale(new Vec3f(0.5f, 0.5f, 0.5f), 0.33f, 0.5f, 0.33f);
                mesh.Translate(0, -7.5f / 16f, 0f);
            }


            float x = ((index % 4) >= 2) ? 12 / 16f : 4 / 16f;
            float y = index >= 4 ? 10 / 16f : 2 / 16f;
            float z = (index % 2 == 0) ? 4 / 16f : 10 / 16f;

            Vec4f offset = mat.TransformVector(new Vec4f(x - 0.5f, y, z - 0.5f, 0));

            mesh.Translate(offset.XYZ);

            return(mesh);
        }
        public void OnRenderFrame(float deltaTime, EnumRenderStage stage)
        {
            if (workItemMeshRef == null)
            {
                return;
            }
            if (stage == EnumRenderStage.AfterFinalComposition)
            {
                if (api.World.Player?.InventoryManager?.ActiveHotbarSlot?.Itemstack?.Collectible is ItemHammer)
                {
                    RenderRecipeOutLine();
                }
                return;
            }

            IRenderAPI           rpi         = api.Render;
            IClientWorldAccessor worldAccess = api.World;
            Vec3d camPos = worldAccess.Player.Entity.CameraPos;
            int   temp   = (int)ingot.Collectible.GetTemperature(api.World, ingot);

            Vec4f lightrgbs = worldAccess.BlockAccessor.GetLightRGBs(pos.X, pos.Y, pos.Z);
            int   extraGlow = GameMath.Clamp((temp - 550) / 2, 0, 255);

            float[] glowColor = ColorUtil.GetIncandescenceColorAsColor4f(temp);
            glowRgb.R = glowColor[0];
            glowRgb.G = glowColor[1];
            glowRgb.B = glowColor[2];
            glowRgb.A = extraGlow / 255f;

            rpi.GlDisableCullFace();

            IShaderProgram prog = coreMod.anvilShaderProg;

            prog.Use();
            rpi.BindTexture2d(texId);
            prog.Uniform("rgbaAmbientIn", rpi.AmbientColor);

            prog.Uniform("rgbaFogIn", rpi.FogColor);
            prog.Uniform("fogMinIn", rpi.FogMin);
            prog.Uniform("dontWarpVertices", (int)0);
            prog.Uniform("addRenderFlags", (int)0);
            prog.Uniform("fogDensityIn", rpi.FogDensity);
            prog.Uniform("rgbaTint", ColorUtil.WhiteArgbVec);
            prog.Uniform("rgbaLightIn", lightrgbs);
            prog.Uniform("rgbaGlowIn", glowRgb);
            prog.Uniform("extraGlow", extraGlow);

            prog.UniformMatrix("modelMatrix", ModelMat
                               .Identity()
                               .Translate(pos.X - camPos.X, pos.Y - camPos.Y, pos.Z - camPos.Z)
                               .Values
                               );
            prog.UniformMatrix("viewMatrix", rpi.CameraMatrixOriginf);
            prog.UniformMatrix("projectionMatrix", rpi.CurrentProjectionMatrix);


            rpi.RenderMesh(workItemMeshRef);

            prog.Stop();
        }
예제 #18
0
파일: Mat4f.cs 프로젝트: abdalmoez/amathlib
 public Mat4f(Vec4f c0, Vec4f c1, Vec4f c2, Vec4f c3)
 {
     cols[0] = new Vec4f(c0);
     cols[1] = new Vec4f(c1);
     cols[2] = new Vec4f(c2);
     cols[3] = new Vec4f(c3);
 }
예제 #19
0
파일: Mat4f.cs 프로젝트: abdalmoez/amathlib
 public Mat4f(Mat4f m)
 {
     for (int i = 0; i < Size; i++)
     {
         cols[i] = new Vec4f(m.cols[i]);
     }
 }
        public override void DoRender3DOpaqueBatched(float dt, bool isShadowPass)
        {
            if (isSpectator || (meshRefOpaque == null && meshRefOit == null))
            {
                return;
            }

            if (isShadowPass)
            {
                Mat4f.Mul(tmpMvMat, capi.Render.CurrentModelviewMatrix, ModelMat);
                capi.Render.CurrentActiveShader.UniformMatrix("modelViewMatrix", tmpMvMat);
            }
            else
            {
                Vec4f lightrgbs = capi.World.BlockAccessor.GetLightRGBs((int)(entity.Pos.X + entity.CollisionBox.X1 - entity.OriginCollisionBox.X1), (int)entity.Pos.Y, (int)(entity.Pos.Z + entity.CollisionBox.Z1 - entity.OriginCollisionBox.Z1));

                capi.Render.CurrentActiveShader.Uniform("rgbaLightIn", lightrgbs);
                capi.Render.CurrentActiveShader.Uniform("extraGlow", entity.Properties.Client.GlowLevel);
                capi.Render.CurrentActiveShader.UniformMatrix("modelMatrix", ModelMat);
                capi.Render.CurrentActiveShader.UniformMatrix("viewMatrix", capi.Render.CurrentModelviewMatrix);
                capi.Render.CurrentActiveShader.Uniform("addRenderFlags", AddRenderFlags);
                capi.Render.CurrentActiveShader.Uniform("windWaveIntensity", (float)WindWaveIntensity);
                capi.Render.CurrentActiveShader.Uniform("skipRenderJointId", skipRenderJointId);
                capi.Render.CurrentActiveShader.Uniform("skipRenderJointId2", skipRenderJointId2);
                capi.Render.CurrentActiveShader.Uniform("entityId", (int)entity.EntityId);
                capi.Render.CurrentActiveShader.Uniform("waterWaveCounter", capi.Render.ShaderUniforms.WaterWaveCounter);

                color[0] = (entity.RenderColor >> 16 & 0xff) / 255f;
                color[1] = ((entity.RenderColor >> 8) & 0xff) / 255f;
                color[2] = ((entity.RenderColor >> 0) & 0xff) / 255f;
                color[3] = ((entity.RenderColor >> 24) & 0xff) / 255f;

                capi.Render.CurrentActiveShader.Uniform("renderColor", color);

                double stab    = entity.WatchedAttributes.GetDouble("temporalStability", 1);
                double plrStab = capi.World.Player.Entity.WatchedAttributes.GetDouble("temporalStability", 1);
                double stabMin = Math.Min(stab, plrStab);

                float strength = (float)(glitchAffected ? Math.Max(0, 1 - 1 / 0.4f * stabMin) : 0);
                capi.Render.CurrentActiveShader.Uniform("glitchEffectStrength", strength);
            }


            capi.Render.CurrentActiveShader.UniformMatrices(
                "elementTransforms",
                GlobalConstants.MaxAnimatedElements,
                entity.AnimManager.Animator.Matrices
                );

            if (meshRefOpaque != null)
            {
                capi.Render.RenderMesh(meshRefOpaque);
            }

            if (meshRefOit != null)
            {
                capi.Render.RenderMesh(meshRefOit);
            }
        }
예제 #21
0
        public static string FormatAsJsonArray(this Vec4f rectRate)
        {
            var s = string.Format("[{0}, {1}, {2}, {3}]",
                                  rectRate.Item0.Format(), rectRate.Item1.Format(),
                                  rectRate.Item2.Format(), rectRate.Item3.Format());

            return(s);
        }
예제 #22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="viewportMat"></param>
        /// <param name="viewportRect"></param>
        /// <param name="exRectRate">采样区域</param>
        /// <param name="exName"></param>
        /// <returns></returns>
        public MatchImageResult MatchImage(Mat viewportMat, RECT viewportRect, Vec4f exRectRate, string exName, double threshold)
        {
            var exRectMat = viewportMat.GetChildMatByRectRate(exRectRate);
            var exImgMat  = ConfigMgr.GetInstance().GetPCRExImg(exName, viewportMat, viewportRect);
            var matchRes  = GraphicsTools.GetInstance().MatchImage(exRectMat, exImgMat, threshold);

            return(matchRes);
        }
예제 #23
0
        public static Mat GetChildMatByRectRate(this Mat mat, Vec4f rectRate)
        {
            var rect         = GetRect(mat);
            var relativeRect = rect.GetChildRectByRate(rectRate);
            var childMat     = GetChildMatByRect(mat, relativeRect);

            return(childMat);
        }
예제 #24
0
        public static string Format(this Vec4f rectRate)
        {
            var s = string.Format("new Vec4f({0}f, {1}f, {2}f, {3}f)",
                                  rectRate.Item0.Format(), rectRate.Item1.Format(),
                                  rectRate.Item2.Format(), rectRate.Item3.Format());

            return(s);
        }
예제 #25
0
        public bool IsReliabilityMainScene(Mat viewportMat, RECT viewportRect)
        {
            var threshold = 0.7;
            var rectRate  = new Vec4f(0.0138f, 0.0058f, 0.1601f, 0.1079f);
            var matchRes  = MatchImage(viewportMat, viewportRect, rectRate, "reliability_main_scene_tag.png", threshold);

            return(matchRes.Success);
        }
예제 #26
0
        public bool IsReliabilityEpisodeScene(Mat viewportMat, RECT viewportRect)
        {
            var threshold = 0.7;
            var rectRate  = new Vec4f(0.0167f, 0.7799f, 0.2322f, 0.8892f);
            var matchRes  = MatchImage(viewportMat, viewportRect, rectRate, "reliability_episode_scene_tag.png", threshold);

            return(matchRes.Success);
        }
예제 #27
0
파일: Mat4.cs 프로젝트: abdalmoez/amathlib
        public Mat4(Mat3 m, Vec4f v)
        {
            for (int i = 0; i < Size - 1; i++)
            {
                cols[i] = new Vec4(m[i]);
            }

            cols[Size - 1] = new Vec4(v);
        }
예제 #28
0
	public static Vec4f Mult (Matrix4 m, Vec4f v)
	{
		return new Vec4f {
			x = m.R0C0*v.x + m.R0C1*v.y + m.R0C2*v.z + m.R0C3*v.h,
			y = m.R1C0*v.x + m.R1C1*v.y + m.R1C2*v.z + m.R1C3*v.h,
			z = m.R2C0*v.x + m.R2C1*v.y + m.R2C2*v.z + m.R2C3*v.h,
			h = m.R3C0*v.x + m.R3C1*v.y + m.R3C2*v.z + m.R3C3*v.h
		};
	}
        public override bool OnTesselation(ITerrainMeshPool mesher, ITesselatorAPI tesselator)
        {
            base.OnTesselation(mesher, tesselator);

            LightRgba = Api.World.BlockAccessor.GetLightRGBs(Blockentity.Pos);

            return false;

        }
예제 #30
0
        public override void TranslateMesh(MeshData mesh, int index)
        {
            float x = (index % 2 == 0) ? 11.5f / 16f : 4.5f / 16f;

            Vec4f offset = mat.TransformVector(new Vec4f(x - 0.5f, 4 / 16f, -4.5f / 16f, 0f));

            mesh.Scale(new Vec3f(0.5f, 0f, 0.5f), 0.5f, 0.5f, 0.5f);
            mesh.Translate(offset.XYZ);
        }
예제 #31
0
        /// <summary>
        /// Finds lines in the input image.
        /// This is the output of the default parameters of the algorithm on the above shown image.
        /// </summary>
        /// <param name="image">A grayscale (CV_8UC1) input image. </param>
        /// <param name="lines">A vector of Vec4i or Vec4f elements specifying the beginning and ending point of a line. 
        /// Where Vec4i/Vec4f is (x1, y1, x2, y2), point 1 is the start, point 2 - end. Returned lines are strictly oriented depending on the gradient.</param>
        /// <param name="width">Vector of widths of the regions, where the lines are found. E.g. Width of line.</param>
        /// <param name="prec">Vector of precisions with which the lines are found.</param>
        /// <param name="nfa">Vector containing number of false alarms in the line region, 
        /// with precision of 10%. The bigger the value, logarithmically better the detection.</param>
        public virtual void Detect(InputArray image, out Vec4f[] lines,
            out double[] width, out double[] prec, out double[] nfa)
        {
            if (image == null)
                throw new ArgumentNullException(nameof(image));
            image.ThrowIfDisposed();

            using (var linesVec = new VectorOfVec4f())
            using (var widthVec = new VectorOfDouble())
            using (var precVec = new VectorOfDouble())
            using (var nfaVec = new VectorOfDouble())
            {
                NativeMethods.imgproc_LineSegmentDetector_detect_vector(ptr, image.CvPtr,
                    linesVec.CvPtr, widthVec.CvPtr, precVec.CvPtr, nfaVec.CvPtr);

                lines = linesVec.ToArray();
                width = widthVec.ToArray();
                prec = precVec.ToArray();
                nfa = nfaVec.ToArray();
            }

            GC.KeepAlive(image);
        }
예제 #32
0
        /// <summary>
        /// converts point coordinates from normal pixel coordinates to homogeneous coordinates ((x,y)->(x,y,1))
        /// </summary>
        /// <param name="src">Input vector of N-dimensional points.</param>
        /// <returns>Output vector of N+1-dimensional points.</returns>
        public static Vec4f[] ConvertPointsToHomogeneous(IEnumerable<Vec3f> src)
        {
            if (src == null)
                throw new ArgumentNullException("src");

            Vec3f[] srcA = EnumerableEx.ToArray(src);
            Vec4f[] dstA = new Vec4f[srcA.Length];
            NativeMethods.calib3d_convertPointsToHomogeneous_array2(srcA, dstA, srcA.Length);
            return dstA;
        }
예제 #33
0
 public static extern void core_Mat_push_back_Vec4f(IntPtr self, Vec4f v);
 public static Vec4f Cos(Vec4f radians)
 {
     return new Vec4f()
     {
         x = (float)Math.Cos(radians.x),
         y = (float)Math.Cos(radians.y),
         z = (float)Math.Sin(radians.z),
         w = (float)Math.Cos(radians.w)
     };
 }