IVTConverter.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 Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu)
20 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21 * GNU General Public License
22 */
23
24// STD/STL
25#include <numeric>
26
27// Header
28#include "IVTConverter.h"
29
31{
32 std::shared_ptr<CByteImage>
34 {
36
37 if (nav->getShape().size() != 3) // +1 for bytes per pixel
38 {
40 __PRETTY_FUNCTION__, "The size of an NDArray does not match.", nav->getPath());
41 }
42
43 auto dims = nav->getShape();
44
45 auto ret = std::make_shared<CByteImage>();
46
47 ret->Set(dims[0], dims[1], static_cast<CByteImage::ImageType>(std::stoi(nav->getType())));
48
49 memcpy(reinterpret_cast<unsigned char*>(ret->pixels),
50 nav->getData(),
51 std::accumulate(std::begin(dims), std::end(dims), 1, std::multiplies<int>()));
52
53 return ret;
54 }
55
57 ConvertFromCByteImage(const std::shared_ptr<CByteImage>& img)
58 {
59 // TODO:
60 return nullptr;
61 }
62} // namespace armarx::aron::data::converter
static std::shared_ptr< CByteImage > ConvertToCByteImage(const data::NDArrayPtr &)
A base class for aron exceptions.
Definition Exception.h:37
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
data::NDArrayPtr ConvertFromCByteImage(const std::shared_ptr< CByteImage > &img)
std::shared_ptr< NDArray > NDArrayPtr
Definition NDArray.h:46