def test_search_drawings(): qdg = QuickDrawDataGroup("anvil") # test a search with no criteria returns 1000 results r = qdg.search_drawings() assert len(r) == 1000 # test a recognized search r = qdg.search_drawings(recognized=True) for d in r: assert d.recognized r = qdg.search_drawings(recognized=False) for d in r: assert not d.recognized # test a country search r = qdg.search_drawings(countrycode="US") for d in r: assert d.countrycode == "US" # pull first drawing key_id = r[0].key_id timestamp = r[0].timestamp # test key_id search r = qdg.search_drawings(key_id=key_id) for d in r: assert d.key_id == key_id # test timestamp search r = qdg.search_drawings(timestamp=timestamp) for d in r: assert d.timestamp == timestamp # test a compound search of recognized and country code r = qdg.search_drawings(recognized=True, countrycode="US") for d in r: assert d.recognized assert d.countrycode == "US"
from quickdraw import QuickDrawDataGroup from PIL import Image, ImageDraw, ImageOps import cv2 import numpy as np from color_it import ColorIt qdg = QuickDrawDataGroup("circle") results = qdg.search_drawings(key_id=int(4865367048454144)) anvil = results[0] #anvil_image = Image.new("RGB", (255,255), color=(255,255,255)) #anvil_drawing = ImageDraw.Draw(anvil_image) # for stroke in anvil.strokes: # # anvil_drawing.line(stroke, fill=(0,0,0), width=2) # for coordinate in range(len(stroke)-1): # x1 = stroke[coordinate][0] # y1 = stroke[coordinate][1] # x2 = stroke[coordinate+1][0] # y2 = stroke[coordinate+1][1] # anvil_drawing.line((x1,y1,x2,y2), fill=(0,0,0), width=4) #old_size = anvil_image.size # old_size[0] is in (width, height) format #clearnew_im = ImageOps.expand(anvil_image,border = 10, fill = (0,0,0)) #new_im.show() c = ColorIt(anvil) c.fill(3)
from quickdraw import QuickDrawDataGroup anvils = QuickDrawDataGroup("anvil") results = anvils.search_drawings(countrycode="PL")