I m not sure which is your final goal as amphetamachine said but a pretty common approach to detect shapes could be the use of cvFindContours which given a binary image and returns a set of CvContour (which in fact is a cvSeq). Binary image can be retrieved quite simple by thresholding the image (cvThreshold). Check out the contours.c example in the sample/ of opencv src directory. Check this link as well:
Noah (2009) opencv tutorial
this sample code will give you an general idea:
cvThreshold( g_gray, g_gray, g_thresh, 255, CV_THRESH_BINARY );
cvFindContours( g_gray, g_storage, &contours );
cvZero( g_gray );
if( contours ){
cvDrawContours(
g_gray,
contours,
cvScalarAll(255),
cvScalarAll(255),
100 );
}
cvShowImage( "Contours", g_gray );
Once you have an encoding of the contour you can use cvMatchShapes which take 2 contours and return a measure of similarity between these contours.
Hope this approach provide you a head start!