Files
openvino/samples/cpp/common/format_reader/bmp.h
T
5b25dbee22 ov2.0 IE samples modification (#8340)
* ov2.0 IE samples modification

apply code style

turn off clang style check for headers order

unify samples a bit

add yuv nv12 reader to format_reader, helloe_nv112 sample

hello_reshape_ssd ov2.0

* sync with PR 8629 preprocessing api changes

* fix for slog << vector<int>

* add operator<< for ov::Version from PR-8687

* Update samples/cpp/hello_nv12_input_classification/main.cpp

Co-authored-by: Mikhail Nosov <mikhail.nosov@intel.com>

* apply code style

* change according to review comments

* add const qualifier

* apply code style

* std::ostream for old inference engine version to make VPU plugin tests happy

* apply code style

* revert changes in print version for old api samples

* keep inference_engine.hpp for not ov2.0 yet samples

* fix merge artifacts

* fix compilation

* apply code style

* Fixed classification sample test

* Revert changes in hello_reshape_ssd sample

* rebase to master, sync with PR-9054

* fix issues found by C++ tests

* rebased and sync with PR-9051

* fix test result parsers for classification tests (except unicode one)

* fix mismatches after merge

* rebase and sync with PR-9144

Co-authored-by: Mikhail Nosov <mikhail.nosov@intel.com>
Co-authored-by: antonrom23 <anton.romanov@intel.com>
2021-12-13 11:30:58 +03:00

73 lines
2.1 KiB
C++

// Copyright (C) 2018-2021 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;
}
std::shared_ptr<unsigned char> getData(size_t width, size_t height) 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