2
* Copyright 2016 Canonical Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as published by
6
* the Free Software Foundation; version 3.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by Jonas G. Drange <jonas.drange@canonical.com>
17
* Florian Boucault <florian.boucault@canonical.com>
21
import Ubuntu.Settings.Fingerprint 0.1
26
property var masks: []
28
// http://stackoverflow.com/a/1830844/538866
29
function isNumeric (n) {
30
return !isNaN(parseFloat(n)) && isFinite(n);
33
function getMasksToEnroll () {
35
if (masks && masks.length) {
36
masks.forEach(function (mask, i) {
37
// Format is "<source>/[x1,y1,w1,h1],…,[xn,yn,wn,hn]"
38
// If any value is non-numeric, we drop the mask.
39
if (!isNumeric(mask.x) || !isNumeric(mask.y) || !isNumeric(mask.width)
40
|| !isNumeric(mask.height))
43
// Translate the box so as to mirror the mask
44
mask.x = (1 - (mask.x + mask.width));
52
onMasksChanged: segmentedImage.enrollMasks(getMasksToEnroll())
54
textureSource: "qrc:/assets/fingerprint_segmented.png"
55
boxesSource: "qrc:/assets/fingerprint_boxes.json"
58
model: segmentedImage.masks
61
visible: UbuntuSettingsFingerprint.debug
64
x: modelData.x * segmentedImage.implicitWidth
65
y: modelData.y * segmentedImage.implicitHeight
66
width: modelData.width * segmentedImage.implicitWidth
67
height: modelData.height * segmentedImage.implicitHeight
69
Component.onCompleted: console.log('Scanner mask (x, y, w, h):', x, y, width, height)