2011-04-21 15:17:19 +00:00
|
|
|
# Created By: Virgil Dupras
|
|
|
|
# Created On: 2011-04-20
|
2015-01-03 21:30:57 +00:00
|
|
|
# Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
2014-10-13 19:08:59 +00:00
|
|
|
#
|
2015-01-03 21:33:16 +00:00
|
|
|
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
2014-10-13 19:08:59 +00:00
|
|
|
# which should be included with this package. The terms are also available at
|
2015-01-03 21:33:16 +00:00
|
|
|
# http://www.gnu.org/licenses/gpl-3.0.html
|
2011-04-21 15:17:19 +00:00
|
|
|
|
|
|
|
from collections import defaultdict
|
|
|
|
from itertools import combinations
|
|
|
|
|
|
|
|
from hscommon.trans import tr
|
|
|
|
|
|
|
|
from core.engine import Match
|
|
|
|
|
2020-01-01 02:16:27 +00:00
|
|
|
|
2011-06-15 14:13:03 +00:00
|
|
|
def getmatches(files, match_scaled, j):
|
2011-04-21 15:17:19 +00:00
|
|
|
timestamp2pic = defaultdict(set)
|
|
|
|
for picture in j.iter_with_progress(files, tr("Read EXIF of %d/%d pictures")):
|
2012-08-10 20:34:27 +00:00
|
|
|
timestamp = picture.exif_timestamp
|
2013-05-05 14:11:07 +00:00
|
|
|
if timestamp:
|
|
|
|
timestamp2pic[timestamp].add(picture)
|
2020-01-01 02:16:27 +00:00
|
|
|
if "0000:00:00 00:00:00" in timestamp2pic: # very likely false matches
|
|
|
|
del timestamp2pic["0000:00:00 00:00:00"]
|
2011-04-21 15:17:19 +00:00
|
|
|
matches = []
|
|
|
|
for pictures in timestamp2pic.values():
|
2011-06-15 14:13:03 +00:00
|
|
|
for p1, p2 in combinations(pictures, 2):
|
|
|
|
if (not match_scaled) and (p1.dimensions != p2.dimensions):
|
|
|
|
continue
|
|
|
|
matches.append(Match(p1, p2, 100))
|
2014-10-13 19:08:59 +00:00
|
|
|
return matches
|