Turi Create  4.0
PortableImage.hpp
1 /* Copyright © 2020 Apple Inc. All rights reserved.
2  *
3  * Use of this source code is governed by a BSD-3-clause license that can
4  * be found in the LICENSE.txt file or at
5  * https://opensource.org/licenses/BSD-3-Clause
6  */
7 
8 #pragma once
9 
10 #include <core/data/image/image_type.hpp>
11 #include <ml/neural_net/Image.hpp>
12 
13 namespace turi {
14 namespace neural_net {
15 
16 /// Concrete implementation of the Image interface that wraps the portable
17 /// image_type class.
18 class PortableImage : public Image {
19  public:
20  explicit PortableImage(image_type impl);
21  explicit PortableImage(const std::string& path);
22 
23  // Copyable and movable.
26  PortableImage& operator=(const PortableImage&);
27  PortableImage& operator=(PortableImage&&);
28 
29  ~PortableImage() override;
30 
31  size_t Height() const override;
32  size_t Width() const override;
33  void WriteCHW(Span<float> buffer) const override;
34  void WriteHWC(Span<float> buffer) const override;
35 
36  private:
37  image_type impl_;
38 };
39 
40 } // namespace neural_net
41 } // namespace turi
size_t Height() const override
The number of rows of pixels.
void WriteCHW(Span< float > buffer) const override
void WriteHWC(Span< float > buffer) const override
Abstract interface for images that a training pipeline can consume.
Definition: Image.hpp:19
size_t Width() const override
The number of columns of pixels.