Image.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T),
5  * Karlsruhe Institute of Technology (KIT), all rights reserved.
6  *
7  * ArmarX is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  *
11  * ArmarX is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * @author Rainer Kartmann (rainer dot kartmann at kit dot edu)
20  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21  * GNU General Public License
22  */
23 
24 #include "Image.h"
25 
26 #include <SimoxUtility/algorithm/string.h>
27 #include <SimoxUtility/meta/EnumNames.hpp>
28 
30 
31 namespace armarx::aron::type
32 {
33  const std::map<image::PixelType, std::string> Image::Pixeltype2String{
34  {image::PixelType::RGB24, "RGB24"},
35  {image::PixelType::DEPTH32, "DEPTH32"}};
36  const std::map<std::string, image::PixelType> Image::String2Pixeltype =
37  conversion::util::InvertMap(Pixeltype2String);
38 
39  // constructors
40  Image::Image(const Path& path) :
41  detail::NDArrayVariant<type::dto::Image, Image>(type::Descriptor::IMAGE, path)
42  {
43  }
44 
45  Image::Image(const type::dto::Image& o, const Path& path) :
46  detail::NDArrayVariant<type::dto::Image, Image>(o, type::Descriptor::IMAGE, path)
47  {
48  }
49 
52  {
53  return this->aron;
54  }
55 
56  image::PixelType
58  {
59  return aron->pixelType;
60  }
61 
62  void
63  Image::setPixelType(const image::PixelType pixelType) const
64  {
65  aron->pixelType = pixelType;
66  }
67 
68  // virtual implementations
69  std::string
71  {
72  return "Image";
73  }
74 
75  std::string
77  {
78  return "armarx::aron::type::Image<" + Pixeltype2String.at(this->aron->pixelType) + ">";
79  }
80 } // namespace armarx::aron::type
armarx::aron::type::Descriptor::IMAGE
@ IMAGE
armarx::aron::type::ImagePtr
std::shared_ptr< class Image > ImagePtr
Definition: forward_declarations.h:22
detail
Definition: OpenCVUtil.cpp:127
armarx::aron::type::Image::toImageDTO
type::dto::ImagePtr toImageDTO() const
Definition: Image.cpp:51
armarx::aron::type::Image::getShortName
std::string getShortName() const override
get a short name of this specific type
Definition: Image.cpp:70
armarx::aron::Path
The Path class.
Definition: Path.h:36
armarx::aron::type::Image::getFullName
std::string getFullName() const override
get the full name of this specific type
Definition: Image.cpp:76
armarx::aron::conversion::util::InvertMap
std::map< T2, T1 > InvertMap(const std::map< T1, T2 > &m)
Definition: Descriptor.h:42
armarx::aron::type::detail::SpecializedVariantBase< type::dto::Image, Image >::aron
type::dto::Image ::PointerType aron
Definition: SpecializedVariant.h:137
armarx::aron::type
A convenience header to include all aron files (full include, not forward declared)
Definition: aron_conversions.cpp:9
armarx::aron::type::Image::setPixelType
void setPixelType(const image::PixelType type) const
Definition: Image.cpp:63
armarx::aron::type::Image::getPixelType
image::PixelType getPixelType() const
Get the pixel type.
Definition: Image.cpp:57
Exception.h
Image.h
armarx::aron::type::Image::Pixeltype2String
static const std::map< image::PixelType, std::string > Pixeltype2String
Definition: Image.h:56
armarx::aron::type::Image
The Image class.
Definition: Image.h:39
armarx::aron::type::Descriptor
Descriptor
Definition: Descriptor.h:76
armarx::aron::type::Image::Image
Image(const Path &path={})
Definition: Image.cpp:40
armarx::aron::type::Image::String2Pixeltype
static const std::map< std::string, image::PixelType > String2Pixeltype
Definition: Image.h:57