/*private OpenTSPSScene addScene(ArrayList args) * { * OpenTSPSScene newScene = new OpenTSPSScene(); * updateScene(newScene, args); * for (int i = 0; i < listeners.Count; i++) { * OpenTSPSListener listener = (OpenTSPSListener)listeners[i]; * if (listener!=null){ * listener.sceneUpdated(newScene); * } * } * return newScene; * }*/ /* * 0: pid; * 1: oid; * 2: age; * 3: centroid.x; * 4: centroid.y; * 5: velocity.x; * 6: velocity.y; * 7: depth; * 8: boundingRect.x; * 9: boundingRect.y; * 10: boundingRect.width; * 11: boundingRect.height; * 12: highest.x * 13: highest.y * 14: haarRect.x; - will be 0 if hasHaar == false * 15: haarRect.y; - will be 0 if hasHaar == false * 16: haarRect.width; - will be 0 if hasHaar == false * 17: haarRect.height; - will be 0 if hasHaar == false * 18: opticalFlowVectorAccumulation.x; * 19: opticalFlowVectorAccumulation.y; * 20+ : contours (if enabled) */ private void updatePerson(OpenTSPSPerson person, ArrayList args) { person.id = (int)args[0]; person.age = (int)args[2]; person.centroidX = (float)args[3]; person.centroidY = (float)args[4]; person.velocityX = (float)args[5]; person.velocityY = (float)args[6]; // person.depth = (float)args[7]; person.boundingRectOriginX = (float)args[8]; person.boundingRectOriginY = (float)args[9]; person.boundingRectSizeWidth = (float)args[10]; person.boundingRectSizeHeight = (float)args[11]; // TO-DO: Add in new properties /* person.highestX = (float)args[12]; * person.highestX = (float)args[13]; * person.haarX = (float)args[14]; * person.haarY = (float)args[15]; * person.haarWidth = (float)args[16]; * person.haarHeight = (float)args[17]; */ person.opticalFlowVelocityX = (float)args[18]; person.opticalFlowVelocityY = (float)args[19]; //TODO Track contours and add them to the person object //if (m->getNumArgs() > 20){ // contour.clear(); // for (int i = 20; i < m->getNumArgs(); i += 2){ // contour.push_back(ofPoint(m->getArgAsFloat(i), m->getArgAsFloat(i+1))); // } //} }
private OpenTSPSPerson addPerson(ArrayList args) { OpenTSPSPerson newPerson = new OpenTSPSPerson(); updatePerson(newPerson, args); people.Add(newPerson.id, newPerson); for (int i = 0; i < listeners.Count; i++) { OpenTSPSListener listener = (OpenTSPSListener)listeners[i]; if (listener != null) { listener.personEntered(newPerson); } } return(newPerson); }
private void processMessage(OSCMessage message) { string address = message.Address; ArrayList args = message.Values; if (address == "/TSPS/personEntered/") { addPerson(args); } else if (address == "/TSPS/personMoved/" || address == "/TSPS/personUpdated/") { int person_id = (int)args[0]; OpenTSPSPerson person = null; if (!people.ContainsKey(person_id)) { person = addPerson(args); } else { person = people[person_id]; updatePerson(person, args); for (int i = 0; i < listeners.Count; i++) { OpenTSPSListener listener = (OpenTSPSListener)listeners[i]; if (listener != null) { if (address == "/TSPS/personMoved/") { listener.personMoved(person); } else { listener.personUpdated(person); } } } } } else if (address == "/TSPS/personWillLeave/") { int person_id = (int)args[0]; if (people.ContainsKey(person_id)) { OpenTSPSPerson personToRemove = people[person_id]; people.Remove(person_id); for (int i = 0; i < listeners.Count; i++) { OpenTSPSListener listener = (OpenTSPSListener)listeners[i]; if (listener != null) { listener.personWillLeave(personToRemove); } } } } else if (address == "/TSPS/scene/") { //TODO //create a scene object that can store global optical flow //and scene time parameters //OpenTSPSScene scene = new OpenTSPSScene(); /*if (scene == null) * { * scene = addScene(args); * } * updateScene(scene, args); * for (int i = 0; i < listeners.Count; i++) { * OpenTSPSListener listener = (OpenTSPSListener)listeners[i]; * if (listener!=null){ * listener.sceneUpdated(scene); * } * }*/ } }