You must convert OpenGL data to OpenCV structures. OpenCV has built-in functions for exchanging data, see here . You can also copy OpenGL points into an OpenCV Mat or an OpenCV vector cv::Point3f . How to do this depends on the OpenGL structure in which your points are represented. If you need to convert matrices from OpenGL to OpenCV, keep in mind that OpenGL stores matrices in the main column order, whereas OpenCV does row ordering.
OpenCV then provides some (limited) cluster solutions . Depending on your application, k-tools may work, but I would suggest you also look at other clustering methods such as QuickShift or DBSCAN.
source share