Skip to content
Snippets Groups Projects
channelUtils.hpp 1.12 KiB
Newer Older
/**
 * @file channelUtils.hpp
 * @copyright Copyright (c) 2020 University of Turku, MIT License
 * @author Nicolas Pope
 */

Nicolas Pope's avatar
Nicolas Pope committed
#pragma once

#include <string>
Nicolas Pope's avatar
Nicolas Pope committed
#include <ftl/protocol/channels.hpp>

namespace ftl {
namespace protocol {

inline bool isVideo(Channel c) { return static_cast<int>(c) < 32; }
inline bool isAudio(Channel c) { return static_cast<int>(c) >= 32 && static_cast<int>(c) < 64; }
inline bool isData(Channel c) { return static_cast<int>(c) >= 64; }
Nicolas Pope's avatar
Nicolas Pope committed

/** Obtain a string name for channel. */
std::string name(Channel c);

/**
 * @brief Get the channel ID from a name.
 * 
 * @param name 
 * @return Channel 
 */
Channel fromName(const std::string &name);

Nicolas Pope's avatar
Nicolas Pope committed
/** Obtain OpenCV type for channel. */
int type(Channel c);

/** @deprecated */
Nicolas Pope's avatar
Nicolas Pope committed
inline bool isFloatChannel(ftl::protocol::Channel chan) {
    switch (chan) {
Nicolas Pope's avatar
Nicolas Pope committed
    case Channel::kGroundTruth  :
    case Channel::kDepth        :
    case Channel::kConfidence   :
    case Channel::kFlow         :
    case Channel::kDensity      :
    case Channel::kEnergy       : return true;
    default                    : return false;
    }
Nicolas Pope's avatar
Nicolas Pope committed
}

}  // namespace protocol
}  // namespace ftl