Ejemplo n.º 1
0
/**
Constructor for filter_options, takes a name and a filter.
*/
filter_options::filter_options(const std::string name, rs2::process_interface& filter) :
    filter_name(name),
    filter(filter),
    is_enabled(true)
{
    const std::array<rs2_option, 3> possible_filter_options = {
        RS2_OPTION_FILTER_MAGNITUDE,
        RS2_OPTION_FILTER_SMOOTH_ALPHA,
        RS2_OPTION_FILTER_SMOOTH_DELTA
    };

    //Go over each filter option and create a slider for it
    for (rs2_option opt : possible_filter_options)
    {
        if (filter.supports(opt))
        {
            rs2::option_range range = filter.get_option_range(opt);
            supported_options[opt].range = range;
            supported_options[opt].value = range.def;
            supported_options[opt].is_int = filter_slider_ui::is_all_integers(range);
            supported_options[opt].description = filter.get_option_description(opt);
            std::string opt_name = rs2_option_to_string(opt);
            supported_options[opt].name = name + "_" + opt_name;
            std::string prefix = "Filter ";
            supported_options[opt].label = name + " " + opt_name.substr(prefix.length());
        }
    }
}
Ejemplo n.º 2
0
void playback_sensor::register_sensor_options(const device_serializer::sensor_snapshot& sensor_snapshot)
{
    auto options_snapshot = sensor_snapshot.get_sensor_extensions_snapshots().find(RS2_EXTENSION_OPTIONS);
    if (options_snapshot == nullptr)
    {
        LOG_WARNING("Recorded file does not contain sensor options");
        return;
    }
    auto options_api = As<options_interface>(options_snapshot);
    if (options_api == nullptr)
    {
        throw invalid_value_exception("Failed to get options interface from sensor snapshots");
    }

    for (int i = 0; i < static_cast<int>(RS2_OPTION_COUNT); i++)
    {
        auto option_id = static_cast<rs2_option>(i);
        try
        {
            if (options_api->supports_option(option_id))
            {
                auto&& option = options_api->get_option(option_id);
                float value = option.query();
                register_option(option_id, std::make_shared<const_value_option>(option.get_description(), option.query()));
                LOG_DEBUG("Registered " << rs2_option_to_string(option_id) << " for sensor " << m_sensor_id << " with value: " << option.query());
            }
        }
        catch (std::exception& e)
        {
            LOG_WARNING("Failed to register option " << option_id << ". Exception: " << e.what());
        }
    }
}
Ejemplo n.º 3
0
void URealSenseOption::QueryData()
{
	rs2::error_ref e;
	Name = uestr(rs2_option_to_string((rs2_option)Type));
	Description = uestr(rs2_get_option_description(RsOptions, (rs2_option)Type, &e));
	rs2_get_option_range(RsOptions, (rs2_option)Type, &Range.Min, &Range.Max, &Range.Step, &Range.Default, &e);
	QueryValue();
}
Ejemplo n.º 4
0
const char* librealsense::uvc_pu_option::get_description() const
{
    switch(_id)
    {
    case RS2_OPTION_BACKLIGHT_COMPENSATION: return "Enable / disable backlight compensation";
    case RS2_OPTION_BRIGHTNESS: return "UVC image brightness";
    case RS2_OPTION_CONTRAST: return "UVC image contrast";
    case RS2_OPTION_EXPOSURE: return "Controls exposure time of color camera. Setting any value will disable auto exposure";
    case RS2_OPTION_GAIN: return "UVC image gain";
    case RS2_OPTION_GAMMA: return "UVC image gamma setting";
    case RS2_OPTION_HUE: return "UVC image hue";
    case RS2_OPTION_SATURATION: return "UVC image saturation setting";
    case RS2_OPTION_SHARPNESS: return "UVC image sharpness setting";
    case RS2_OPTION_WHITE_BALANCE: return "Controls white balance of color image. Setting any value will disable auto white balance";
    case RS2_OPTION_ENABLE_AUTO_EXPOSURE: return "Enable / disable auto-exposure";
    case RS2_OPTION_ENABLE_AUTO_WHITE_BALANCE: return "Enable / disable auto-white-balance";
    case RS2_OPTION_POWER_LINE_FREQUENCY: return "Power Line Frequency";
    case RS2_OPTION_AUTO_EXPOSURE_PRIORITY: return "Limit exposure time when auto-exposure is ON to preserve constant fps rate";
    default: return rs2_option_to_string(_id);
    }
}
void FRealSenseInspectorCustomization::CustomizeDetails(IDetailLayoutBuilder& DetailLayout)
{
	SCOPED_PROFILER;
	REALSENSE_TRACE(TEXT("FRealSenseInspectorCustomization::CustomizeDetails"));

	if (!IRealSensePlugin::Get().GetContext()) return;

	DetailLayoutPtr = &DetailLayout;
	auto This = this;
	auto* Category = &DetailLayout.EditCategory("Hardware Inspector");
	auto ParentWindow = FSlateApplication::Get().FindBestParentWindowHandleForDialogs(nullptr);

	if (RsDevices->size() == 0)
	{
		UpdateDevices();
	}

	Category->AddCustomRow(FText::FromString(TEXT("Refresh")))
		.WholeRowContent()
		[
			SNew(SButton)
			.Text(FText::FromString(TEXT("Refresh")))
			.OnClicked_Lambda([This]()
			{
				This->UpdateDevices();
				This->DetailLayoutPtr->ForceRefreshDetails();
				return FReply::Handled();
			})
		]
	;

	for (auto Device : *RsDevices)
	{
		FString DevName = uestr(Device.get_info(RS2_CAMERA_INFO_NAME));
		FString DevSerial = uestr(Device.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER));
		auto* DeviceGroup = &Category->AddGroup(TEXT("Device"), FText::FromString(DevName));

		DeviceGroup->AddWidgetRow()
			.NameContent()
			[
				SNew(STextBlock)
				.Text(FText::FromString(TEXT("Serial Number")))
				.Font(IDetailLayoutBuilder::GetDetailFont())
			]
			.ValueContent()
			[
				SNew(STextBlock)
				.Text(FText::FromString(DevSerial))
				.Font(IDetailLayoutBuilder::GetDetailFont())
			]
		;

		DeviceGroup->AddWidgetRow()
			.NameContent()
			[
				SNew(SButton)
				.Text(FText::FromString(TEXT("Load preset")))
				.OnClicked_Lambda([This, Device, ParentWindow]()
				{
					FString Path;
					if (This->PickFile(Path, ParentWindow, TEXT("Select preset"), TEXT("Preset file|*.json")))
					{
						REALSENSE_TRACE(TEXT("Load preset %s"), *Path);
						if (URealSenseDevice::LoadPreset(Device.get().get(), Path))
						{
							This->UpdateDevices();
						}
					}
					return FReply::Handled();
				})
			]
		;

		DeviceGroup->AddWidgetRow()
			.NameContent()
			[
				SNew(SButton)
				.Text(FText::FromString(TEXT("Save preset")))
				.OnClicked_Lambda([This, Device, ParentWindow]()
				{
					FString Path;
					if (This->PickFile(Path, ParentWindow, TEXT("Select preset"), TEXT("Preset file|*.json"), true))
					{
						REALSENSE_TRACE(TEXT("Save preset %s"), *Path);
						URealSenseDevice::SavePreset(Device.get().get(), Path);
					}
					return FReply::Handled();
				})
			]
		;

		for (auto Sensor : Device.query_sensors())
		{
			FString SensorName = uestr(Sensor.get_info(RS2_CAMERA_INFO_NAME));
			auto* SensorGroup = &DeviceGroup->AddGroup(TEXT("Sensor"), FText::FromString(SensorName));

			for (int i = 0; i < RS2_OPTION_COUNT; ++i)
			{
				const rs2_option Option = (rs2_option)i;

				if (Sensor.supports(Option))
				{
					auto OptionName = uestr(rs2_option_to_string(Option));
					auto Range = Sensor.get_option_range(Option);

					auto UniqId = DevName + "_" + SensorName + "_" + OptionName;
					if (!ValueCache.Contains(UniqId))
					{
						auto Value = Sensor.get_option(Option);
						ValueCache.Add(UniqId, Value);
					}

					SensorGroup->AddWidgetRow()
						.NameContent()
						[
							SNew(STextBlock)
							.Text(FText::FromString(OptionName))
							.Font(IDetailLayoutBuilder::GetDetailFont())
						]
						.ValueContent()
						[
							SNew(SNumericEntryBox<float>)
							.MinValue(Range.min)
							.MinSliderValue(Range.min)
							.MaxValue(Range.max)
							.MaxSliderValue(Range.max)
							.AllowSpin(true)
							.Value_Lambda([This, UniqId]()
							{
								return This->ValueCache.Contains(UniqId) ? This->ValueCache[UniqId] : 0;
							})
							.OnValueChanged_Lambda([This, Sensor, Option, UniqId, Range](float NewValue)
							{
								NewValue = FMath::RoundToFloat(NewValue / Range.step) * Range.step;
								Sensor.set_option(Option, NewValue);
								if (This->ValueCache.Contains(UniqId)) This->ValueCache[UniqId] = NewValue; else This->ValueCache.Add(UniqId, NewValue);
							})
						]
					;
				}
			}
		}
	}
}