コード例 #1
0
        public MainWindow(string[] args)
        {
            // Set configuration parameters
            InitParameters init_params = new InitParameters();

            init_params.resolution           = RESOLUTION.HD720;
            init_params.cameraFPS            = 60;
            init_params.depthMode            = DEPTH_MODE.ULTRA;
            init_params.coordinateUnits      = UNIT.METER;
            init_params.coordinateSystem     = COORDINATE_SYSTEM.RIGHT_HANDED_Y_UP;
            init_params.depthMaximumDistance = 50f;

            parseArgs(args, ref init_params);
            // Open the camera
            zedCamera = new Camera(0);
            ERROR_CODE err = zedCamera.Open(ref init_params);

            if (err != ERROR_CODE.SUCCESS)
            {
                Environment.Exit(-1);
            }

            // Enable trackin
            Quaternion quat = Quaternion.Identity;
            Vector3    vec  = Vector3.Zero;

            zedCamera.EnablePositionalTracking(ref quat, ref vec);

            runtimeParameters = new RuntimeParameters();

            point_cloud = new Mat();
            int Height = zedCamera.ImageHeight;
            int Width  = zedCamera.ImageWidth;

            res = new Resolution((uint)Width, (uint)Height);
            point_cloud.Create(res, MAT_TYPE.MAT_32F_C4, MEM.CPU);

            // Create OpenGL Viewer
            viewer = new GLViewer();

            cam_pose = new Pose();

            // Create OpenGL window
            CreateWindow();
        }
コード例 #2
0
        public MainWindow(string[] args)
        {
            // Set configuration parameters
            InitParameters init_params = new InitParameters();

            init_params.resolution       = RESOLUTION.HD720;
            init_params.cameraFPS        = 60;
            init_params.depthMode        = DEPTH_MODE.ULTRA;
            init_params.coordinateUnits  = UNIT.METER;
            init_params.coordinateSystem = COORDINATE_SYSTEM.RIGHT_HANDED_Y_UP;
            init_params.sdkVerbose       = true;

            parseArgs(args, ref init_params);
            // Open the camera
            zedCamera = new Camera(0);
            ERROR_CODE err = zedCamera.Open(ref init_params);

            if (err != ERROR_CODE.SUCCESS)
            {
                Environment.Exit(-1);
            }

            // Enable tracking
            PositionalTrackingParameters trackingParams = new PositionalTrackingParameters();

            trackingParams.enableAreaMemory = true;
            zedCamera.EnablePositionalTracking(ref trackingParams);

            runtimeParameters = new RuntimeParameters();

            cameraModel = zedCamera.GetCameraModel();

            int Height = zedCamera.ImageHeight;
            int Width  = zedCamera.ImageWidth;

            res = new Resolution((uint)Width, (uint)Height);

            // Create OpenGL Viewer
            viewer = new GLViewer();

            cam_pose = new Pose();

            // Create OpenGL window
            CreateWindow();
        }
コード例 #3
0
        public MainWindow(string[] args)
        {
            // Set configuration parameters
            InitParameters init_params = new InitParameters();

            init_params.resolution           = RESOLUTION.HD720;
            init_params.cameraFPS            = 60;
            init_params.depthMode            = DEPTH_MODE.ULTRA;
            init_params.coordinateUnits      = UNIT.METER;
            init_params.coordinateSystem     = COORDINATE_SYSTEM.RIGHT_HANDED_Y_UP;
            init_params.depthMaximumDistance = 15f;

            parseArgs(args, ref init_params);
            // Open the camera
            zedCamera = new Camera(0);
            ERROR_CODE err = zedCamera.Open(ref init_params);

            if (err != ERROR_CODE.SUCCESS)
            {
                Environment.Exit(-1);
            }

            if (zedCamera.CameraModel != sl.MODEL.ZED2)
            {
                Console.WriteLine(" ERROR : Use ZED2 Camera only");
                return;
            }

            // Enable tracking (mandatory for object detection)
            Quaternion quat = Quaternion.Identity;
            Vector3    vec  = Vector3.Zero;

            zedCamera.EnablePositionalTracking(ref quat, ref vec);

            runtimeParameters = new RuntimeParameters();
            // Enable the Objects detection module
            ObjectDetectionParameters obj_det_params = new ObjectDetectionParameters();

            obj_det_params.enableObjectTracking = true; // the object detection will track objects across multiple images, instead of an image-by-image basis
            obj_det_params.enable2DMask         = false;
            obj_det_params.enableBodyFitting    = true; // smooth skeletons moves
            obj_det_params.imageSync            = true; // the object detection is synchronized to the image
            obj_det_params.detectionModel       = sl.DETECTION_MODEL.MULTI_CLASS_BOX_ACCURATE;

            zedCamera.EnableObjectDetection(ref obj_det_params);

            // Create ZED Objects filled in the main loop
            object_frame = new Objects();
            zedMat       = new Mat();
            int Height = zedCamera.ImageHeight;
            int Width  = zedCamera.ImageWidth;

            Resolution res = new Resolution((uint)Width, (uint)Height);

            zedMat.Create(res, MAT_TYPE.MAT_8U_C4, MEM.CPU);

            // Create OpenGL Viewer
            viewer = new GLViewer(new Resolution((uint)Width, (uint)Height));

            // Configure object detection runtime parameters
            obj_runtime_parameters = new ObjectDetectionRuntimeParameters();
            obj_runtime_parameters.detectionConfidenceThreshold = 35;
            obj_runtime_parameters.objectClassFilter            = new int[(int)OBJECT_CLASS.LAST];
            obj_runtime_parameters.objectClassFilter[(int)sl.OBJECT_CLASS.PERSON] = Convert.ToInt32(true);

            // To set a specific threshold
            obj_runtime_parameters.objectConfidenceThreshold = new int[(int)OBJECT_CLASS.LAST];
            obj_runtime_parameters.objectConfidenceThreshold[(int)sl.OBJECT_CLASS.PERSON] = 35;

            // Create OpenGL window
            CreateWindow();
        }
