Program Listing for File v4l2exposuretype.h
↰ Return to documentation for file (include/holoscan/operators/v4l2_video_capture/v4l2exposuretype.h
)
/*
* SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef HOLOSCAN_OPERATORS_V4L2_VIDEO_CAPTURE_V4L2_EXPOSURE_TYPE_HPP
#define HOLOSCAN_OPERATORS_V4L2_VIDEO_CAPTURE_V4L2_EXPOSURE_TYPE_HPP
#include <linux/videodev2.h>
#include <yaml-cpp/yaml.h>
#include <sstream>
#include <string>
template <>
struct YAML::convert<v4l2_exposure_auto_type> {
static Node encode(const v4l2_exposure_auto_type& rhs) {
Node node;
auto type = static_cast<int>(rhs);
std::stringstream ss;
switch (type) {
case 0:
ss << "V4L2_EXPOSURE_AUTO";
break;
case 1:
ss << "V4L2_EXPOSURE_MANUAL";
break;
case 2:
ss << "V4L2_EXPOSURE_SHUTTER_PRIORITY";
break;
case 3:
ss << "V4L2_EXPOSURE_APERTURE_PRIORITY";
break;
default:
ss << "V4L2_EXPOSURE_APERTURE_PRIORITY";
break;
}
node.push_back(ss.str());
YAML::Node value_node = node[0];
return value_node;
}
static bool decode(const Node& node, v4l2_exposure_auto_type& rhs) {
if (!node.IsScalar()) { return false; }
auto value = node.as<std::string>();
if (value == "V4L2_EXPOSURE_AUTO") {
rhs = V4L2_EXPOSURE_AUTO;
} else if (value == "V4L2_EXPOSURE_MANUAL") {
rhs = V4L2_EXPOSURE_MANUAL;
} else if (value == "V4L2_EXPOSURE_SHUTTER_PRIORITY") {
rhs = V4L2_EXPOSURE_SHUTTER_PRIORITY;
} else if (value == "V4L2_EXPOSURE_APERTURE_PRIORITY") {
rhs = V4L2_EXPOSURE_APERTURE_PRIORITY;
} else {
return false;
}
return true;
}
};
#endif/* HOLOSCAN_OPERATORS_V4L2_VIDEO_CAPTURE_V4L2_EXPOSURE_TYPE_HPP */