예제 #1
0
def run_scan_setup(cam_index=0):
    setup_all(True)

    cam = cv.CreateCameraCapture(cam_index)
    scan_card.setup_windows()

    # main loop
    run = True
    while run:
        # for now, name the next box as the largest integer box name, +1
        current_max_box = session.query(func.max(sqlalchemy.cast(InvCard.box, sqlalchemy.Integer))).first()[0]
        if current_max_box is None:
            # if there is no current box, just start at 1
            next_box = 1
        else:
            next_box = current_max_box + 1

        print "box to scan[%02d]: " % next_box,
        answer = ("%s" % raw_input().rstrip())
        if answer != '' and answer != 'q':
            next_box = answer
            capture_box(cam, next_box)
        if answer == 'q':
            run = False
            run_match()
예제 #2
0
import cv
import scan_card

from elixir import session, setup_all
import sqlalchemy
from sqlalchemy import func
from models import *
import re

setup_all(True)

cam = cv.CreateCameraCapture(0)
scan_card.setup_windows()

def capture_box(cam, boxnum):
	while True: #retry loop
		retry = False
		captures = scan_card.watch_for_card(cam)
		scan_card.save_captures(boxnum, captures)
		print "captured %d cards. is this correct?" % len(captures)
		answer = raw_input()
		print "got answer: ", answer
		if re.search('[yc]',answer):
			break #finish the function
		else:
			print "try editing captures_%02d to match" % boxnum
			answer = ""
			while not re.match('[cra]', answer):
				print "when done - (c)orrected? (r)etry scan? or (a)bort?"
				answer = raw_input()
			if re.search('c',answer):
예제 #3
0
]

# Load the sets
known = load_set_cache(SET_CACHE_FILE)
if known is None:
    print "Processing magic sets"
    known = match_card.load_sets(BASE_SET_DIR, SETS)
    print "Saving sets to cache file %s" % (SET_CACHE_FILE)
    save_set_cache(SET_CACHE_FILE, known)
print "Magic sets loaded and ready"

cam = cv.CreateCameraCapture(-1)  # Camera, -1 indicates autofind
#cam = cv.CreateCameraCapture(1)
# TODO: detect failed to load camera, CAN NOT simply check if cam is None

scan_card.setup_windows()  # win, snapshot, match, background
tts = TTS()  # Load test to speech festival
cache = match_card.GradientCache(BASE_SET_DIR)  # memory cache
scanCard = ScanCard(cam)
matchCard = MatchCard(BASE_SET_DIR)
csv = MagicAssistantCSV(CSV_FILE, append=True)

while True:
    capture = scanCard.check_for_card()
    if capture is not None:
        print "Card captured, proceeding to find a match"
        (card,
         set_name), is_sure = match_card.match_card(capture, known, cache)

        # Display matched information
        if is_sure == True:
예제 #4
0
]

# Load the sets
known = load_set_cache(SET_CACHE_FILE)
if known is None:
	print "Processing magic sets"
	known = match_card.load_sets(BASE_SET_DIR, SETS)
	print "Saving sets to cache file %s" % (SET_CACHE_FILE)
	save_set_cache(SET_CACHE_FILE, known)
print "Magic sets loaded and ready"

cam = cv.CreateCameraCapture(-1)	# Camera, -1 indicates autofind
#cam = cv.CreateCameraCapture(1)
# TODO: detect failed to load camera, CAN NOT simply check if cam is None

scan_card.setup_windows() # win, snapshot, match, background
tts = TTS()		# Load test to speech festival
cache = match_card.GradientCache(BASE_SET_DIR)	# memory cache
scanCard = ScanCard(cam)
matchCard = MatchCard(BASE_SET_DIR)
csv = MagicAssistantCSV(CSV_FILE, append=True)

while True:
	capture = scanCard.check_for_card()
	if capture is not None:
		print "Card captured, proceeding to find a match"
		(card, set_name), is_sure = match_card.match_card(capture, known, cache)

		# Display matched information
		if is_sure == True:
			print "\tMatch Found!"
예제 #5
0
from match_card import compare_cards, hash_original_images, load_orig_image_hashs_from_json

import cv2
import numpy as np
import scan_card
import scipy
import timeit
import json
import os.path

DEFAULTCAM = 0
WEBCAM = 1

cam = cv2.VideoCapture(WEBCAM)

scan_card.setup_windows()
scanCard = ScanCard(cam)

if (os.path.isfile("orig_image_hashs.json")):
    orig_image_hashs = load_orig_image_hashs_from_json()
else:
    orig_image_hashs = hash_original_images()

while True:
    capture = scanCard.check_for_card()

    if capture is not None:
        print "Card captured, proceeding to find a match"
        scanCard.display_snapshot()
        original = compare_cards(capture, orig_image_hashs)
        cv2.imshow("match", original)