Exemplo n.º 1
0
    void ObjectTracking()
    {
        int detectedTrackingCount = 0;

        unsafe
        {
            fixed(CvRectangle *outTracking = _tracking)
            {
                OpenCVInterop.Track(outTracking, _maxTrackingCount, ref detectedTrackingCount);
            }
        }

        NormalizedTrackingPositions.Clear();
        for (int i = 0; i < detectedTrackingCount; i++)
        {
            NormalizedTrackingPositions.Add(new Vector2((_tracking[i].X * DetectionDownScale) / CameraResolution.x, 1f - ((_tracking[i].Y * DetectionDownScale) / CameraResolution.y)));
        }
        Debug.Log(NormalizedTrackingPositions);
    }
    private void PatientTracking()
    {
        // Unsafe codeblock to retrieve data from OpenCV
        int detectedTrackingCount = 0;

        unsafe
        {
            fixed(CvRectangle *outTracking = _tracking)
            {
                OpenCVInterop.Track(outTracking, _maxTrackCount, ref detectedTrackingCount);
            }
        }

        // Record the Normalized Tracking Positions
        NormalizedTrackingPositions.Clear();
        for (int i = 0; i < detectedTrackingCount; i++)
        {
            NormalizedTrackingPositions.Add(new Vector2((_tracking[i].X * DetectionDownScale) / CameraResolution.x, 1f - ((_tracking[i].Y * DetectionDownScale) / CameraResolution.y)));
        }

        patientBody = _tracking[0];
        // Log current patient position for debugging
        Debug.Log("Patient At: (x=" + _tracking[0].X + " y=" + _tracking[0].Y + " width=" + _tracking[0].Width + " height=" + _tracking[0].Height + ")");
    }