comparing x,y, coordinates of blobs

Apr 9, 2009 at 6:34pm

comparing x,y, coordinates of blobs

I keep running into the same problem over and over. I have a cv.jit patch identifying blobs and their x,y coordinates. Then I want to make specific determinations about these blobs. For example, I want to find out if any of the blobs are within a certain radius. If I determine that blob 7 and 20 are within that radius, I want to compare those blobs and find their distance. But I need to keep them labeled and separate from each other. Inside the circle, they could become blob 1 and 2 instead of 7 and 20, but once inside the circle, they need to keep the same label. I would use route or a gate, but I don’t know how many total blobs I will have at any given time. I have tried putting them into a coll, but then all I do is dump them back out of the coll and it’s the same situation. Maybe I need something like dynamic route object. Any suggestions would be greatly appreciated. Here is an example patch that illustrates the problem.

{
“boxes” : [ {
"box" : {
"maxclass" : "comment",
"text" : "route is not ideal, because I would need to have too many outputs",
"linecount" : 3,
"id" : "obj-54",
"fontname" : "Arial",
"patching_rect" : [ 247.0, 542.0, 162.0, 48.0 ],
“fontsize” : 12.0,
“numinlets” : 1,
“numoutlets” : 0
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “route 0 1 2 3 4 5 6 7 8 9 10 11…”,
“id” : “obj-53″,
“outlettype” : [ "", "", "", "", "", "", "", "", "", "", "", "", "" ],
“fontname” : “Arial”,
“patching_rect” : [ 64.0, 546.0, 181.0, 20.0 ],
“fontsize” : 12.0,
“numinlets” : 1,
“numoutlets” : 13
}

}
, {
“box” : {
“maxclass” : “comment”,
“text” : “label”,
“id” : “obj-52″,
“fontname” : “Arial”,
“patching_rect” : [ 106.0, 148.0, 42.0, 20.0 ],
“fontsize” : 12.0,
“numinlets” : 1,
“numoutlets” : 0
}

}
, {
“box” : {
“maxclass” : “comment”,
“text” : “xy”,
“id” : “obj-51″,
“fontname” : “Arial”,
“patching_rect” : [ 45.0, 141.0, 33.0, 20.0 ],
“fontsize” : 12.0,
“numinlets” : 1,
“numoutlets” : 0
}

}
, {
“box” : {
“maxclass” : “comment”,
“text” : “if blob is in range, xy coordinates and label are output, how to keep the blobs labeled?”,
“linecount” : 4,
“id” : “obj-50″,
“fontname” : “Arial”,
“patching_rect” : [ 212.0, 453.0, 150.0, 62.0 ],
“fontsize” : 12.0,
“numinlets” : 1,
“numoutlets” : 0
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “unpack”,
“id” : “obj-49″,
“outlettype” : [ "int", "int" ],
“fontname” : “Arial”,
“patching_rect” : [ 67.0, 180.0, 49.0, 20.0 ],
“fontsize” : 12.0,
“numinlets” : 1,
“numoutlets” : 2
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “pack 0 0 0″,
“id” : “obj-48″,
“outlettype” : [ "" ],
“fontname” : “Arial”,
“patching_rect” : [ 46.0, 215.0, 66.0, 20.0 ],
“fontsize” : 12.0,
“numinlets” : 3,
“numoutlets” : 1
}

}
, {
“box” : {
“maxclass” : “comment”,
“text” : “scale of rectangle inscribed in circle”,
“linecount” : 4,
“id” : “obj-47″,
“fontname” : “Arial”,
“patching_rect” : [ 290.0, 114.0, 83.0, 62.0 ],
“fontsize” : 12.0,
“numinlets” : 1,
“numoutlets” : 0
}

}
, {
“box” : {
“maxclass” : “comment”,
“text” : “x,y coordinates of circle center”,
“linecount” : 4,
“id” : “obj-46″,
“fontname” : “Arial”,
“patching_rect” : [ 168.0, 240.0, 83.0, 62.0 ],
“fontsize” : 12.0,
“numinlets” : 1,
“numoutlets” : 0
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “r centroids”,
“id” : “obj-1″,
“outlettype” : [ "" ],
“fontname” : “Arial”,
“patching_rect” : [ 81.0, 93.0, 67.0, 20.0 ],
“fontsize” : 12.0,
“numinlets” : 0,
“numoutlets” : 1
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “jit.iter”,
“id” : “obj-68″,
“outlettype” : [ "", "", "" ],
“fontname” : “Arial”,
“patching_rect” : [ 84.0, 125.0, 41.0, 17.0 ],
“fontsize” : 9.0,
“numinlets” : 1,
“numoutlets” : 3
}

}
, {
“box” : {
“maxclass” : “comment”,
“text” : “from cv.jit.centroids”,
“id” : “obj-45″,
“fontname” : “Arial”,
“patching_rect” : [ 66.0, 70.0, 150.0, 20.0 ],
“fontsize” : 12.0,
“numinlets” : 1,
“numoutlets” : 0
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “gate”,
“id” : “obj-39″,
“outlettype” : [ "" ],
“fontname” : “Arial”,
“patching_rect” : [ 128.0, 502.0, 34.0, 20.0 ],
“fontsize” : 12.0,
“numinlets” : 2,
“numoutlets” : 1
}

}
, {
“box” : {
“maxclass” : “toggle”,
“id” : “obj-35″,
“outlettype” : [ "int" ],
“patching_rect” : [ 164.0, 470.0, 20.0, 20.0 ],
“numinlets” : 1,
“numoutlets” : 1
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “< ",
“id” : “obj-32″,
“outlettype” : [ "int" ],
“fontname” : “Arial”,
“patching_rect” : [ 157.0, 427.0, 32.5, 20.0 ],
“fontsize” : 12.0,
“numinlets” : 2,
“numoutlets” : 1
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “r plane1″,
“id” : “obj-22″,
“outlettype” : [ "" ],
“fontname” : “Arial”,
“patching_rect” : [ 201.0, 308.0, 54.0, 20.0 ],
“fontsize” : 12.0,
“numinlets” : 0,
“numoutlets” : 1
}

}
, {
“box” : {
“maxclass” : “flonum”,
“id” : “obj-15″,
“outlettype” : [ "float", "bang" ],
“fontname” : “Arial”,
“patching_rect” : [ 133.0, 381.0, 67.0, 20.0 ],
“fontsize” : 12.0,
“numinlets” : 1,
“numoutlets” : 2
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “vexpr $i1 – $i2″,
“id” : “obj-14″,
“outlettype” : [ "" ],
“fontname” : “Arial”,
“patching_rect” : [ 133.0, 340.0, 73.0, 18.0 ],
“fontsize” : 10.0,
“numinlets” : 2,
“numoutlets” : 1
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “cartopol”,
“id” : “obj-7″,
“outlettype” : [ "float", "float" ],
“fontname” : “Arial”,
“patching_rect” : [ 133.0, 360.0, 46.0, 18.0 ],
“fontsize” : 10.0,
“numinlets” : 2,
“numoutlets” : 2
}

}
, {
“box” : {
“maxclass” : “number”,
“id” : “obj-3″,
“outlettype” : [ "int", "bang" ],
“fontname” : “Arial”,
“patching_rect” : [ 287.0, 353.0, 50.0, 20.0 ],
“fontsize” : 12.0,
“numinlets” : 1,
“numoutlets” : 2
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “sqrt”,
“id” : “obj-2″,
“outlettype” : [ "float" ],
“fontname” : “Arial”,
“patching_rect” : [ 286.0, 321.0, 31.0, 20.0 ],
“fontsize” : 12.0,
“numinlets” : 1,
“numoutlets” : 1
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “+”,
“id” : “obj-18″,
“outlettype” : [ "int" ],
“fontname” : “Arial”,
“patching_rect” : [ 284.0, 295.0, 32.5, 20.0 ],
“fontsize” : 12.0,
“numinlets” : 2,
“numoutlets” : 1
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “*”,
“id” : “obj-17″,
“outlettype” : [ "int" ],
“fontname” : “Arial”,
“patching_rect” : [ 316.0, 274.0, 32.5, 20.0 ],
“fontsize” : 12.0,
“numinlets” : 2,
“numoutlets” : 1
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “*”,
“id” : “obj-16″,
“outlettype” : [ "int" ],
“fontname” : “Arial”,
“patching_rect” : [ 263.0, 276.0, 32.5, 20.0 ],
“fontsize” : 12.0,
“numinlets” : 2,
“numoutlets” : 1
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “* 480″,
“id” : “obj-11″,
“outlettype” : [ "int" ],
“fontname” : “Arial”,
“patching_rect” : [ 312.0, 249.0, 39.0, 20.0 ],
“fontsize” : 12.0,
“numinlets” : 2,
“numoutlets” : 1
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “* 240″,
“id” : “obj-10″,
“outlettype” : [ "int" ],
“fontname” : “Arial”,
“patching_rect” : [ 260.0, 254.0, 39.0, 20.0 ],
“fontsize” : 12.0,
“numinlets” : 2,
“numoutlets” : 1
}

}
, {
“box” : {
“maxclass” : “flonum”,
“id” : “obj-9″,
“outlettype” : [ "float", "bang" ],
“fontname” : “Arial”,
“patching_rect” : [ 274.0, 216.0, 48.0, 20.0 ],
“fontsize” : 12.0,
“numinlets” : 1,
“numoutlets” : 2
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “r scaleplane”,
“id” : “obj-6″,
“outlettype” : [ "" ],
“fontname” : “Arial”,
“patching_rect” : [ 271.0, 191.0, 75.0, 20.0 ],
“fontsize” : 12.0,
“numinlets” : 0,
“numoutlets” : 1
}

}
],
“lines” : [ {
"patchline" : {
"source" : [ "obj-68", 0 ],
“destination” : [ "obj-14", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-68", 1 ],
“destination” : [ "obj-48", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-68", 0 ],
“destination” : [ "obj-49", 0 ],
“hidden” : 0,
“midpoints” : [ 91.5, 172.0 ]
}

}
, {
“patchline” : {
“source” : [ "obj-48", 0 ],
“destination” : [ "obj-39", 1 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-49", 1 ],
“destination” : [ "obj-48", 2 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-49", 0 ],
“destination” : [ "obj-48", 1 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-1", 0 ],
“destination” : [ "obj-68", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-35", 0 ],
“destination” : [ "obj-39", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-22", 0 ],
“destination” : [ "obj-14", 1 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-32", 0 ],
“destination” : [ "obj-35", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-3", 0 ],
“destination” : [ "obj-32", 1 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-15", 0 ],
“destination” : [ "obj-32", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-7", 0 ],
“destination” : [ "obj-15", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-14", 0 ],
“destination” : [ "obj-7", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-2", 0 ],
“destination” : [ "obj-3", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-18", 0 ],
“destination” : [ "obj-2", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-9", 0 ],
“destination” : [ "obj-11", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-9", 0 ],
“destination” : [ "obj-10", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-10", 0 ],
“destination” : [ "obj-16", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-10", 0 ],
“destination” : [ "obj-16", 1 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-11", 0 ],
“destination” : [ "obj-17", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-11", 0 ],
“destination” : [ "obj-17", 1 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-6", 0 ],
“destination” : [ "obj-9", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-16", 0 ],
“destination” : [ "obj-18", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-17", 0 ],
“destination” : [ "obj-18", 1 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
]
}

#43288
Jun 5, 2009 at 3:50pm

hi,

I am working on a cv patch with similar issues. I see this is a somewhat older patch, so I guess I am hoping you might have found a solution to better tracking.

I am hoping I don’t have to make some sort of (zl nth) patching setup that pulls all of the cell rows out and then routes them.

One thing though that might be helpful for you is if you haven’t yet, I higly recomend the f0 objects. (Thats F (zero)) You pobably would find the f0.route_index which does the dynamic routing you are after. I guess it wouldn’t be too difficult to have a prepend object that is being dynamically set with a new id sent to the f0.route_index.

jon

#155238

You must be logged in to reply to this topic.