Ejemplo n.º 1
0
 public void exit()
 {
     if (currentInstance != null)
     {
         image_handler.close();
         available = false;
         BBox_edges.clear();
         BBox_faces.clear();
     }
 }
Ejemplo n.º 2
0
        public void update(Mat image, Objects objects)
        {
            image_handler.pushNewImage(image);

            //if(objects.isNew == 0) return;

            BBox_faces.clear();
            BBox_edges.clear();
            objectsName.Clear();

            // For each object
            for (int idx = 0; idx < objects.numObject; idx++)
            {
                sl.ObjectData obj = objects.objectData[idx];

                // Only show tracked objects
                if (renderObject(obj))
                {
                    List <Vector3> bb_ = new List <Vector3>();
                    bb_.AddRange(obj.boundingBox);
                    if (bb_.Count > 0)
                    {
                        float4 clr_id    = generateColorClass(obj.id);
                        float4 clr_class = generateColorClass((int)obj.label);

                        if (obj.objectTrackingState != sl.OBJECT_TRACKING_STATE.OK)
                        {
                            clr_id = clr_class;
                        }
                        else
                        {
                            createIDRendering(obj.position, clr_id, obj.id);
                        }

                        createBboxRendering(bb_, clr_id);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public void update(Mat image, Objects objects)
        {
            image_handler.pushNewImage(image);

            bones.clear();
            joints.clear();

            BBox_faces.clear();
            BBox_edges.clear();

            if (Keyboard.IsKeyDown(Key.B))
            {
                showbbox = !showbbox;
            }

            // For each object
            for (int idx = 0; idx < objects.numObject; idx++)
            {
                sl.ObjectData obj = objects.objectData[idx];

                // Only show tracked objects
                if (renderObject(obj))
                {
                    List <Vector3> bb_ = new List <Vector3>();
                    bb_.AddRange(obj.boundingBox);
                    float4    clr_id    = generateColorClass(obj.id);
                    float4    clr_class = generateColorClass((int)obj.label);
                    Vector3[] keypoints = obj.keypoints;

                    if (showbbox)
                    {
                        if (obj.objectTrackingState != sl.OBJECT_TRACKING_STATE.OK)
                        {
                            clr_id = clr_class;
                        }
                        else
                        {
                            createIDRendering(obj.position, clr_id, obj.id);
                        }

                        createBboxRendering(bb_, clr_id);
                    }

                    if (keypoints.Length > 0)
                    {
                        foreach (var limb in BODY_BONES)
                        {
                            Vector3 kp_1 = keypoints[getIdx(limb.Item1)];
                            Vector3 kp_2 = keypoints[getIdx(limb.Item2)];

                            float norm_1 = kp_1.Length();
                            float norm_2 = kp_2.Length();

                            if (!float.IsNaN(norm_1) && norm_1 > 0 && !float.IsNaN(norm_2) && norm_2 > 0)
                            {
                                bones.addCylinder(new float3(kp_1.X, kp_1.Y, kp_1.Z), new float3(kp_2.X, kp_2.Y, kp_2.Z), clr_id);
                            }
                        }
                        for (int i = 0; i < (int)BODY_PARTS.LAST; i++)
                        {
                            Vector3 kp   = keypoints[i];
                            float   norm = kp.Length();
                            if (!float.IsNaN(norm) && norm > 0)
                            {
                                joints.addSphere(new float3(kp.X, kp.Y, kp.Z), clr_id);
                            }
                        }
                    }
                }
            }
        }