1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- using Assets.StreetLight.Adapters;
- using Assets.StreetLight.Interfaces;
- using Assets.StreetLight.Poco;
- using System.Collections;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Runtime.CompilerServices;
- using UnityEngine;
- public class PersonManager : MonoBehaviour
- {
- public ObservableCollection<Person> Persons { get; set; }
- private IPersonDetector personDetector;
- void Start()
- {
- var cylinderUL = GameObject.Find("CylinderUL");
- var cylinderUR = GameObject.Find("CylinderUR");
- var cylinderDR = GameObject.Find("CylinderDR");
- var cylinderDL = GameObject.Find("CylinderDL");
- var sphere = GameObject.Find("Sphere");
- // World to Unity Position
- var calibrationVectors = new Dictionary<Vector3, Vector3> {
- { new Vector3(-0.5225359f, -2.012292f, 3.934204f), new Vector3(cylinderUL.transform.position.x, cylinderUL.transform.position.y, cylinderUL.transform.position.z) },
- { new Vector3(2.538264f, -2.015675f, 2.318164f), new Vector3(cylinderUR.transform.position.x, cylinderUR.transform.position.y, cylinderUR.transform.position.z) },
- { new Vector3(-1.551626f, -1.86093f, 2.275376f), new Vector3(cylinderDR.transform.position.x, cylinderDR.transform.position.y, cylinderDR.transform.position.z) },
- { new Vector3(-1.095514f, -1.981828f, 2.849167f), new Vector3(cylinderDL.transform.position.x, cylinderDL.transform.position.y, cylinderDL.transform.position.z) },
- { new Vector3(0.6326299f, -1.908295f, 2.349819f), new Vector3(cylinderDL.transform.position.x, cylinderDL.transform.position.y, cylinderDL.transform.position.z) },
- };
- var positionCalculator = new PositionCalculator(calibrationVectors);
- Persons = new ObservableCollection<Person>();
- personDetector = new ZedPersonDetector(FindObjectOfType<ZEDManager>(), positionCalculator);
- personDetector.PersonsDetected += PersonDetector_PersonsDetected;
- }
- private void PersonDetector_PersonsDetected(object sender, IEnumerable<Person> e)
- {
- foreach (var person in e)
- {
- Persons.Add(person);
- }
- }
- void Update()
- {
- }
- }
|