diff --git a/QML/ColorPipelineColor.qml b/QML/ColorPipelineColor.qml index d4cd471916f696d25a1c9859f105c82790ed65ee..0bb9dab8411b99fa43be55676ec307442805b8ff 100644 --- a/QML/ColorPipelineColor.qml +++ b/QML/ColorPipelineColor.qml @@ -42,8 +42,8 @@ Window { x: Screen.width/2-width/2 y: Screen.height/2-height/2 width: 450 - height: 360 - maximumHeight: 360 + height: 400 + maximumHeight: 400 maximumWidth: 450 Component.onCompleted: { @@ -177,6 +177,61 @@ Window { } } } + + ColumnLayout { + CheckBox { + id: trapezecor + text: qsTr("Trapeze correction") + onCheckedChanged: { + if (checked) { + trapezecorr_h_label.opacity = 1 + trapezecorr_h.enabled = true +// trapezecorr_v_label.opacity = 1 +// trapezecorr_v.enabled = true + } + else{ + trapezecorr_h_label.opacity = 0.5 + trapezecorr_h.enabled = false +// trapezecorr_v_label.opacity = 0.5 +// trapezecorr_v.enabled = false + } +// imgpromngr.setTrapezeCor(checked, trapezecorr_h.value, trapezecorr_v.value) + imgpromngr.setTrapezeCor(checked, trapezecorr_h.value, 1.0) + } + } + + RowLayout { + Layout.leftMargin: 25 + Layout.minimumWidth: 300 + + Label { id: trapezecorr_h_label; opacity: 0.5; text: qsTr("horizontal") } + SpinBox { + id: trapezecorr_h + enabled: false + value: 0.0 + minimumValue: -100.0 + stepSize: 1.0 + maximumValue: 100.0 + decimals: 1 + implicitWidth: 70 +// onValueChanged: imgpromngr.setTrapezeCor(trapezecor.checked, value, trapezecorr_v.value) + onValueChanged: imgpromngr.setTrapezeCor(trapezecor.checked, value, 0) + } + +// Label { id: trapezecorr_v_label; opacity: 0.5; text: qsTr("vertical") } +// SpinBox { +// id: trapezecorr_v +// enabled: false +// value: 0.0 +// minimumValue: -100.0 +// stepSize: 1.0 +// maximumValue: 100.0 +// decimals: 1 +// implicitWidth: 70 +// onValueChanged: imgpromngr.setTrapezeCor(trapezecor.checked, trapezecorr_h.value, value) +// } + } + } } } @@ -262,6 +317,9 @@ Gamma correction: Raise all the pixel values to a power, the gamma value. So, de sharp.checked = false gamma.value = 1.2 gammacor.checked = false + trapezecor.checked = false + trapezecorr_h.value = 0.0 +// trapezecorr_v.value = 0.0 } onClosing: help.close() } diff --git a/QML/ColorPipelineMono.qml b/QML/ColorPipelineMono.qml index bbed0bc84e34541aa4710357c971fb2ad1372b32..2c0776dda36592ece174a2fd787afb7fb987ab0e 100644 --- a/QML/ColorPipelineMono.qml +++ b/QML/ColorPipelineMono.qml @@ -165,6 +165,61 @@ Window { } } } + + ColumnLayout { + CheckBox { + id: trapezecor + text: qsTr("Trapeze correction") + onCheckedChanged: { + if (checked) { + trapezecorr_h_label.opacity = 1 + trapezecorr_h.enabled = true +// trapezecorr_v_label.opacity = 1 +// trapezecorr_v.enabled = true + } + else{ + trapezecorr_h_label.opacity = 0.5 + trapezecorr_h.enabled = false +// trapezecorr_v_label.opacity = 0.5 +// trapezecorr_v.enabled = false + } +// imgpromngr.setTrapezeCor(checked, trapezecorr_h.value, trapezecorr_v.value) + imgpromngr.setTrapezeCor(checked, trapezecorr_h.value, 1.0) + } + } + + RowLayout { + Layout.leftMargin: 25 + Layout.minimumWidth: 300 + + Label { id: trapezecorr_h_label; opacity: 0.5; text: qsTr("horizontal") } + SpinBox { + id: trapezecorr_h + enabled: false + value: 0.0 + minimumValue: -100.0 + stepSize: 1.0 + maximumValue: 100.0 + decimals: 1 + implicitWidth: 70 +// onValueChanged: imgpromngr.setTrapezeCor(trapezecor.checked, value, trapezecorr_v.value) + onValueChanged: imgpromngr.setTrapezeCor(trapezecor.checked, value, 0) + } + +// Label { id: trapezecorr_v_label; opacity: 0.5; text: qsTr("vertical") } +// SpinBox { +// id: trapezecorr_v +// enabled: false +// value: 0.0 +// minimumValue: -100.0 +// stepSize: 1.0 +// maximumValue: 100.0 +// decimals: 1 +// implicitWidth: 70 +// onValueChanged: imgpromngr.setTrapezeCor(trapezecor.checked, trapezecorr_h.value, value) +// } + } + } } } @@ -248,6 +303,8 @@ Gamma correction: Raise all the pixel values to a power, the gamma value. So, de sharp.checked = false gamma.value = 1.2 gammacor.checked = false + trapezecorr_h.value = 0.0 +// trapezecorr_v.value = 0.0 } onClosing: help.close() diff --git a/imgpromngr.cpp b/imgpromngr.cpp index e19fb5d2788b8279ba9899b66dcec0632b6b5b60..d482f8f70e78c481c7a33da9959a794979c484a4 100644 --- a/imgpromngr.cpp +++ b/imgpromngr.cpp @@ -76,6 +76,8 @@ ImgProMngr::ImgProMngr(QMutex *m_mutex) { connect(this, SIGNAL(disableSharp()), worker[i], SLOT(disableSharp())); connect(this, SIGNAL(enableGammaCor(float)), worker[i], SLOT(enableGammaCor(float))); connect(this, SIGNAL(disableGammaCor()), worker[i], SLOT(disableGammaCor())); + connect(this, SIGNAL(enableTrapezeCor(float, float)), worker[i], SLOT(enableTrapezeCor(float, float))); + connect(this, SIGNAL(disableTrapezeCor()), worker[i], SLOT(disableTrapezeCor())); connect(this, SIGNAL(startProcessing(QByteArray, struct img_header_t, int)), worker[i], SLOT(bufferProcessing(QByteArray, struct img_header_t, int))); worker_thread[i]->start(); } @@ -559,6 +561,24 @@ void ImgProMngr::setGamma(bool a, float gamma) { disableGammaCor(); } +/** + * @brief ImgProMngr::setTrapezeCor + * Called from GUI to enable/disable trapeze perspective correction. + * + * @param enable enabling flag + * @param factH horizontal factor + * @param factV vertical factor + */ +void ImgProMngr::setTrapezeCor(bool enable, float factH, float factV) { + + if(enable) { + enableTrapezeCor(factH, factV); + } + else { + disableTrapezeCor(); + } +} + /** * @brief ImgProMngr::enable * Called from GUI to enable the color pipeline. @@ -589,6 +609,7 @@ void ImgProMngr::resetColorPipeLine() { disableCcm(color_pipeline.ccm_preset); disableGammaCor(); disableSharp(); + disableTrapezeCor(); } /** diff --git a/imgpromngr.hpp b/imgpromngr.hpp index e3891f69532c4f288ec09732b28e4d2bf00629ff..67fa239a610dc280b6a7d34512acc6011c59c198 100644 --- a/imgpromngr.hpp +++ b/imgpromngr.hpp @@ -68,6 +68,8 @@ signals: void disableSharp(); void enableGammaCor(float gamma); void disableGammaCor(); + void enableTrapezeCor(float factH, float factV); + void disableTrapezeCor(); void startProcessing(QByteArray, struct img_header_t, int); void lostFrame(); @@ -97,6 +99,7 @@ public: Q_INVOKABLE void setCcm(bool a, int ccm_preset); Q_INVOKABLE void setSharp(bool a, float factor, int alg, float sens); Q_INVOKABLE void setGamma(bool a, float gamma); + Q_INVOKABLE void setTrapezeCor(bool enable, float factH, float factV); Q_INVOKABLE void resetColorPipeLine(); Q_INVOKABLE void resetFilters(); Q_INVOKABLE void resetZoomingParameters(); diff --git a/imgproworkers.cpp b/imgproworkers.cpp index 7c70d7615cf5969999c932d63977e8c6bbddb0d7..67af3d7f5ae9a2df3d90915e47318e28d5e7f1a8 100644 --- a/imgproworkers.cpp +++ b/imgproworkers.cpp @@ -641,6 +641,25 @@ void ImgProWorkers::disableGammaCor() { color_pipe_stageconf_gamma(color_pipe, FALSE, 1.0); } +/** + * @brief ImgProWorkers::enableTrapezeCor + * Enable trapeze correction. + * + * @param factH horizontal correction factor + * @param factV vertical correction factor + */ +void ImgProWorkers::enableTrapezeCor(float factH, float factV) { + color_pipe_stageconf_trapcorr(color_pipe, TRUE, factV, factH); +} + +/** + * @brief ImgProWorkers::disableTrapezeCor + * Disable trapeze correction. + */ +void ImgProWorkers::disableTrapezeCor() { + color_pipe_stageconf_trapcorr(color_pipe, FALSE, 1.0, 1.0); +} + /** * @brief ImgProWorkers::initColorPipeLine * Open color pipeline. Called once in the diff --git a/imgproworkers.hpp b/imgproworkers.hpp index eb25e1ae89fc1252a980e410e1ad726608afc19b..ddfd63249e4745202e2322ca07061f641a80a80d 100644 --- a/imgproworkers.hpp +++ b/imgproworkers.hpp @@ -84,6 +84,8 @@ public slots: void disableSharp(); void enableGammaCor(float gamma); void disableGammaCor(); + void enableTrapezeCor(float factH, float factV); + void disableTrapezeCor(); public: ImgProWorkers(Manager *mngr, QMutex *mutex, int id);