Turi Create  4.0
CoreImageImage.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 <ml/neural_net/Image.hpp>
11 
12 #import <CoreImage/CoreImage.h>
13 
14 namespace turi {
15 namespace neural_net {
16 
17 /// Concrete implementation of the Image interface that wraps a CIImage.
18 class CoreImageImage : public Image {
19  public:
20  explicit CoreImageImage(CIImage* impl);
21  explicit CoreImageImage(const std::string& path);
22 
23  // Copyable and movable.
26  CoreImageImage& operator=(const CoreImageImage&);
27  CoreImageImage& operator=(CoreImageImage&&);
28 
29  ~CoreImageImage() override;
30 
31  CIImage* AsCIImage() const { return impl_; }
32 
33  size_t Height() const override;
34  size_t Width() const override;
35  void WriteCHW(Span<float> buffer) const override;
36  void WriteHWC(Span<float> buffer) const override;
37 
38  private:
39  CIImage* impl_ = nil;
40 };
41 
42 } // namespace neural_net
43 } // namespace turi
void WriteHWC(Span< float > buffer) const override
size_t Height() const override
The number of rows of pixels.
Abstract interface for images that a training pipeline can consume.
Definition: Image.hpp:19
Concrete implementation of the Image interface that wraps a CIImage.
size_t Width() const override
The number of columns of pixels.
void WriteCHW(Span< float > buffer) const override