コード例 #4
0
        public MainWindow(string[] args)
        {
            // Set configuration parameters
            InitParameters init_params = new InitParameters();

            init_params.resolution       = RESOLUTION.HD1080;
            init_params.cameraFPS        = 30;
            init_params.depthMode        = DEPTH_MODE.ULTRA;
            init_params.coordinateUnits  = UNIT.METER;
            init_params.coordinateSystem = COORDINATE_SYSTEM.RIGHT_HANDED_Y_UP;

            parseArgs(args, ref init_params);
            // Open the camera
            zedCamera = new Camera(0);
            ERROR_CODE err = zedCamera.Open(ref init_params);

            if (err != ERROR_CODE.SUCCESS)
            {
                Environment.Exit(-1);
            }

            if (!(zedCamera.CameraModel == sl.MODEL.ZED2 || zedCamera.CameraModel == sl.MODEL.ZED2i))
            {
                Console.WriteLine(" ERROR : Use ZED2/ZED2i Camera only");
                return;
            }

            // Enable tracking (mandatory for object detection)
            PositionalTrackingParameters positionalTrackingParameters = new PositionalTrackingParameters();

            zedCamera.EnablePositionalTracking(ref positionalTrackingParameters);

            runtimeParameters = new RuntimeParameters();

            // Enable the Objects detection module
            ObjectDetectionParameters obj_det_params = new ObjectDetectionParameters();

            obj_det_params.enableObjectTracking = true; // the object detection will track objects across multiple images, instead of an image-by-image basis
            isTrackingON = obj_det_params.enableObjectTracking;
            obj_det_params.enable2DMask      = false;
            obj_det_params.enableBodyFitting = true; // smooth skeletons moves
            obj_det_params.imageSync         = true; // the object detection is synchronized to the image
            obj_det_params.detectionModel    = sl.DETECTION_MODEL.HUMAN_BODY_ACCURATE;

            zedCamera.EnableObjectDetection(ref obj_det_params);

            // Create ZED Objects filled in the main loop
            camPose = new sl.Pose();
            objects = new Objects();
            int Height = zedCamera.ImageHeight;
            int Width  = zedCamera.ImageWidth;

            imageLeft  = new Mat();
            displayRes = new Resolution(Math.Min((uint)Width, 1280), Math.Min((uint)Height, 720));
            imgScale   = new sl.float2((int)displayRes.width / (float)Width, (int)displayRes.height / (float)Height);
            imageLeft.Create(displayRes, MAT_TYPE.MAT_8U_C4, MEM.CPU);

            imageLeftOcv = new OpenCvSharp.Mat((int)displayRes.height, (int)displayRes.width, OpenCvSharp.MatType.CV_8UC4, imageLeft.GetPtr());

            pointCloud = new sl.Mat();
            pcRes      = new Resolution(Math.Min((uint)Width, 720), Math.Min((uint)Height, 404));
            pointCloud.Create(pcRes, MAT_TYPE.MAT_32F_C4, MEM.CPU);

            // Create OpenGL Viewer
            viewer = new GLViewer(new Resolution((uint)Width, (uint)Height));

            // Configure object detection runtime parameters
            obj_runtime_parameters = new ObjectDetectionRuntimeParameters();
            obj_runtime_parameters.detectionConfidenceThreshold = 40;

            window_name = "ZED| 2D View";
            Cv2.NamedWindow(window_name, WindowMode.Normal);// Create Window

            // Create OpenGL window
            CreateWindow();
        }
