Beispiel #1
0
    def add_orb(self):
        orb_x = random.randint(0, GAMEBOARD_WIDTH)
        orb_y = random.randint(0, GAMEBOARD_HEIGHT)
        orb_mass = random.randint(orb.orb.MIN_MASS, orb.orb.MAX_MASS)
        orb_color = random.choice(orb.orb.ORB_COLORS)
        orb_ = orb.orb(orb_x, orb_y, orb_mass, orb_color)

        id_ = orb_id(orb_)

        dataBase.add_orb(id_, orb_)
clear_images = os.listdir(clear_dir)

blur_images = os.listdir(blur_dir)




clear_orb_scores = []
clear_blob_scores = []
dummy_clear_scores=[]

for image in clear_images:
    path = clear_dir + image

    clear_orb_scores.append(orb(path))
    #clear_blob_scores.append(blobdetection(path))
    dummy_clear_scores.append(0)


print("################")


blur_orb_scores = []
blur_blob_scores = []
dummy_blur_scores=[]
for image in blur_images:
    path = blur_dir + image

    blur_orb_scores.append(orb(path))
    #blur_blob_scores.append(blobdetection(path))
Beispiel #3
0
#orb scale invariance
from tools import *
import numpy as np
#orb matching features
import cv2
import copy
from orb import orb

img1 = load_img('Lesson5//images//face.jpeg')

img2 = load_img('Lesson5//images//faceQS.png')

bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)

keypoints_train, descriptors_train = orb(img1)
keypoints_query, descriptors_query = orb(img2)

matches = bf.match(descriptors_train, descriptors_query)

matches = sorted(matches, key=lambda x: x.distance)

result = cv2.drawMatches(img1,
                         keypoints_train,
                         img2,
                         keypoints_query,
                         matches[:300],
                         img2,
                         flags=2)

show_img('Result', result)
Beispiel #4
0
def main():
    pygame.init()
    display = pygame.display.set_mode(settings.WINDOW_SIZE, pygame.FULLSCREEN)
    board = pygame.Rect(0, 0, 9600, 5400)
    CLOCK = pygame.time.Clock()
    dataBase = dataSets.dataBase()
    rendering = render.render(display.get_rect(), board, dataBase)

    player = playerSnake.playerSnake((0, 0), 'nadav')
    dataBase.add_snake('1', player)
    rendering.set_player(player)

    for i in xrange(100):
        dataBase.add_orb(i, orb.orb(random.randint(0, 200), random.randint(0, 200), random.randint(2, 20), random.choice(orb.orb.ORB_COLORS)))

    while True:
        # console prints
        if CLOCK.get_fps() < settings.REFRESH_RATE * 0.8:
            print 'fps: {}'.format(CLOCK.get_fps())

        # event handling
        # pressed = pygame.key.get_pressed()

        # # save states of alt, ctrl and shift key
        # alt_held = pressed[pygame.K_LALT] or pressed[pygame.K_RALT]
        # ctrl_held = pressed[pygame.K_LCTRL] or pressed[pygame.K_RCTRL]
        # shift_held = pressed[pygame.K_LSHIFT] or pressed[pygame.K_RSHIFT]

        # get integer with all the key mods, then use and operations to compare.
        key_mods = pygame.key.get_mods()
        # save states of alt, ctrl and shift key
        alt_held = key_mods & pygame.KMOD_ALT
        ctrl_held = key_mods & pygame.KMOD_CTRL
        shift_held = key_mods & pygame.KMOD_SHIFT

        for event in pygame.event.get():
            # exit if pressed on the X (top right)
            if event.type == pygame.QUIT:
                return
            # handel key presses
            elif event.type == pygame.KEYDOWN:
                # exit if press alt-f4 or ctrl-w
                if event.key == pygame.K_w and ctrl_held:
                    return
                elif event.key == pygame.K_F4 and alt_held:
                    return
                # other

        # game handling
        mouse_loc = pygame.mouse.get_pos()
        middle_loc = settings.WINDOW_CENTER
        new_angle = functions.incline_angle(mouse_loc, middle_loc)
        player.set_angle(new_angle, limit=playerSnake.playerSnake.MAX_ANGLE_CHANGE)
        player.move()

        for id_, obj in list(dataBase.iter_orbs()):
            collide = player.any_collide(obj)
            if collide:
                dataBase.remove_orb(id_)
                player.add_mass(obj.mass)

        # screen update
        rendering.set_camera_pos(player.get_location())
        rendering.set_zoom(20 / player.get_radius() + 1)
        rendering.render(display)
        pygame.display.flip()

        # tick timer
        CLOCK.tick(settings.REFRESH_RATE)
from blob_detection import blobdetection
from orb import orb

home = expanduser("~")

clear_dir = home + "/Downloads/QA-Polyp/train/0-clear/"

blur_dir = home + "/Downloads/QA-Polyp/train/1-blurry/"

clear_images = os.listdir(clear_dir)

blur_images = os.listdir(blur_dir)

LOOP = 4

for i in range(LOOP):

    try:

        path = clear_dir + clear_images[i]
        #print(path+" Features :"+str(blobdetection(path)))
        print(path + " Features :" + str(orb(path)))

        path = blur_dir + blur_images[i]
        #print(path + " Features :" + str(blobdetection(path)))
        print(path + " Features :" + str(orb(path)))

    except:
        print("error occurred :", sys.exc_info()[1])