setting ofxBox2d b2EdgeChainDef points and adding to world


I am currently trying to create a ofxBox2d b2EdgeChainDef and setting it’s vertices from a vector of points from a contour blob found using ofxOpenCV, then add it in the correct position in my ofxBox2d world and have it so it updates on each frame. The following code in my update() function compiles fine but when I run it, it always crashes and returns a debug error message:

b2EdgeChainDef edgeDef;		  
				vector<ofPoint> points = contourFinder.blobs[0].pts;				  
				edgeDef.vertices = new b2Vec2[points.size()];  
				for(int j=0; j < points.size(); j+=10){					  
				edgeDef.isALoop = true;  
				edgeDef.density = 3.0f;  
				edgeDef.restitution = 1.0f;  
				edgeDef.vertexCount = edgeDef.vertices->Length();  
				b2BodyDef bodyDef;  
				bodyDef.position.Set(10.0f, 4.0f);  
				b2Body* body =>CreateBody(&bodyDef);  
				delete [] edgeDef.vertices;    
				edgeDef.vertices = NULL;  

I’ve already seen but still cant get it working. Any help very much appreciated or ideally an example from someone has managed to do this!

Thanks, Adam