summaryrefslogtreecommitdiffstats
path: root/ml/dlib/tools/python/src/serialize_object_detector.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-03-09 13:19:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-03-09 13:20:02 +0000
commit58daab21cd043e1dc37024a7f99b396788372918 (patch)
tree96771e43bb69f7c1c2b0b4f7374cb74d7866d0cb /ml/dlib/tools/python/src/serialize_object_detector.h
parentReleasing debian version 1.43.2-1. (diff)
downloadnetdata-58daab21cd043e1dc37024a7f99b396788372918.tar.xz
netdata-58daab21cd043e1dc37024a7f99b396788372918.zip
Merging upstream version 1.44.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--ml/dlib/tools/python/src/serialize_object_detector.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/ml/dlib/tools/python/src/serialize_object_detector.h b/ml/dlib/tools/python/src/serialize_object_detector.h
new file mode 100644
index 000000000..e53401c81
--- /dev/null
+++ b/ml/dlib/tools/python/src/serialize_object_detector.h
@@ -0,0 +1,49 @@
+// Copyright (C) 2014 Davis E. King (davis@dlib.net)
+// License: Boost Software License See LICENSE.txt for the full license.
+#ifndef DLIB_SERIALIZE_OBJECT_DETECTOR_H__
+#define DLIB_SERIALIZE_OBJECT_DETECTOR_H__
+
+#include "simple_object_detector_py.h"
+
+namespace dlib
+{
+ inline void serialize (const dlib::simple_object_detector_py& item, std::ostream& out)
+ {
+ int version = 1;
+ serialize(item.detector, out);
+ serialize(version, out);
+ serialize(item.upsampling_amount, out);
+ }
+
+ inline void deserialize (dlib::simple_object_detector_py& item, std::istream& in)
+ {
+ int version = 0;
+ deserialize(item.detector, in);
+ deserialize(version, in);
+ if (version != 1)
+ throw dlib::serialization_error("Unexpected version found while deserializing a simple_object_detector.");
+ deserialize(item.upsampling_amount, in);
+ }
+
+ inline void save_simple_object_detector_py(const simple_object_detector_py& detector, const std::string& detector_output_filename)
+ {
+ std::ofstream fout(detector_output_filename.c_str(), std::ios::binary);
+ int version = 1;
+ serialize(detector.detector, fout);
+ serialize(version, fout);
+ serialize(detector.upsampling_amount, fout);
+ }
+
+// ----------------------------------------------------------------------------------------
+
+ inline void save_simple_object_detector(const simple_object_detector& detector, const std::string& detector_output_filename)
+ {
+ std::ofstream fout(detector_output_filename.c_str(), std::ios::binary);
+ serialize(detector, fout);
+ // Don't need to save version of upsampling amount because want to write out the
+ // object detector just like the C++ code that serializes an object_detector would.
+ // We also don't know the upsampling amount in this case anyway.
+ }
+}
+
+#endif // DLIB_SERIALIZE_OBJECT_DETECTOR_H__