c - grouping motion vectors -
i using -lucas-kanade algorithm calculate optical flow of video sequences opencv. got motion vectors. want group motion vectors in clusters. vectors near each other want group them together. thing nearest neighbor approach. don't know how can implement same. appreciated.
thank you.
i used cvkmeans2() group corner points after running optical flow algorithm...
i have clusters in vector of vectors clustercontainer. want draw boundary line around every clusters..i not sure how can so...if knows please help.
using below code opencv manual draw circle around every cluster..but want draw rectangle rather circle..any body please me.
for(int h = 0; h < clustercontainer.size(); h++ ) { cvpoint pt1,pt2; cvmat box[100]; pt1.x=(int)points->data.fl[h*2]; pt1.y=(int)points->data.fl[h*2+1]; cvcircle( frame1, pt1, 20, cv_rgb(255,255,0),4); } 
to obtain bounding rectangle set of points, can use opencv boundingrect() function. note similar fitellipse() function.
boundingrect
calculates up-right bounding rectangle of point set.
c++: rect boundingrect(inputarray points) python: cv2.boundingrect(points) → retval c: cvrect cvboundingrect(cvarr* points, int update=0 ) python: cv.boundingrect(points, update=0) → cvrect parameters: points – input 2d point set, stored in std::vector or mat.
function calculates , returns minimal up-right bounding rectangle specified point set.
fitellipse
fits ellipse around set of 2d points.
c++: rotatedrect fitellipse(inputarray points) python: cv2.fitellipse(points) → retval c: cvbox2d cvfitellipse2(const cvarr* points) python: cv.fitellipse2(points) → box2d parameters: points – input 2d point set, stored in:
std::vector<> or mat (c++ interface) cvseq* or cvmat* (c interface) nx2 numpy array (python interface) the function calculates ellipse fits (in least-squares sense) set of 2d points best of all. returns rotated rectangle in ellipse inscribed. algorithm [fitzgibbon95] used.
Comments
Post a Comment