mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-08-06 10:18:42 +02:00
[Lens Distortion] add control points display and features
This commit is contained in:
parent
b64b18c1a2
commit
c3e504efc7
3 changed files with 105 additions and 4 deletions
|
@ -34,9 +34,15 @@ AliceVision.FloatImageViewer {
|
||||||
property string channelModeString : "rgba"
|
property string channelModeString : "rgba"
|
||||||
|
|
||||||
// rename into distortionView
|
// rename into distortionView
|
||||||
property bool distortion: false
|
property bool distortion: false;
|
||||||
|
|
||||||
property bool isGridDisplayed : false;
|
property bool isGridDisplayed : false;
|
||||||
property int subdivisions: 2
|
property int gridOpacity : 100;
|
||||||
|
property color gridColor : "#FF0000";
|
||||||
|
|
||||||
|
property bool isCtrlPointsDisplayed : true;
|
||||||
|
property int subdivisions: 5;
|
||||||
|
property int pointsNumber: Math.pow(subdivisions + 1, 2);
|
||||||
|
|
||||||
onDistortionChanged: {
|
onDistortionChanged: {
|
||||||
console.warn("distortion");
|
console.warn("distortion");
|
||||||
|
@ -51,6 +57,19 @@ AliceVision.FloatImageViewer {
|
||||||
root.updateSubdivisions(subdivisions)
|
root.updateSubdivisions(subdivisions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onIsCtrlPointsDisplayedChanged: {
|
||||||
|
repeater.displayControlPoints()
|
||||||
|
}
|
||||||
|
|
||||||
|
onGridOpacityChanged: {
|
||||||
|
root.setGridColorQML(Qt.rgba(gridColor.r, gridColor.g, gridColor.b, gridOpacity/100));
|
||||||
|
}
|
||||||
|
|
||||||
|
onGridColorChanged: {
|
||||||
|
root.setGridColorQML(Qt.rgba(gridColor.r, gridColor.g, gridColor.b, gridOpacity/100));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
channelMode: {
|
channelMode: {
|
||||||
switch(channelModeString)
|
switch(channelModeString)
|
||||||
{
|
{
|
||||||
|
@ -74,4 +93,81 @@ AliceVision.FloatImageViewer {
|
||||||
// Do not intercept mouse events, only get the mouse over information
|
// Do not intercept mouse events, only get the mouse over information
|
||||||
acceptedButtons: Qt.NoButton
|
acceptedButtons: Qt.NoButton
|
||||||
}
|
}
|
||||||
|
Item {
|
||||||
|
id: grid
|
||||||
|
width: root.width
|
||||||
|
height: root.height
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: root
|
||||||
|
onVerticesChanged : {
|
||||||
|
if (reinit){
|
||||||
|
grid.recalculateCP();
|
||||||
|
grid.generateControlPoints();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateControlPoints() {
|
||||||
|
if(repeater.model === pointsNumber){
|
||||||
|
repeater.model = 0;
|
||||||
|
}
|
||||||
|
repeater.model = pointsNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
function recalculateCP() {
|
||||||
|
if (repeater.model === 0)
|
||||||
|
return
|
||||||
|
|
||||||
|
var width = repeater.itemAt(0).width;
|
||||||
|
var height = repeater.itemAt(0).height;
|
||||||
|
|
||||||
|
for (let i = 0; i < repeater.model; i++) {
|
||||||
|
repeater.itemAt(i).x = root.getVertex(i).x - (width / 2);
|
||||||
|
repeater.itemAt(i).y = root.getVertex(i).y - (height / 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: rectGrid
|
||||||
|
Rectangle {
|
||||||
|
id: rect
|
||||||
|
width: root.sourceSize.width/100; height: width
|
||||||
|
radius: width/2
|
||||||
|
x: root.getVertex(model.index).x - (width / 2)
|
||||||
|
y: root.getVertex(model.index).y - (height / 2)
|
||||||
|
color: Colors.yellow
|
||||||
|
visible: true
|
||||||
|
MouseArea {
|
||||||
|
id: mouseAreaCP
|
||||||
|
anchors.fill : parent;
|
||||||
|
acceptedButtons: Qt.LeftButton
|
||||||
|
|
||||||
|
drag.target: rect
|
||||||
|
drag.smoothed: false
|
||||||
|
drag.axis: Drag.XAndYAxis
|
||||||
|
onReleased: {
|
||||||
|
root.setVertex(index, rect.x + (width / 2), rect.y + (height / 2))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
id: repeater
|
||||||
|
model: pointsNumber
|
||||||
|
delegate: rectGrid
|
||||||
|
function displayControlPoints() {
|
||||||
|
for (let i = 0; i < model; i++) {
|
||||||
|
if (repeater.itemAt(i).visible) {
|
||||||
|
repeater.itemAt(i).visible = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
repeater.itemAt(i).visible = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,7 @@ FloatingPane {
|
||||||
ToolTip.text: "subdivisions"
|
ToolTip.text: "subdivisions"
|
||||||
|
|
||||||
text: subdivisionsValue.toFixed(1)
|
text: subdivisionsValue.toFixed(1)
|
||||||
Layout.preferredWidth: textMetrics_opacityValue.width
|
Layout.preferredWidth: textMetrics_subdivisionsValue.width
|
||||||
selectByMouse: true
|
selectByMouse: true
|
||||||
validator: doubleValidator
|
validator: doubleValidator
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
|
@ -160,4 +160,9 @@ FloatingPane {
|
||||||
font: opacityLabel.font
|
font: opacityLabel.font
|
||||||
text: "100.000"
|
text: "100.000"
|
||||||
}
|
}
|
||||||
|
TextMetrics {
|
||||||
|
id: textMetrics_subdivisionsValue
|
||||||
|
font: opacityLabel.font
|
||||||
|
text: "10.00"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ AliceVision.PanoramaViewer {
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: grid
|
id: points
|
||||||
width: root.width
|
width: root.width
|
||||||
height: root.height
|
height: root.height
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue