various code samples

#1

I got around to cleaning up and posting a couple of useful bits and pieces of code last week:

  • Movement along bezier curves
  • Contour analysis - ellipse fitting, point in polygon, line finding
  • Statistic recorder - a simple class for tracking running streams of data

Find everything here:
http://www.csugrue.com/code

hopefully more to come…

#2

Really great stuff chris! I’m a big fan of your projects and code examples =)

I noticed you posted an update version of Warp too. I saw you included the FBO classes, but they don’t seem to be used. Is that correct or am I missing something? I’ve been using your older Warp stuff on a project and was interested if you’ll be adding in the FBO stuff into your updated example.

Thanks and keep up the great work!

#3

mega nice !!! :smiley:

#4

Thanks, your blog is great, helped to get me going! These are great examples! :smiley:

#5

Hi Chris. Thanks for the code examples. I tried to get the FakeMultiTouchScreen example to compile on my mac with oF_005 but i failed. :slight_smile: Maybe somebody has a working xcode project?

Thanks a lot

stiwi

#6

this is amazing!!! thanks :slight_smile:

#7

i’m glad these are useful - post if you make some updates or nice additions to them!

stiwi - sorry yes, I still haven’t updated that code. it is from a really old release and it think quite a few things are broken on it… will try to fix that example this week.

cerupcat - ah, no i wasn’t using fbo’s in that example, perhaps I left it in by mistake…

#8

hey chris,

i’m just working through your super-useful contour analysis examples. do you know if there’s a method for creating a bounding rectangle (oriented to fit around the shape of the tracked object) instead of an ellipse?

thanks for these algorithms!

jeremy

#9

try:
http://opencvlibrary.sourceforge.net/Cv-…-a-contours

look for “CvBox2D”

note that from version to version of opencv they have changed angle from radians to degrees, so be careful :slight_smile:

  • zach
#10

nice!

i discovered cvMinAreaRect, which takes a list of contour points and outputs an rectangle that tightly hugs the blog … with an angle, centerpoint, width and height.

from there, it’s possible to get the coordinates of the enclosing rect using cvBoxPoints();

jeremy

here’s the code:

  
  
  
//-----------------------------------------  
void fitBox( vector <ofPoint>  & contour, CvBox2D32f & box)  
{  
  
	  
    CvPoint * pointArray = new CvPoint[contour.size()];  
  
    for( int i = 0; i < contour.size(); i++){  
  
    	pointArray[i].x = 	contour[i].x;  
    	pointArray[i].y =	contour[i].y;  
    }  
	  
	CvMat pointMat = cvMat( 1, contour.size(), CV_32SC2, pointArray);  
	  
	box = cvMinAreaRect2(&pointMat, 0);  
		  
	free(pointArray);  
}  
  
  

#11

ah yeah, that’s right box2d is what it returns… nice function there, thanks!

interesting, I was skimming through that section and there is a point in polygon test:
cvPointPolygonTest

I had no idea… we keep going back to paul bourke :slight_smile:

take care!

  • zach
#12

well, the nice thing about the paul bourke site is that each section contains an image describing the algorithm.

jeremy

#13

Are these still available somewhere?