Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flatbuffers: selectable custom LUT files #334

Merged
merged 1 commit into from
Sep 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions assets/webconfig/content/json_api.html
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,14 @@ <h4 class="bs-main-text" data-i18n="conf_helptable_expl">Explanation</h4>
<input class="form-check-input" type="radio" name="hdrModeState" id="hdr_on_mode" value="1">
<label class="form-check-label" for="hdr_on_mode" data-i18n="general_btn_on"></label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="hdrModeState" id="hdr_border_mode" value="2">
<label class="form-check-label" for="hdr_border_mode" data-i18n="general_mode_border"></label>
</div>
</div>
</div>
<div class="row mt-1">
<div class="col-8 text-start">
<div class="input-group">
<span class="input-group-text mb-1" data-i18n="json_api_flatbuffers_user_lut"></span>
<input class="form-control mb-1" type="text" id="flatbuffersUserLut">
</div>
</div>
</div>
</div>
Expand Down
7 changes: 4 additions & 3 deletions assets/webconfig/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1120,8 +1120,7 @@
"json_api_effect_color_expl" : "Set desired color or effect for the active instance.",
"json_api_clear" : "Clear a priority",
"json_api_clear_expl" : "Clear priority from effects and preset colors.",
"json_api_hdr" : "HDR mode",
"json_api_hdr_expl" : "Turn on/off HDR tone mapping for USB grabber. 'Border mode' works only for MJPEG stream.",
"json_api_hdr" : "HDR mode",
"json_api_components_expl_multi":"You can run multiple commands with just one link. Maximum lenght is 2048 chars. They all will be executed but you will receive only one response (check out logs for all the output). Just put your links' <code>request</code> content into the format (note first '?' char and next '&' chars):<br><code>http://IP:PORT/json-rpc?request=request1&request=request2&request=request3...</code>",
"edt_conf_stream_autoResume_title" : "Auto resume",
"edt_conf_stream_autoResume_expl" : "Try restarting video capture if the video stream stops. Use with caution as it is not a cure for hardware problems of the grabber.",
Expand Down Expand Up @@ -1176,5 +1175,7 @@
"edt_conf_mqtt_is_ssl_title" : "SSL",
"edt_conf_mqtt_is_ssl_expl" : "Use SSL protocol",
"edt_conf_mqtt_ssl_ignore_errors_title" : "Ignore SSL errors",
"edt_conf_mqtt_ssl_ignore_errors_expl" : "Ignore all SSL errors such as self-signed certificates etc. Use with caution."
"edt_conf_mqtt_ssl_ignore_errors_expl" : "Ignore all SSL errors such as self-signed certificates etc. Use with caution.",
"json_api_flatbuffers_user_lut" : "Flatbuffers LUT filename",
"json_api_hdr_expl" : "Turn on/off HDR tone mapping. You can also pass the name of the user LUT file in the user HyperHDR home folder to be used for Flatbuffers tone mapping."
}
12 changes: 7 additions & 5 deletions assets/webconfig/js/json_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,26 +515,28 @@ function BuildClearJson()
var componentHdr =
`{
"command":"videomodehdr",
"HDR":{0}
"HDR":{0},
"flatbuffers_user_lut_filename":"{1}"
}`;