コード例 #5
0
        public MainWindow(string[] args)
        {
            // Set configuration parameters
            InitParameters init_params = new InitParameters();

            init_params.resolution       = RESOLUTION.HD720;
            init_params.cameraFPS        = 60;
            init_params.depthMode        = DEPTH_MODE.ULTRA;
            init_params.coordinateUnits  = UNIT.METER;
            init_params.coordinateSystem = COORDINATE_SYSTEM.RIGHT_HANDED_Y_UP;
            init_params.sdkVerbose       = true;

            parseArgs(args, ref init_params);
            // Open the camera
            zedCamera = new Camera(0);
            ERROR_CODE err = zedCamera.Open(ref init_params);

            if (err != ERROR_CODE.SUCCESS)
            {
                Environment.Exit(-1);
            }

            if (zedCamera.CameraModel != sl.MODEL.ZED2)
            {
                Console.WriteLine(" ERROR : Use ZED2 Camera only");
                return;
            }

            findPlaneStatus = ERROR_CODE.FAILURE;
            tracking_state  = POSITIONAL_TRACKING_STATE.OFF;

            hasIMU     = zedCamera.GetSensorsConfiguration().gyroscope_parameters.isAvailable;
            userAction = new UserAction();
            // Enable tracking
            PositionalTrackingParameters positionalTrackingParameters = new PositionalTrackingParameters();

            zedCamera.EnablePositionalTracking(ref positionalTrackingParameters);

            runtimeParameters = new RuntimeParameters();
            runtimeParameters.measure3DReferenceFrame = REFERENCE_FRAME.WORLD;
            // Create ZED Objects filled in the main loop
            zedMat   = new Mat();
            cam_pose = new Pose();

            //Create mesh.
            planeMeshTriangles = new int[65000];
            planeMeshVertices  = new Vector3[65000];
            plane = new PlaneData();
            int Height = zedCamera.ImageHeight;
            int Width  = zedCamera.ImageWidth;

            Resolution res = new Resolution((uint)Width, (uint)Height);

            zedMat.Create(res, MAT_TYPE.MAT_8U_C4, MEM.CPU);

            // Create OpenGL Viewer
            viewer = new GLViewer(new Resolution((uint)Width, (uint)Height));

            // Create OpenGL window
            CreateWindow();
        }
コード例 #6
0
        public MainWindow(string[] args)
        {
            // Set configuration parameters
            InitParameters init_params = new InitParameters();

            init_params.resolution           = RESOLUTION.HD720;
            init_params.cameraFPS            = 60;
            init_params.depthMode            = DEPTH_MODE.ULTRA;
            init_params.coordinateUnits      = UNIT.METER;
            init_params.coordinateSystem     = COORDINATE_SYSTEM.RIGHT_HANDED_Y_UP;
            init_params.depthMaximumDistance = 15f;
            init_params.sdkVerbose           = true;

            parseArgs(args, ref init_params);
            // Open the camera
            zedCamera = new Camera(0);
            ERROR_CODE err = zedCamera.Open(ref init_params);

            if (err != ERROR_CODE.SUCCESS)
            {
                Environment.Exit(-1);
            }

            if (zedCamera.CameraModel != sl.MODEL.ZED2)
            {
                Console.WriteLine(" ERROR : Use ZED2 Camera only");
                return;
            }

            tracking_state    = POSITIONAL_TRACKING_STATE.OFF;
            mapping_state     = SPATIAL_MAPPING_STATE.NOT_ENABLED;
            mapping_activated = false;

            // Enable tracking
            PositionalTrackingParameters positionalTrackingParameters = new PositionalTrackingParameters();

            zedCamera.EnablePositionalTracking(ref positionalTrackingParameters);

            runtimeParameters = new RuntimeParameters();

            spatialMappingParameters = new SpatialMappingParameters();
            spatialMappingParameters.resolutionMeter = SpatialMappingParameters.get(MAPPING_RESOLUTION.MEDIUM);
            spatialMappingParameters.saveTexture     = false;
            if (CREATE_MESH)
            {
                spatialMappingParameters.map_type = SPATIAL_MAP_TYPE.MESH;
            }
            else
            {
                spatialMappingParameters.map_type = SPATIAL_MAP_TYPE.FUSED_POINT_CLOUD;
            }

            // Create ZED Objects filled in the main loop
            zedMat   = new Mat();
            cam_pose = new Pose();

            //Create mesh.
            mesh            = new Mesh();
            fusedPointCloud = new FusedPointCloud();
            int Height = zedCamera.ImageHeight;
            int Width  = zedCamera.ImageWidth;

            Resolution res = new Resolution((uint)Width, (uint)Height);

            zedMat.Create(res, MAT_TYPE.MAT_8U_C4, MEM.CPU);

            // Create OpenGL Viewer
            viewer = new GLViewer(new Resolution((uint)Width, (uint)Height));

            Console.WriteLine("Hit SPACE BAR to start spatial mapping...");

            // Create OpenGL window
            CreateWindow();
        }