From de24dbb0ffc4b49e623f2014992914133dd631d4 Mon Sep 17 00:00:00 2001 From: Davis King Date: Wed, 20 Aug 2008 23:29:37 +0000 Subject: [PATCH] Fixed the serialization code for the kkmeans object so that it actually works. --HG-- extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402481 --- dlib/svm/kkmeans.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/dlib/svm/kkmeans.h b/dlib/svm/kkmeans.h index 03d4e6f6b..f455876c2 100644 --- a/dlib/svm/kkmeans.h +++ b/dlib/svm/kkmeans.h @@ -138,14 +138,27 @@ namespace dlib friend void serialize(const kkmeans& item, std::ostream& out) { - serialize(item.centers, out); + serialize(item.centers.size(),out); + for (unsigned long i = 0; i < item.centers.size(); ++i) + { + serialize(*item.centers[i], out); + } serialize(item.kc, out); serialize(item.assignments, out); } friend void deserialize(kkmeans& item, std::istream& in) { - deserialize(item.centers, in); + unsigned long num; + deserialize(num, in); + item.centers.expand(num); + for (unsigned long i = 0; i < item.centers.size(); ++i) + { + scoped_ptr > temp(new kcentroid(kernel_type())); + deserialize(*temp, in); + item.centers[i].swap(temp); + } + deserialize(item.kc, in); deserialize(item.assignments, in); }