$('input[name="hdrModeState"]').change(
$('input[name="hdrModeState"], #flatbuffersUserLut').change(
function(){
if ($("input[name='hdrModeState']:checked").val())
{
BuildHdrJson();
}
});


function BuildHdrJson()
{
$('button[name="hdrModeButtons"]').each(function(i, obj) {
$(this).removeClass('disabled');
});

var state = $('input[name="hdrModeState"]:checked').val();
var finJson = componentHdr.replace("{0}", state);
var state = $('input[name="hdrModeState"]:checked').val();
var flatbufferUserLut = $('#flatbuffersUserLut').val();
var finJson = componentHdr.replace("{0}", state).replace("{1}", flatbufferUserLut);

$("#hdrMode_json").html(finJson);
}
////////////////////////////////////////////////////////////////////////////////
Expand Down
6 changes: 6 additions & 0 deletions include/api/API.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ class API : public QObject
///
void setVideoModeHdr(int hdr, hyperhdr::Components callerComp = hyperhdr::COMP_INVALID);

///
/// @brief Set user LUT filename for flatbuffers tone mapping
/// @param userLUTfile user LUT filename
///
void setFlatbufferUserLUT(QString userLUTfile);

///
/// @brief Set an effect
/// @param dat The effect data
Expand Down
3 changes: 3 additions & 0 deletions include/flatbufserver/FlatBufferServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public slots:

void initServer();

void setUserLut(QString filename);

void setHdrToneMappingEnabled(int mode);

int getHdrToneMappingEnabled();
Expand Down Expand Up @@ -105,4 +107,5 @@ private slots:
uint8_t* _lutBuffer;
bool _lutBufferInit;
QString _configurationPath;
QString _userLutFile;
};
6 changes: 6 additions & 0 deletions sources/api/API.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ void API::setVideoModeHdr(int hdr, hyperhdr::Components callerComp)
QMetaObject::invokeMethod(FlatBufferServer::getInstance(), "setHdrToneMappingEnabled", Qt::QueuedConnection, Q_ARG(int, hdr));
}

void API::setFlatbufferUserLUT(QString userLUTfile)
{
if (FlatBufferServer::getInstance() != nullptr)
QMetaObject::invokeMethod(FlatBufferServer::getInstance(), "setUserLut", Qt::QueuedConnection, Q_ARG(QString, userLUTfile));
}

bool API::setEffect(const EffectCmdData& dat, hyperhdr::Components callerComp)
{
int res;
Expand Down
4 changes: 4 additions & 0 deletions sources/api/JSONRPC_schema/schema-videomodehdr.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
"minimum" : 0,
"maximum" : 2,
"required": true
},
"flatbuffers_user_lut_filename": {
"type" : "string",
"required": false
}
},
"additionalProperties": false
Expand Down
5 changes: 5 additions & 0 deletions sources/api/JsonAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,11 @@ void JsonAPI::handleProcessingCommand(const QJsonObject& message, const QString&

void JsonAPI::handleVideoModeHdrCommand(const QJsonObject& message, const QString& command, int tan)
{
if (message.contains("flatbuffers_user_lut_filename"))
{
API::setFlatbufferUserLUT(message["flatbuffers_user_lut_filename"].toString(""));
}

API::setVideoModeHdr(message["HDR"].toInt());
sendSuccessReply(command, tan);
}
Expand Down
15 changes: 15 additions & 0 deletions sources/flatbufserver/FlatBufferServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ FlatBufferServer::FlatBufferServer(const QJsonDocument& config, const QString& c
, _lutBuffer(nullptr)
, _lutBufferInit(false)
, _configurationPath(configurationPath)
, _userLutFile("")
{
FlatBufferServer::instance = this;
}
Expand Down Expand Up @@ -240,6 +241,13 @@ void FlatBufferServer::loadLutFile()
files.append(fileName3);
#endif

if (!_userLutFile.isEmpty())
{
QString userFile = QString("%1/%2").arg(_configurationPath).arg(_userLutFile);
files.prepend(userFile);
Debug(_log, "Adding user LUT file for searching: %s", QSTRING_CSTR(userFile));
}

_lutBufferInit = false;

if (_hdrToneMappingMode)
Expand Down Expand Up @@ -295,3 +303,10 @@ void FlatBufferServer::importFromProtoHandler(int priority, int duration, const

emit GlobalSignals::getInstance()->setGlobalImage(priority, image, duration);
}

void FlatBufferServer::setUserLut(QString filename)
{
_userLutFile = filename.replace("~", "").replace("/","").replace("..", "");

Info(_log, "Setting user LUT filename to: '%s'", QSTRING_CSTR(_userLutFile));
}