コード例 #1
0
def find(img,mask,dims): # this isn't actually blobbing anything
	length, width = bounds(img)
	height, breadth = dims
	result = like(img)
	img = img.load()
	height = int(height / 2)
	breadth = int(breadth / 2)
	for l in range(height,length-height):
		for w in range(breadth,width-breadth):
			pixel = img[l,w]
	return result
コード例 #2
0
ファイル: proto.py プロジェクト: JoshuaA9088/HackCamera
def find(img, mask, dims):  # this isn't actually blobbing anything
    length, width = bounds(img)
    height, breadth = dims
    result = like(img)
    img = img.load()
    height = int(height / 2)
    breadth = int(breadth / 2)
    for l in range(height, length - height):
        for w in range(breadth, width - breadth):
            pixel = img[l, w]
    return result
コード例 #3
0
ファイル: proto.py プロジェクト: JoshuaA9088/HackCamera
def edge(img):
    avails = avail(img)
    result = like(img).load()
    length, width = bounds(img)
    img = img.load()
    for a in range(0, len(avails)):
        av = avails[a]
        for x in range(0, length):
            for y in range(0, width):
                if av == img[x, y]:
                    result[x, y] == av
    return result
コード例 #4
0
def edge(img):
	avails = avail(img)
	result = like(img).load()
	length,width = bounds(img)
	img = img.load()
	for a in range(0,len(avails)):
		av = avails[a]
		for x in range(0,length):
			for y in range(0,width):
				if av == img[x,y]:
					result[x,y] == av
	return result
コード例 #5
0
ファイル: proto.py プロジェクト: JoshuaA9088/HackCamera
def sharpen(img, amount):  # not actually sharpening
    result = like(img)
    length, width = bounds(img)
    img = img.load()
    result = result.load()
    for left in range(1, length - 1):
        for top in range(1, width - 1):
            pixel = [0, 0, 0, 0]
            for l in range(-1, 1):
                for w in range(-1, 1):
                    pixel[0] += img[left + l, top + w][0]
                    pixel[1] += img[left + l, top + w][1]
                    pixel[2] += img[left + l, top + w][2]
            result[left, top] = tuple(pixel)
    return result
コード例 #6
0
def sharpen(img,amount): #not actually sharpening
	result = like(img)
	length, width = bounds(img)
	img = img.load()
	result = result.load()
	for left in range(1,length-1):
		for top in range(1,width-1):
			pixel = [0,0,0,0]
			for l in range(-1,1):
				for w in range(-1, 1):
					pixel[0] += img[left+l,top+w][0]
					pixel[1] += img[left+l,top+w][1]
					pixel[2] += img[left+l,top+w][2]
			result[left,top] = tuple(pixel)
	return result
コード例 #7
0
ファイル: proto.py プロジェクト: JoshuaA9088/HackCamera
def group(img):  # automatically
    length, width = bounds(img)
    result = like(img).load()
    img = img.load()
    color = [255, 255, 255, 255]
    tolerance = [2, 2, 2, 2]
    for inc in range(1, 127):  # this is really really slow / iterative
        for x in range(length):
            for y in range(width):
                matches = 0
                if abs(img[x, y][0] - color[0]) < tolerance:
                    matches += 1
                if abs(img[x, y][1] - color[1]) < tolerance:
                    matches += 1
                if abs(img[x, y][2] - color[2]) < tolerance:
                    matches += 1
                if matches > 3:
                    result[x, y] = tuple(color)
    return result
コード例 #8
0
def group(img):#automatically
	length, width = bounds(img)
	result = like(img).load()
	img = img.load()
	color = [255,255,255,255]
	tolerance = [2,2,2,2]
	for inc in range(1,127): # this is really really slow / iterative
		for x in range(length):
			for y in range(width):
				matches = 0
				if (abs(img[x,y][0] - color[0]) < tolerance):
					matches += 1
				if (abs(img[x,y][1] - color[1]) < tolerance):
					matches += 1
				if (abs(img[x,y][2] - color[2]) < tolerance):
					matches += 1
				if matches > 3:
					result[x,y] = tuple(color)
	return result
コード例 #9
0
    teaser['user']['photos'][0]['url']) for teaser in teasers}

for rec in recs:
    user = rec['user']
    rec_id = user['_id']
    print(f"{Fore.GREEN}Analyzing {user['name']} ({rec_id}) ...")

    for rec_photo in user['photos']:
        print(f"\t{Fore.BLUE}Image {rec_photo['url']}")
        rec_img = get_image(rec_photo['url'])

        for (tea_id, tea_img) in teaser_images.items():
            print(
                f"\t\t{Fore.BLACK}{Style.BRIGHT}Comparing with teaser {tea_id}")
            if (compare(rec_img, tea_img)):
                for i, rec_found_img in enumerate([get_image(pic['url']) for pic in user['photos']]):
                    cv2.imshow(f"Rec {i}", rescale(rec_found_img, 30))
                cv2.imshow("Teaser", rescale(tea_img, 30))
                action = cv2.waitKey(0)
                cv2.destroyAllWindows()
                if (action == KEY_LIKE or action == KEY_LIKE - 32):
                    like(rec_id)
                if (action == KEY_PASS or action == KEY_PASS - 32):
                    dislike(rec_id)
                if (action == KEY_SUPERLIKE or action == KEY_SUPERLIKE - 32):
                    superlike(rec_id)
    print("\n")

# Deinit Colorama
deinit()
コード例 #10
0
ファイル: test.py プロジェクト: marciopocebon/HackCamera
#!/usr/bin/env python
from utils import (load, take, show, bgr, image, like, bounds,
channels, crop, scale, color, avail, colorPicker)
from proto import alias, sharpen, group, find, edge, center, distance
from PIL import Image

print "# fast stuff"
img = load('samples/abstract/colors.png')
#b = take()
show(img)
b, g, r = bgr(img)
img = image(b,b,b)
test = like(img)
bound = bounds(b)
channel = channels(b)
coord = (0,0,50,50)
closer = crop(img, coord)
bigger = scale(closer, 2.0)
eyedrop = color(img, 0, 30)
pallet = avail(img)
colorPicker(img,0,30)

print "# slow stuff"
res1 = alias(img, .3)
res2 = sharpen(img, .3)
blob1 = group(img)
mask = Image.new("RGB", (50, 10), "white")
blob3 = find(img,mask,(3,3))
coords1 = edge(img)
coords2 = center(blob1)
dist = distance(0,3)