/// <summary>
    /// Creates an OpenCV matrix based on the ZED camera's rectified parameters. This is specific to each camera.
    /// </summary>
    private void Initialize()
    {
        zedCam = zedManager.zedCamera;
        sl.CameraParameters camparams = zedCam.CalibrationParametersRectified.leftCam;

        //Shorthand.
        double fx = camparams.fx;
        double fy = camparams.fy;
        double cx = camparams.cx;
        double cy = camparams.cy;

        //Build a rough 3x3 matrix for OpenCV with the camera's parameters.
        camMat = new Mat(3, 3, CvType.CV_64FC1);

        camMat.put(0, 0, fx);
        camMat.put(0, 1, 0);
        camMat.put(0, 2, cx);
        camMat.put(1, 0, 0);
        camMat.put(1, 1, fy);
        camMat.put(1, 2, cy);
        camMat.put(2, 0, 0);
        camMat.put(2, 1, 0);
        camMat.put(2, 2, 0.0f);

        Size imageSize = new Size(zedCam.ImageWidth, zedCam.ImageHeight);

        //Make ZED and OpenCV versions of the image matrices.
        //Each grab, we'll fill the zedMat from the ZED SDK, copy it to cvMat, and run marker detection on it.
        //8U_C1(8 bits, one channel) as we're using a grayscale image for performance.
        //zedMat = new ZEDMat((uint)zedCam.ImageWidth, (uint)zedCam.ImageHeight, sl.ZEDMat.MAT_TYPE.MAT_8U_C1);
        //cvMat = SLMat2CVMat(zedMat, ZEDMat.MAT_TYPE.MAT_8U_C1);

        isInit = true;
    }
Beispiel #2
0
        public void init(CameraParameters param)
        {
            pointCloud.initialize(param.resolution);
            // Compile and create the shader
            shaderBbox         = new ShaderData();
            shaderBbox.it      = new Shader(Shader.VERTEX_SHADER, Shader.FRAGMENT_SHADER);
            shaderBbox.MVP_Mat = Gl.GetUniformLocation(shaderBbox.it.getProgramId(), "u_mvpMatrix");

            //Create Camera
            //setRenderCameraProjection(param, 0.5f, 20f);
            camera_ = new CameraGL(new Vector3(0, 0, 1), new Vector3(0, 0, -1f), Vector3.UnitY);
            camera_.setOffsetFromPosition(new Vector3(0, 0, 1.5f));

            frustum.init();
            frustum.setDrawingType(PrimitiveType.Triangles);
            frustum.createFrustum(param);
            frustum.pushToGPU();

            cam_pose = new Matrix4x4();

            available = true;
        }
Beispiel #3
0
        public void init(CameraParameters param, bool isTrackingON)
        {
            isTrackingON_ = isTrackingON;
            Gl.Enable(EnableCap.FramebufferSrgb);

            shaderBasic         = new ShaderData();
            shaderBasic.it      = new Shader(Shader.VERTEX_SHADER, Shader.FRAGMENT_SHADER);
            shaderBasic.MVP_Mat = Gl.GetUniformLocation(shaderBasic.it.getProgramId(), "u_mvpMatrix");

            setRenderCameraProjection(param, 0.5f, 20);

            image_handler.initialize();
            BBox_edges.init();
            BBox_edges.setDrawingType(PrimitiveType.Lines);
            BBox_faces.init();
            BBox_faces.setDrawingType(PrimitiveType.Quads);

            objectsName = new List <ObjectClassName>();

            Gl.Disable(EnableCap.DepthTest);

            available = true;
        }
Beispiel #4
0
        public void init(CameraParameters param, MODEL cameraModel)
        {
            mainShader         = new ShaderData();
            mainShader.it      = new Shader(Shader.VERTEX_SHADER, Shader.FRAGMENT_SHADER);
            mainShader.MVP_Mat = Gl.GetUniformLocation(mainShader.it.getProgramId(), "u_mvpMatrix");

            shaderLine         = new ShaderData();
            shaderLine.it      = new Shader(Shader.VERTEX_SHADER, Shader.FRAGMENT_SHADER);
            shaderLine.MVP_Mat = Gl.GetUniformLocation(shaderLine.it.getProgramId(), "u_mvpMatrix");

            //Create Camera
            camera_ = new CameraGL(new Vector3(0f, 1f, 1f), new Vector3(0, -1, -4f), Vector3.UnitY);
            camera_.setOffsetFromPosition(new Vector3(0, 0, 1.0f));

            floor_grid.init();
            floor_grid.setDrawingType(PrimitiveType.Lines);

            zedModel.init();
            zedModel.setDrawingType(PrimitiveType.Triangles);
            zedPath.init();

            float  limit = 20;
            float4 clr1  = new float4();

            clr1.x = 0.85f;
            clr1.y = 0.87f;
            clr1.z = 0.88f;
            clr1.w = 1f;

            float4 clr2 = new float4();

            clr2.x = 0.42f;
            clr2.y = 0.48f;
            clr2.z = 0.53f;
            clr2.w = 1f;

            float height = 0.0f;

            for (int i = (int)(limit * -5); i <= (int)(limit * 5); i++)
            {
                float i_f = i / 5.0f;
                if ((i % 5) == 0)
                {
                    addVert(ref floor_grid, i_f, limit, height, clr2);
                }
                else
                {
                    addVert(ref floor_grid, i_f, limit, height, clr1);
                }
            }
            floor_grid.pushToGPU();
            zedPath.setDrawingType(PrimitiveType.LineStrip);

            Model3D model = new Model3D();

            switch (cameraModel)
            {
            case MODEL.ZED:
                model = new Model3D_ZED();
                break;

            case MODEL.ZED2:
                model = new Model3D_ZED2();
                break;

            case MODEL.ZED_M:
                model = new Model3D_ZED();
                break;
            }

            foreach (ModelPart part in model.part)
            {
                fillZED(part.nb_triangles, model.vertices, part.triangles, part.color, ref zedModel);
            }

            zedModel.pushToGPU();
            updateZEDposition = false;

            available = true;
        }