samples/cpp/kmeans.cpp
Примеры с cv2.imshow требуют сборки OpenCV с GUI. В ноутбуке с headless-версией используйте вывод изображений через Matplotlib.
Loading...
Searching...
No Matches
samples/cpp/kmeans.cpp
An example on k-means clustering
#include "opencv2/highgui.hpp"
#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
#include <iostream>
using namespace cv;
using namespace std;
// static void help()
// {
// cout << "\nThis program demonstrates kmeans clustering.\n"
// "It generates an image with random points, then assigns a random number of cluster\n"
// "centers and uses kmeans to move those cluster centers to their representative location\n"
// "Call\n"
// "./kmeans\n" << endl;
( , ** )
{
= ;
[] =
{
(, , ),
(,,),
(,,),
(,,),
(,,)
};
(, , );
();
(;;)
{
, = .(, +);
, = .(, );
(, , ), ;
= (, );
::<> ;
( = ; < ; ++ )
{
;
. = .(, .);
. = .(, .);
= .(*/,
== - ? :
(+)*/);
.(, ::, (., .), (.*, .*));
}
(, , &);
= (, , ,
( ::+::, , ),
, , );
= ::();
( = ; < ; ++ )
{
= .<>();
= .<>();
( , , , [], , );
}
( = ; < ().(); ++)
{
= [];
( , , , [], , );
}
<< << << ;
(, );
= ()();
( == || == || == )
;
}
;
}