summaryrefslogtreecommitdiff
path: root/python/openvino/runtime/common/format_reader/bmp.h
diff options
context:
space:
mode:
authorEric Dao <eric@erickhangdao.com>2025-03-10 17:54:31 -0400
committerEric Dao <eric@erickhangdao.com>2025-03-10 17:54:31 -0400
commitab224e2e6ba65f5a369ec392f99cd8845ad06c98 (patch)
treea1e757e9341863ed52b8ad4c5a1c45933aab9da4 /python/openvino/runtime/common/format_reader/bmp.h
parent40da1752f2c8639186b72f6838aa415e854d0b1d (diff)
downloadthesis-master.tar.gz
thesis-master.tar.bz2
thesis-master.zip
completed thesisHEADmaster
Diffstat (limited to 'python/openvino/runtime/common/format_reader/bmp.h')
-rw-r--r--python/openvino/runtime/common/format_reader/bmp.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/python/openvino/runtime/common/format_reader/bmp.h b/python/openvino/runtime/common/format_reader/bmp.h
new file mode 100644
index 0000000..ac3ff31
--- /dev/null
+++ b/python/openvino/runtime/common/format_reader/bmp.h
@@ -0,0 +1,75 @@
+// Copyright (C) 2018-2022 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+/**
+ * \brief BMP reader
+ * \file bmp.h
+ */
+#pragma once
+
+#include <memory>
+#include <string>
+
+// clang-format off
+#include "format_reader.h"
+#include "register.h"
+// clang-format on
+
+namespace FormatReader {
+/**
+ * \class BitMap
+ * \brief Reader for bmp files
+ */
+class BitMap : public Reader {
+private:
+ static Register<BitMap> reg;
+
+ typedef struct BmpHeaderType {
+ unsigned short type = 0u; /* Magic identifier */
+ unsigned int size = 0u; /* File size in bytes */
+ unsigned int reserved = 0u;
+ unsigned int offset = 0u; /* Offset to image data, bytes */
+ } BmpHeader;
+
+ typedef struct BmpInfoHeaderType {
+ unsigned int size = 0u; /* Header size in bytes */
+ int width = 0, height = 0; /* Width and height of image */
+ unsigned short planes = 0u; /* Number of colour planes */
+ unsigned short bits = 0u; /* Bits per pixel */
+ unsigned int compression = 0u; /* Compression type */
+ unsigned int imagesize = 0u; /* Image size in bytes */
+ int xresolution = 0, yresolution = 0; /* Pixels per meter */
+ unsigned int ncolours = 0u; /* Number of colours */
+ unsigned int importantcolours = 0u; /* Important colours */
+ } BmpInfoHeader;
+
+public:
+ /**
+ * \brief Constructor of BMP reader
+ * @param filename - path to input data
+ * @return BitMap reader object
+ */
+ explicit BitMap(const std::string& filename);
+ virtual ~BitMap() {}
+
+ /**
+ * \brief Get size
+ * @return size
+ */
+ size_t size() const override {
+ return _width * _height * 3;
+ }
+
+ // langsu: ResizeType is a added by us to support custom resizing functions (only in opencv_wrapper).
+ // format_reader is copied from openvino samples/cpp/common/format_reader/
+ // this might need special care when doing a OV uplift
+ std::shared_ptr<unsigned char> getData(size_t width, size_t height, ResizeType resize_type) override {
+ if ((width * height != 0) && (_width * _height != width * height)) {
+ std::cout << "[ WARNING ] Image won't be resized! Please use OpenCV.\n";
+ return nullptr;
+ }
+ return _data;
+ }
+};
+} // namespace FormatReader