blob: 99fc573a28f23dc697565939c25a0fb48946859f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
// Copyright (C) 2018-2022 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
/**
* \brief Format reader abstract class implementation
* \file format_reader.h
*/
#pragma once
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#if defined(_WIN32)
# ifdef IMPLEMENT_FORMAT_READER
# define FORMAT_READER_API(type) extern "C" __declspec(dllexport) type
# else
# define FORMAT_READER_API(type) extern "C" type
# endif
#elif (__GNUC__ >= 4)
# ifdef IMPLEMENT_FORMAT_READER
# define FORMAT_READER_API(type) extern "C" __attribute__((visibility("default"))) type
# else
# define FORMAT_READER_API(type) extern "C" type
# endif
#else
# define FORMAT_READER_API(TYPE) extern "C" TYPE
#endif
namespace FormatReader {
/**
* \class FormatReader
* \brief This is an abstract class for reading input data
*/
class Reader {
protected:
/// \brief height
size_t _height = 0;
/// \brief width
size_t _width = 0;
/// \brief data
std::shared_ptr<unsigned char> _data;
public:
virtual ~Reader() = default;
// 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
enum ResizeType {
RESIZE, // resize the image to target (height, width)
PAD_RESIZE, // pad the image into a squared image and then resize the image to target (height, width)
};
/**
* \brief Get width
* @return width
*/
size_t width() const {
return _width;
}
/**
* \brief Get height
* @return height
*/
size_t height() const {
return _height;
}
/**
* \brief Get input data ptr
* @return shared pointer with input data
* @In case of using OpenCV, parameters width and height will be used for image resizing
*/
// langsu: ResizeType is a added by us to support custom resizing functions (only in opencv_wrapper).
// Needs special care when doing a OV uplift
virtual std::shared_ptr<unsigned char> getData(size_t width = 0, size_t height = 0,
ResizeType resize_type = ResizeType::RESIZE) = 0;
/**
* \brief Get size
* @return size
*/
virtual size_t size() const = 0;
};
} // namespace FormatReader
/**
* \brief Function for create reader
* @return FormatReader pointer
*/
FORMAT_READER_API(FormatReader::Reader*) CreateFormatReader(const char* filename);
|