2011-04-21 15:17:19 +00:00
|
|
|
# Created By: Virgil Dupras
|
|
|
|
# Created On: 2011-04-20
|
2012-03-15 18:28:40 +00:00
|
|
|
# Copyright 2012 Hardcoded Software (http://www.hardcoded.net)
|
2011-04-21 15:17:19 +00:00
|
|
|
#
|
|
|
|
# This software is licensed under the "BSD" License as described in the "LICENSE" file,
|
|
|
|
# which should be included with this package. The terms are also available at
|
|
|
|
# http://www.hardcoded.net/licenses/bsd_license
|
|
|
|
|
|
|
|
from collections import defaultdict
|
|
|
|
from itertools import combinations
|
|
|
|
|
|
|
|
from hscommon.trans import tr
|
|
|
|
|
|
|
|
from core.engine import Match
|
|
|
|
|
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
|
|
|
|
timestamp2pic[timestamp].add(picture)
|
2011-04-21 15:17:19 +00:00
|
|
|
if '0000:00:00 00:00:00' in timestamp2pic: # very likely false matches
|
|
|
|
del timestamp2pic['0000:00:00 00: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))
|
2011-04-21 15:17:19 +00:00
|
|
|
return matches
|