-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
New ColorChecker Detection and Correction #1266
Merged
fabiencastan
merged 26 commits into
alicevision:develop
from
ludchieng:dev/colorChecker
Apr 26, 2021
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
a67bd4d
[nodes] add color checker detection (crashtest)
ludchieng b1e42e0
Add ColorCheckerDetection pipeline
ludchieng 402c315
[nodes] ColorCheckerDetection: update params
ludchieng c352e64
[nodes] ColorCheckerCorrection: create node and add it to pipeline
vscav 0984a48
[nodes] ColorChecker: update nodes io
ludchieng c064b70
[nodes] ColorCheckerCorrection: add SfmData output
vscav c4553fc
[nodes] ColorChecker: update io and doc
ludchieng fd59e17
[nodes] ColorChecker: add extension output option
vscav 23dacd2
[nodes] ColorChecker: add postion data output and rename io
ludchieng d474c17
[nodes] ColorCheckerDetection: remove position data output
ludchieng 7e4ae7c
[nodes] ColorCheckerCorrection: add new file extensions
vscav 899da9e
[nodes] colorCheckerCorrection: rename checker data input
vscav 8f5472a
[nodes] ColorCheckerDetection: add max charts count input and update io
ludchieng c1ccd5a
[ui] add ColorCheckerViewer
ludchieng 536c9b7
[ui] ColorCheckerViewer: show cchecker in the aside pane
ludchieng f48f83a
[ui] ColorCheckerViewer: ux improve & remove irrelevant qml includes
ludchieng a014bcf
[nodes] ColorCheckerCorrection: change output extensions
vscav e3f685f
[ui] remove colorcheckerdetection pipeline
ludchieng 4f52fad
[ui nodes] ColorChecker: fix refactor and documentation
ludchieng 214a011
[ui] ColorCheckerViewer: fix url path
ludchieng 2f4c736
[ui] ColorCheckerViewer: fix CCheckerPane display
ludchieng ad3e67e
[ui] ColorCheckerViewer: allow to display the ColorChecker without sf…
fabiencastan fee4bc9
[ui] ColorCheckerViewer: add load onCompleted
fabiencastan b2bb1e1
[ui] reconstruction: minor rename
fabiencastan a17fdf3
[ui] reconstruction: remove dead code
fabiencastan 35e831c
[ui] ColorCheckerViewer: add comment
fabiencastan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
__version__ = "1.0" | ||
|
||
from meshroom.core import desc | ||
|
||
import os.path | ||
|
||
|
||
class ColorCheckerCorrection(desc.CommandLineNode): | ||
commandLine = 'aliceVision_utils_colorCheckerCorrection {allParams}' | ||
size = desc.DynamicNodeSize('input') | ||
# parallelization = desc.Parallelization(blockSize=40) | ||
# commandLineRange = '--rangeStart {rangeStart} --rangeSize {rangeBlockSize}' | ||
|
||
documentation = ''' | ||
(BETA) \\ | ||
Performs color calibration from Macbeth color checker chart. | ||
|
||
The node assumes all the images to process are sharing the same colorimetric properties. | ||
All the input images will get the same correction. | ||
|
||
If multiple color charts are submitted, only the first one will be taken in account. | ||
''' | ||
|
||
inputs = [ | ||
desc.File( | ||
name='inputData', | ||
label='Color checker data', | ||
description='Position and colorimetric data of the color checker', | ||
value='', | ||
uid=[0], | ||
), | ||
desc.File( | ||
name='input', | ||
label='Input', | ||
description='SfMData file input, image filenames or regex(es) on the image file path.\nsupported regex: \'#\' matches a single digit, \'@\' one or more digits, \'?\' one character and \'*\' zero or more.', | ||
value='', | ||
uid=[0], | ||
), | ||
desc.ChoiceParam( | ||
name='extension', | ||
label='Output File Extension', | ||
description='Output Image File Extension.', | ||
value='exr', | ||
values=['exr', ''], | ||
exclusive=True, | ||
uid=[0], | ||
), | ||
desc.ChoiceParam( | ||
name='storageDataType', | ||
label='Storage Data Type for EXR output', | ||
description='Storage image data type:\n' | ||
' * float: Use full floating point (32 bits per channel)\n' | ||
' * half: Use half float (16 bits per channel)\n' | ||
' * halfFinite: Use half float, but clamp values to avoid non-finite values\n' | ||
' * auto: Use half float if all values can fit, else use full float\n', | ||
value='float', | ||
values=['float', 'half', 'halfFinite', 'auto'], | ||
exclusive=True, | ||
uid=[0], | ||
), | ||
] | ||
|
||
outputs = [ | ||
desc.File( | ||
name='outSfMData', | ||
label='Output sfmData', | ||
description='Output sfmData.', | ||
value=lambda attr: (desc.Node.internalFolder + os.path.basename(attr.node.input.value)) if (os.path.splitext(attr.node.input.value)[1] in ['.abc', '.sfm']) else '', | ||
uid=[], | ||
group='', # do not export on the command line | ||
), | ||
desc.File( | ||
name='output', | ||
label='Output Folder', | ||
description='Output Images Folder.', | ||
value=desc.Node.internalFolder, | ||
uid=[], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
__version__ = "1.0" | ||
|
||
from meshroom.core import desc | ||
|
||
import os.path | ||
|
||
|
||
class ColorCheckerDetection(desc.CommandLineNode): | ||
commandLine = 'aliceVision_utils_colorCheckerDetection {allParams}' | ||
size = desc.DynamicNodeSize('input') | ||
# parallelization = desc.Parallelization(blockSize=40) | ||
# commandLineRange = '--rangeStart {rangeStart} --rangeSize {rangeBlockSize}' | ||
|
||
documentation = ''' | ||
(BETA) \\ | ||
Performs Macbeth color checker chart detection. | ||
|
||
Outputs: | ||
- the detected color charts position and colors | ||
- the associated tranform matrix from "theoric" to "measured" | ||
assuming that the "theoric" Macbeth chart corners coordinates are: | ||
(0, 0), (1675, 0), (1675, 1125), (0, 1125) | ||
|
||
Dev notes: | ||
- Fisheye/pinhole is not handled | ||
- ColorCheckerViewer is unstable with multiple color chart within a same image | ||
''' | ||
|
||
inputs = [ | ||
desc.File( | ||
name='input', | ||
label='Input', | ||
description='SfMData file input, image filenames or regex(es) on the image file path.\nsupported regex: \'#\' matches a single digit, \'@\' one or more digits, \'?\' one character and \'*\' zero or more.', | ||
value='', | ||
uid=[0], | ||
), | ||
desc.IntParam( | ||
name='maxCount', | ||
label='Max count by image', | ||
description='Max color charts count to detect in a single image', | ||
value=1, | ||
range=(1, 3, 1), | ||
uid=[0], | ||
advanced=True, | ||
), | ||
desc.BoolParam( | ||
name='debug', | ||
label='Debug', | ||
description='If checked, debug data will be generated', | ||
value=False, | ||
uid=[0], | ||
), | ||
] | ||
|
||
outputs = [ | ||
desc.File( | ||
name='outputData', | ||
label='Color checker data', | ||
description='Output position and colorimetric data extracted from detected color checkers in the images', | ||
value=desc.Node.internalFolder + '/ccheckers.json', | ||
uid=[], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import QtQuick 2.11 | ||
|
||
Item { | ||
id: root | ||
|
||
// required for perspective transform | ||
property real sizeX: 1675.0 // might be overrided in ColorCheckerViewer | ||
property real sizeY: 1125.0 // might be overrided in ColorCheckerViewer | ||
|
||
property var colors: null | ||
property var window: null | ||
|
||
|
||
Rectangle { | ||
id: canvas | ||
anchors.centerIn: parent | ||
|
||
width: parent.sizeX | ||
height: parent.sizeY | ||
|
||
color: "transparent" | ||
border.width: Math.max(1, (4.0 / zoom)) | ||
border.color: "red" | ||
|
||
transformOrigin: Item.TopLeft | ||
transform: Matrix4x4 { | ||
id: transformation | ||
matrix: Qt.matrix4x4() | ||
} | ||
|
||
} | ||
|
||
|
||
function transform(matrix) { | ||
var m = matrix | ||
transformation.matrix = Qt.matrix4x4( | ||
m[0][0], m[0][1], 0, m[0][2], | ||
m[1][0], m[1][1], 0, m[1][2], | ||
0, 0, 1, 0, | ||
m[2][0], m[2][1], 0, m[2][2] ) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import QtQuick 2.11 | ||
import QtQuick.Layouts 1.3 | ||
|
||
import Controls 1.0 | ||
|
||
FloatingPane { | ||
id: root | ||
|
||
property var colors: null | ||
|
||
clip: true | ||
padding: 4 | ||
anchors.rightMargin: 0 | ||
|
||
|
||
ColumnLayout { | ||
anchors.fill: parent | ||
|
||
Grid { | ||
id: grid | ||
|
||
spacing: 5 | ||
x: spacing | ||
y: spacing | ||
rows: 4 | ||
columns: 6 | ||
|
||
Repeater { | ||
model: root.colors | ||
|
||
Rectangle { | ||
id: cell | ||
width: root.width / grid.columns - grid.spacing * (grid.columns+1) / grid.columns | ||
height: root.height / grid.rows - grid.spacing * (grid.rows+1) / grid.rows | ||
color: Qt.rgba(modelData.r, modelData.g, modelData.b, 1.0) | ||
} | ||
|
||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import QtQuick 2.11 | ||
|
||
Item { | ||
id: root | ||
|
||
property url source: undefined | ||
property var json: null | ||
property var image: null | ||
property var viewpoint: null | ||
property real zoom: 1.0 | ||
|
||
// required for perspective transform | ||
// Match theoretical values in AliceVision | ||
// see https://github.com/alicevision/AliceVision/blob/68ab70bcbc3eb01b73dc8dea78c78d8b4778461c/src/software/utils/main_colorCheckerDetection.cpp#L47 | ||
readonly property real ccheckerSizeX: 1675.0 | ||
readonly property real ccheckerSizeY: 1125.0 | ||
|
||
// offset the cchecker top left corner to match the image top left corner | ||
x: -image.width / 2 + ccheckerSizeX / 2 | ||
y: -image.height / 2 + ccheckerSizeY / 2 | ||
|
||
property var ccheckers: [] | ||
property int selectedCChecker: -1 | ||
|
||
Component.onCompleted: { readSourceFile(); } | ||
onSourceChanged: { readSourceFile(); } | ||
onViewpointChanged: { loadCCheckers(); } | ||
property var updatePane: null | ||
|
||
|
||
function getColors() { | ||
if (ccheckers[selectedCChecker] === undefined) | ||
return null; | ||
|
||
if (ccheckers[selectedCChecker].colors === undefined) | ||
return null; | ||
|
||
return ccheckers[selectedCChecker].colors; | ||
} | ||
|
||
function readSourceFile() { | ||
var xhr = new XMLHttpRequest; | ||
// console.warn("readSourceFile: " + root.source) | ||
xhr.open("GET", root.source); | ||
|
||
xhr.onreadystatechange = function() { | ||
if (xhr.readyState === XMLHttpRequest.DONE && xhr.status == 200) { | ||
try { | ||
root.json = null; | ||
// console.warn("readSourceFile: update json from " + root.source) | ||
root.json = JSON.parse(xhr.responseText); | ||
// console.warn("readSourceFile: root.json.checkers.length=" + root.json.checkers.length) | ||
} | ||
catch(exc) | ||
{ | ||
console.warn("Failed to parse ColorCheckerDetection JSON file: " + source); | ||
return; | ||
} | ||
} | ||
loadCCheckers(); | ||
}; | ||
xhr.send(); | ||
} | ||
|
||
function loadCCheckers() { | ||
emptyCCheckers(); | ||
if (root.json === null) | ||
{ | ||
return; | ||
} | ||
|
||
var currentImagePath = (root.viewpoint && root.viewpoint.attribute && root.viewpoint.attribute.childAttribute("path")) ? root.viewpoint.attribute.childAttribute("path").value : null | ||
var viewId = (root.viewpoint && root.viewpoint.attribute && root.viewpoint.attribute.childAttribute("viewId")) ? root.viewpoint.attribute.childAttribute("viewId").value : null | ||
for (var i = 0; i < root.json.checkers.length; i++) { | ||
// Only load ccheckers for the current view | ||
var checker = root.json.checkers[i] | ||
if (checker.viewId == viewId || | ||
checker.imagePath == currentImagePath) { | ||
var cpt = Qt.createComponent("ColorCheckerEntity.qml"); | ||
|
||
var obj = cpt.createObject(root, { | ||
sizeX: root.ccheckerSizeX, | ||
sizeY: root.ccheckerSizeY, | ||
colors: root.json.checkers[i].colors | ||
}); | ||
obj.transform(root.json.checkers[i].transform); | ||
ccheckers.push(obj); | ||
selectedCChecker = ccheckers.length-1; | ||
break; | ||
} | ||
} | ||
updatePane(); | ||
} | ||
|
||
function emptyCCheckers() { | ||
for (var i = 0; i < ccheckers.length; i++) | ||
ccheckers[i].destroy(); | ||
ccheckers = []; | ||
selectedCChecker = -1; | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does this value come from?