2D Collision detection - irregular shapes (computer vision blobs)
in
Programming Questions
•
2 years ago
Hi,
I've been reading lots about collision detection on these forums, reading about box2d, fiscia, geomerative and others, but all the threads I find relate to collision detection of an unchanging vector shape.
My ultimate goal is to be able to test if a point in 2D space is within the bounds of an irregular polygon, whose size, shape and location is potentially changing 25 times a second.
Unrealistic? An approximation would do, maybe less prescision in the "bounding box" or updates at less than 25 frames a second.
The situation: I'm using the computer vision library Jmyron to do blob tracking, which is working very well. I can extract the blobs as the co-ordinates that form quads, co-ordinates that form vector shapes or as a list of "edge pixels".
The other half of my project is a really basic random particle system. Particles whizzing about with random directions and velocities. The idea is that these particles can't intersect with the blobs that Jmyron detects, so if a hand-shaped blob is detected, the particles will go anywhere around the "silhouette" of the hand, including between the fingers, but won't go inside the outline of the hand.
Crazy?
If anyone could point me in the right direction, I would be very grateful.
Here's a quick link to the fairly brief Jmyron reference:
http://webcamxtra.sourceforge.net/reference.shtml
Here's an image of the blob of a biro drawn as a vector (code below)
http://ilumos.co.uk/misc/blob_as_vector_outline.png
I've been reading lots about collision detection on these forums, reading about box2d, fiscia, geomerative and others, but all the threads I find relate to collision detection of an unchanging vector shape.
My ultimate goal is to be able to test if a point in 2D space is within the bounds of an irregular polygon, whose size, shape and location is potentially changing 25 times a second.
Unrealistic? An approximation would do, maybe less prescision in the "bounding box" or updates at less than 25 frames a second.
The situation: I'm using the computer vision library Jmyron to do blob tracking, which is working very well. I can extract the blobs as the co-ordinates that form quads, co-ordinates that form vector shapes or as a list of "edge pixels".
The other half of my project is a really basic random particle system. Particles whizzing about with random directions and velocities. The idea is that these particles can't intersect with the blobs that Jmyron detects, so if a hand-shaped blob is detected, the particles will go anywhere around the "silhouette" of the hand, including between the fingers, but won't go inside the outline of the hand.
Crazy?
If anyone could point me in the right direction, I would be very grateful.
Here's a quick link to the fairly brief Jmyron reference:
http://webcamxtra.sourceforge.net/reference.shtml
Here's an image of the blob of a biro drawn as a vector (code below)
http://ilumos.co.uk/misc/blob_as_vector_outline.png
- void drawGlobVectors() {
- stroke(0,150,0);
- fill(255,0,0,128);
- int[][][] list = m.globEdgePoints(30);//get the outlines
- for(int i=0;i<list.length;i++){
- beginShape();
- if(list[i]!=null){
- for(int ii=0;ii<list[i].length;ii++){
- vertex(list[i][ii][0],list[i][ii][1]);
- }
- }
- endShape();
- }
- }
1