Log images on the jevois.
This could fill up the sd card if we don't clean it periodically,
(~10000 images).
We should come up with a method/philosophy on cleaning it before merging
this in.
Change-Id: I5bd78d7a984f6e50352b8804a0c5e4f0a1d11e68
diff --git a/y2019/vision/image_writer.h b/y2019/vision/image_writer.h
new file mode 100644
index 0000000..3d0d934
--- /dev/null
+++ b/y2019/vision/image_writer.h
@@ -0,0 +1,39 @@
+#ifndef _Y2019_VISION_IMAGE_WRITER_H_
+#define _Y2019_VISION_IMAGE_WRITER_H_
+
+#include <string>
+
+#include "aos/logging/logging.h"
+#include "aos/vision/image/image_types.h"
+
+namespace y2019 {
+namespace vision {
+
+class ImageWriter {
+ public:
+ ImageWriter() {
+ LOG(INFO, "Initializing image writer\n");
+ SetDirPath();
+ }
+
+ // This is destructive to data.
+ void ProcessImage(::aos::vision::DataRef data, size_t num_targets);
+ private:
+ void SetDirPath();
+
+ void WriteImage(::aos::vision::DataRef data);
+
+ std::string file_prefix_ = std::string("debug_viewer_jpeg_");
+ std::string dir_path_;
+
+ size_t previous_num_targets_ = 0;
+ char previous_image_[640 * 480 * 2];
+
+ unsigned int image_count_ = 0;
+ unsigned int debounce_count_ = 0;
+};
+
+} // namespace vision
+} // namespace y2017
+
+#endif // _Y2019_VISION_IMAGE_WRITER_H_