Esempio n. 1
0
    def post(self):
        user = users.get_current_user()
        minIndex = int(self.request.get("minIndex"))
        maxIndex = int(self.request.get("maxIndex"))
        userID = self.request.get("userID")
        query = UserScreenshot.query(UserScreenshot.index >= minIndex,
                                     UserScreenshot.index < maxIndex,
                                     ancestor=ndb.Key('UserCollection',
                                                      userID)).order(
                                                          UserScreenshot.index)

        results = query.fetch(None)
        images = []
        for entry in results:
            blob_key = entry.blob_key
            blobstore.get(blob_key)
            reader = blobstore.BlobReader(blob_key)
            image = Image.open(reader)
            image.load()
            images.append(image)

        p = ScreenshotParser()
        cards = p.getCardsFromImages(images)
        for i in range(0, len(results)):
            # Bit of a fudge here, could get the ScreenshotParser to give us how many cards per image
            results[i].cards = ""
            for j in range(i * 8, min(i * 8 + 8, len(cards))):
                results[i].cards += str(cards[j].toDict()) + "\n"
            results[i].cards = results[i].cards[:-1]  # Remove last newline
            blobstore.delete(results[i].blob_key)
            results[i].processed = True
            results[i].put()
        return
Esempio n. 2
0
	def post(self):
		user = users.get_current_user()
		minIndex = int(self.request.get("minIndex"))
		maxIndex = int(self.request.get("maxIndex"))
		userID = self.request.get("userID")
		query = UserScreenshot.query(UserScreenshot.index >= minIndex,
			                         UserScreenshot.index <  maxIndex,
			                         ancestor=ndb.Key('UserCollection', userID)
			                         ).order(UserScreenshot.index)

		results = query.fetch(None)
		images = []
		for entry in results:
			blob_key = entry.blob_key
			blobstore.get(blob_key)
			reader = blobstore.BlobReader(blob_key)
			image = Image.open(reader)
			image.load()
			images.append(image)

		p = ScreenshotParser()
		cards = p.getCardsFromImages(images)
		for i in range(0, len(results)):
			# Bit of a fudge here, could get the ScreenshotParser to give us how many cards per image
			results[i].cards = ""
			for j in range(i * 8, min(i*8 + 8, len(cards))):
				results[i].cards += str(cards[j].toDict()) + "\n"
			results[i].cards = results[i].cards[:-1]    # Remove last newline
			blobstore.delete(results[i].blob_key)
			results[i].processed = True
			results[i].put()
		return
Esempio n. 3
0
					csv += str(card["golden"])   + ","
					csv += str(card["overlaps"]) + "\n"
		return csv

def reorderImages(imageNames):
	imageNames.sort()
	i = 0
	sortedImageNames = []
	while i < len(imageNames):
		image = imageNames[i]
		if image[-4:] == ".png":
			if image[-6:-5] == " ":
				sortedImageNames.append(imageNames[i+1])
				i += 1
			sortedImageNames.append(image)
		i += 1
	return sortedImageNames


if __name__ == "__main__":
	images = []
	for name in reorderImages(os.listdir("../screencaps/")):
		if name[-4:] == ".png":
			images.append(Image.open("../screencaps/" + name))

	p = ScreenshotParser()
	cards = p.getCardsFromImages(images)
	analyser = Analyser(cards)
	analyser.findPotentialCards()
	print analyser.potentialCardsToCSV()
	
Esempio n. 4
0
                    csv += str(card["overlaps"]) + "\n"
        return csv


def reorderImages(imageNames):
    imageNames.sort()
    i = 0
    sortedImageNames = []
    while i < len(imageNames):
        image = imageNames[i]
        if image[-4:] == ".png":
            if image[-6:-5] == " ":
                sortedImageNames.append(imageNames[i + 1])
                i += 1
            sortedImageNames.append(image)
        i += 1
    return sortedImageNames


if __name__ == "__main__":
    images = []
    for name in reorderImages(os.listdir("../screencaps/")):
        if name[-4:] == ".png":
            images.append(Image.open("../screencaps/" + name))

    p = ScreenshotParser()
    cards = p.getCardsFromImages(images)
    analyser = Analyser(cards)
    analyser.findPotentialCards()
    print analyser.potentialCardsToCSV()