Files
openvino/inference-engine/samples/common/format_reader/bmp.h
anikulk 83964338b0 Chromeos enabling (#4704)
* ChromeOS enabling changes in DLDT/OPENVINO

Changes for new activations
Enable Debug messages
Add exp activation files
Enable FP32 functions for newly added activations
Enable activation names in debug files
Modify Scale Factor calcuation

* Add support for SetState in GNAMemory

* Use rounding when changing the scale + switch to Elevoc's identity

* Merge branch 'private/kmagiers/GNAPlugin_Memory_layer_as_output' into 'master'

Input memory layer support in addOutput();

See merge request inference-engine/dldt!7016

* Porting Dldt to ChromeOS

Signed-off-by: Anisha Kulkarni <anisha.dattatraya.kulkarni@intel.com>

* Optimizations for builder & GNAPlugin

 - Optimize graph building addLayer
 - Cache Activation functions pwl
 - Use AVX/SSE intrinsics for Quantization
 - Add config to add Identity layer Scale Factor
 - Port Permute related changes, Permute
   operation is needed for Layer Normalization
   batching.
 - Additionally, enable Negetive Half Log
   Activation Layer

* Work Around for DivByN and permute

- Scale Factors need further tuning before
  the DivByN operation in GNA Layer Norm
- Work around for Permute

* BACKPORT:Enable CoreThreadingTestsWithIterations tests for GNA

Co-authored-by: Raviraj P Sitaram <raviraj.p.sitaram@intel.com>
Co-authored-by: Denis Orlov <denis.orlov@intel.com>
Co-authored-by: Smirnov, Eugene <eugene.smirnov@intel.com>
Co-authored-by: Anisha Kulkarni <anisha.dattatraya.kulkarni@intel.corp-partner.google.com>
2021-03-11 12:10:53 +03:00

76 lines
2.2 KiB
C++

// Copyright (C) 2018-2020 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
/**
* \brief BMP reader
* \file bmp.h
*/
#pragma once
#include <memory>
#include <string>
#include <format_reader.h>
#include "register.h"
namespace FormatReader {
/**
* \class BitMap
* \brief Reader for bmp files
*/
class BitMap : public Reader {
private:
static Register<BitMap> reg;
typedef struct BmpHeader{
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 BmpInfoHeader{
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;
}
void Release() noexcept override {
delete this;
}
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