MCPcopy Create free account
hub / github.com/davisking/dlib / chinese_whispers_raw

Function chinese_whispers_raw

tools/python/src/face_recognition.cpp:300–328  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

298}
299
300py::list chinese_whispers_raw(py::list edges)
301{
302 py::list clusters;
303 size_t num_edges = py::len(edges);
304
305 std::vector<sample_pair> edges_pairs;
306 std::vector<unsigned long> labels;
307 for (size_t idx = 0; idx < num_edges; ++idx)
308 {
309 py::tuple t = edges[idx].cast<py::tuple>();
310 if ((len(t) != 2) && (len(t) != 3))
311 {
312 PyErr_SetString( PyExc_IndexError, "Input must be a list of tuples with 2 or 3 elements.");
313 throw py::error_already_set();
314 }
315 size_t i = t[0].cast<size_t>();
316 size_t j = t[1].cast<size_t>();
317 double distance = (len(t) == 3) ? t[2].cast<double>(): 1;
318
319 edges_pairs.push_back(sample_pair(i, j, distance));
320 }
321
322 chinese_whispers(edges_pairs, labels);
323 for (size_t i = 0; i < labels.size(); ++i)
324 {
325 clusters.append(labels[i]);
326 }
327 return clusters;
328}
329
330void save_face_chips (
331 numpy_image<rgb_pixel> img,

Callers

nothing calls this directly

Calls 6

lenFunction · 0.85
chinese_whispersFunction · 0.85
sample_pairClass · 0.50
push_backMethod · 0.45
sizeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected