Allow configuring the webcam stream's aspect ratio
Options are 16:9 and 4:3, 16:9 is the default.
This commit is contained in:
parent
c844217f82
commit
399ec5a909
7 changed files with 23 additions and 1 deletions
|
|
@ -98,6 +98,7 @@ def getSettings():
|
|||
},
|
||||
"webcam": {
|
||||
"streamUrl": s.get(["webcam", "stream"]),
|
||||
"streamRatio": s.get(["webcam", "streamRatio"]),
|
||||
"snapshotUrl": s.get(["webcam", "snapshot"]),
|
||||
"ffmpegPath": s.get(["webcam", "ffmpeg"]),
|
||||
"bitrate": s.get(["webcam", "bitrate"]),
|
||||
|
|
@ -299,6 +300,7 @@ def _saveSettings(data):
|
|||
|
||||
if "webcam" in data.keys():
|
||||
if "streamUrl" in data["webcam"]: s.set(["webcam", "stream"], data["webcam"]["streamUrl"])
|
||||
if "streamRatio" in data["webcam"] and data["webcam"]["streamRatio"] in ("16:9", "4:3"): s.set(["webcam", "streamRatio"], data["webcam"]["streamRatio"])
|
||||
if "snapshotUrl" in data["webcam"]: s.set(["webcam", "snapshot"], data["webcam"]["snapshotUrl"])
|
||||
if "ffmpegPath" in data["webcam"]: s.set(["webcam", "ffmpeg"], data["webcam"]["ffmpegPath"])
|
||||
if "bitrate" in data["webcam"]: s.set(["webcam", "bitrate"], data["webcam"]["bitrate"])
|
||||
|
|
|
|||
|
|
@ -155,6 +155,7 @@ default_settings = {
|
|||
},
|
||||
"webcam": {
|
||||
"stream": None,
|
||||
"streamRatio": "16:9",
|
||||
"snapshot": None,
|
||||
"ffmpeg": None,
|
||||
"ffmpegThreads": 1,
|
||||
|
|
|
|||
|
|
@ -49,6 +49,14 @@ $(function() {
|
|||
return self.keycontrolActive() && self.keycontrolPossible();
|
||||
});
|
||||
|
||||
self.webcamRatioClass = ko.pureComputed(function() {
|
||||
if (self.settings.webcam_streamRatio() == "4:3") {
|
||||
return "ratio43";
|
||||
} else {
|
||||
return "ratio169";
|
||||
}
|
||||
});
|
||||
|
||||
self.settings.printerProfiles.currentProfileData.subscribe(function () {
|
||||
self._updateExtruderCount();
|
||||
self.settings.printerProfiles.currentProfileData().extruder.count.subscribe(self._updateExtruderCount);
|
||||
|
|
|
|||
|
|
@ -91,6 +91,8 @@ $(function() {
|
|||
}
|
||||
};
|
||||
|
||||
self.webcam_available_ratios = ["16:9", "4:3"];
|
||||
|
||||
var auto_locale = {language: "_default", display: gettext("Autodetect from browser"), english: undefined};
|
||||
self.locales = ko.observableArray([auto_locale].concat(_.sortBy(_.values(AVAILABLE_LOCALES), function(n) {
|
||||
return n.display;
|
||||
|
|
@ -110,6 +112,7 @@ $(function() {
|
|||
self.printer_defaultExtrusionLength = ko.observable(undefined);
|
||||
|
||||
self.webcam_streamUrl = ko.observable(undefined);
|
||||
self.webcam_streamRatio = ko.observable(undefined);
|
||||
self.webcam_snapshotUrl = ko.observable(undefined);
|
||||
self.webcam_ffmpegPath = ko.observable(undefined);
|
||||
self.webcam_bitrate = ko.observable(undefined);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
<form class="form-horizontal">
|
||||
{% include "snippets/settings/webcam/webcamStreamUrl.jinja2" %}
|
||||
{% include "snippets/settings/webcam/webcamStreamRatio.jinja2" %}
|
||||
{% include "snippets/settings/webcam/webcamOrientation.jinja2" %}
|
||||
</form>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
<div class="control-group" title="{{ _('Aspect ratio of the webcam stream, either 16:9 or 4:3') }}">
|
||||
<label class="control-label" for="settings-webcamStreamRatio">{{ _('Stream aspect ratio') }}</label>
|
||||
<div class="controls">
|
||||
<select data-bind="options: webcam_available_ratios, value: webcam_streamRatio"></select>
|
||||
<span class="help-inline">{% trans %}If the stream has a different aspect ratio than configured here it will be letterboxed.{% endtrans %}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div id="webcam_rotator" data-bind="css: { webcam_rotated: settings.webcam_rotate90(), webcam_unrotated: !settings.webcam_rotate90() }">
|
||||
<div class="webcam_fixed_ratio ratio169">
|
||||
<div class="webcam_fixed_ratio" data-bind="css: webcamRatioClass">
|
||||
<div class="webcam_fixed_ratio_inner">
|
||||
<img id="webcam_image" data-bind="css: { flipH: settings.webcam_flipH(), flipV: settings.webcam_flipV() }, event: { load: onWebcamLoaded, error: onWebcamErrored }, visible: !webcamError()">
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue