使用处理语言直观地表示XML.如何在数据结束/中断的每个点绘制椭圆



我参与了一个研究项目,分析建筑如何(如果有的话)影响人们在不同地点移动时的路径。到目前为止,我们已经使用OpenCV Blob跟踪器成功地生成了映射Blob移动时的XML文件数据。我现在想做的是,在数据开始和结束的每个点上画一个椭圆(表示每个人的开始和结束点)。对得出这一结论的任何帮助都是非常受欢迎的。

我也不太了解您提供的数据的结构。但在处理过程中,如果您想表示xml数据(特别是屏幕上的坐标位置和颜色时间),您首先需要解析xml文件,然后适当地映射值。看看

http://processing.org/reference/XMLElement.html

http://processing.org/reference/map_.html

http://processing.org/reference/fill_.html

这些应该有你需要的一切。

您可以这样做,将xml表示为省略号和颜色。假设这是你的xml,(我只是编的)

 <?xml version="1.0"?>
 <people>
   <person time="45.6" x="6.5" y="10.3"></person>
   ...
 </people>
XMLElement xml;
void setup() {
  size(200, 200);
  int size = 10; //just a default size for the ellipse, maybe you want to pull this value from your data as well though
  xml = new XMLElement(this, "people.xml");
  int numPeople = xml.getChildCount();
  for (int i = 0; i < numPeople; i++) {
    XMLElement person = xml.getChild(i);
    float time = person.getFloat("time"); 
    float xPos = person.getFloat("x"); 
    float yPos = person.getFloat("y"); 
    int personColor = map(time, 0, 100, 0, 255); //you will need some way of mapping your time values (i have no idea what the scale is, to a range of 0-255
    fill(personColor);
    ellipse(xPos, yPos, size, size);
  }
}

根据你提供的一系列数字,我猜你的xml结构比我在本例中提供的要复杂得多,如果你想帮助解析你的特定数据,请发布一个更完整的xml示例和描述。

最新更新