Commit 17565cfb authored by Davis King's avatar Davis King

Added serialization support for the rls, rls_filter, and kalman_filter objects.

parent 9802fe64
......@@ -82,6 +82,37 @@ namespace dlib
return xb;
}
friend inline void serialize(const kalman_filter& item, std::ostream& out)
{
int version = 1;
serialize(version, out);
serialize(item.got_first_meas, out);
serialize(item.x, out);
serialize(item.xb, out);
serialize(item.P, out);
serialize(item.H, out);
serialize(item.A, out);
serialize(item.Q, out);
serialize(item.R, out);
}
friend inline void deserialize(kalman_filter& item, std::istream& in)
{
int version = 0;
deserialize(version, in);
if (version != 1)
throw dlib::serialization_error("Unknown version number found while deserializing kalman_filter object.");
deserialize(item.got_first_meas, in);
deserialize(item.x, in);
deserialize(item.xb, in);
deserialize(item.P, in);
deserialize(item.H, in);
deserialize(item.A, in);
deserialize(item.Q, in);
deserialize(item.R, in);
}
private:
bool got_first_meas;
......
......@@ -6,6 +6,27 @@
namespace dlib
{
// ----------------------------------------------------------------------------------------
void serialize (
const kalman_filter& item,
std::ostream& out
);
/*!
provides serialization support
!*/
void deserialize (
kalman_filter& item,
std::istream& in
);
/*!
provides deserialization support
!*/
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_KALMAN_FiLTER_ABSTRACT_H__
......
......@@ -130,6 +130,31 @@ namespace dlib
return next;
}
friend inline void serialize(const rls_filter& item, std::ostream& out)
{
int version = 1;
serialize(version, out);
serialize(item.count, out);
serialize(item.size, out);
serialize(item.filter, out);
serialize(item.next, out);
serialize(item.data, out);
}
friend inline void deserialize(rls_filter& item, std::istream& in)
{
int version = 0;
deserialize(version, in);
if (version != 1)
throw dlib::serialization_error("Unknown version number found while deserializing rls_filter object.");
deserialize(item.count, in);
deserialize(item.size, in);
deserialize(item.filter, in);
deserialize(item.next, in);
deserialize(item.data, in);
}
private:
unsigned long count;
......
......@@ -70,6 +70,25 @@ namespace dlib
// ----------------------------------------------------------------------------------------
void serialize (
const rls_filter& item,
std::ostream& out
);
/*!
provides serialization support
!*/
void deserialize (
rls_filter& item,
std::istream& in
);
/*!
provides deserialization support
!*/
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_RLS_FiLTER_ABSTRACT_H__
......
......@@ -143,6 +143,29 @@ namespace dlib
return df;
}
friend inline void serialize(const rls& item, std::ostream& out)
{
int version = 1;
serialize(version, out);
serialize(item.w, out);
serialize(item.R, out);
serialize(item.C, out);
serialize(item.forget_factor, out);
}
friend inline void deserialize(rls& item, std::istream& in)
{
int version = 0;
deserialize(version, in);
if (version != 1)
throw dlib::serialization_error("Unknown version number found while deserializing rls object.");
deserialize(item.w, in);
deserialize(item.R, in);
deserialize(item.C, in);
deserialize(item.forget_factor, in);
}
private:
void add_eye_to_inv(
......
......@@ -133,6 +133,24 @@ namespace dlib
};
// ----------------------------------------------------------------------------------------
void serialize (
const rls& item,
std::ostream& out
);
/*!
provides serialization support
!*/
void deserialize (
rls& item,
std::istream& in
);
/*!
provides deserialization support
!*/
// ----------------------------------------------------------------------------------------
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment