示例#1
0
def setup_tile_db(errors, db_file):
    tiles_db = None
    if REGEN_TILES_DB:
        tiles = glob.glob(os.path.join(TILES_DIR, '*.png'))
        if tiles:
            tiles_db = [
                (tile, extract_meta.extractPhotoInfo(tile)) \
                 for tile in tiles
            ]
            db_file = open(DB_FILE, 'wb')
            pickle.dump(tiles_db, db_file)
            db_file.close()
        else:
            errors.append(ERRORS.get('NO_TILES'))
    else:
        if os.path.isfile(DB_FILE):
            db_file = open(DB_FILE, 'rb')
            tiles_db = pickle.load(db_file)
            if len(tiles_db) < 1:
                errors.append(ERRORS.get('NO_TILES'))
            db_file.close()
        else:
            errors.append(ERRORS.get('NO_TILES_DB_FILE'))
    return errors, tiles_db
示例#2
0
def setup_tile_db(errors, db_file):
    tiles_db = None
    if REGEN_TILES_DB:
        tiles = glob.glob(os.path.join(TILES_DIR, '*.png'))
        if tiles:
            tiles_db = [
                (tile, extract_meta.extractPhotoInfo(tile)) \
                 for tile in tiles
            ]
            db_file = open(DB_FILE, 'wb')
            pickle.dump(tiles_db, db_file)
            db_file.close()
        else:
            errors.append(ERRORS.get('NO_TILES'))
    else:
        if os.path.isfile(DB_FILE):
            db_file = open(DB_FILE, 'rb')
            tiles_db = pickle.load(db_file)
            if len(tiles_db) < 1:
                errors.append(ERRORS.get('NO_TILES'))
            db_file.close()
        else:
            errors.append(ERRORS.get('NO_TILES_DB_FILE'))
    return errors, tiles_db
示例#3
0
import os.path
import sys
import glob
import extract_meta
import mosaic
import pickle

db_filename = 'db.p'

if not os.path.isfile(db_filename):
	photos = glob.glob("photos/*.png")
	db = [(photo, extract_meta.extractPhotoInfo(photo)) for photo in photos]
	db_file = open(db_filename, 'wb')
	pickle.dump(db, db_file)
else:
	db_file = open(db_filename, 'r')
	db = pickle.load(db_file)
		
print "Have " + str(len(db)) + " samples"

photos = glob.glob("*.png")

result = mosaic.createMosaic(db, photos[0])
result.show()
result.save('result-Cartesian.png', 'PNG')


result = mosaic.createMosaicHex(db, photos[0])
result.show()
result.save('result-Hex.png', 'PNG')
示例#4
0
import os.path
import sys
import glob
import extract_meta
import mosaic
import pickle

db_filename = 'db.p'

if not os.path.isfile(db_filename):
    photos = glob.glob("photos/*.png")
    db = [(photo, extract_meta.extractPhotoInfo(photo)) for photo in photos]
    db_file = open(db_filename, 'wb')
    pickle.dump(db, db_file)
else:
    db_file = open(db_filename, 'r')
    db = pickle.load(db_file)

print "Have " + str(len(db)) + " samples"

photos = glob.glob("*.png")

result = mosaic.createMosaic(db, photos[0])
result.show()
result.save('result-Cartesian.png', 'PNG')

result = mosaic.createMosaicHex(db, photos[0])
result.show()
result.save('result-Hex.png', 'PNG')