Exemplo n.º 1
0
    def build(self):

        #Modifico la configuracion de kivy
        Config.set('input', 'mouse', 'mouse,multitouch_on_demand')
        Config.set('graphics', 'fullscreen', 'auto')
        Config.write()
        '''Creación de un horario vacío para rellenarlo con los datos posteriormente'''
        for dia in ['Lunes', 'Martes', 'Miercoles', 'Jueves', 'Viernes']:
            for i in range(9, 19):
                horarioPrincipal.incluye_hora(dia, 'Libre', dia, 'Sin Aula',
                                              '', i - 8, i - 7)

        self.box = Boxes(horarioPrincipal, filterTotal, documento)

        return self.box
Exemplo n.º 2
0
def main():
    clock = pygame.time.Clock()
    view = View()
    screen = view.screen
    player = Player()
    boxes = Boxes()
    game = Game()
    game.game_loop(clock=clock,
                   view=view,
                   player=player,
                   boxes=boxes,
                   screen=screen)
Exemplo n.º 3
0
class TestApp(App):
    def build(self):

        #Modifico la configuracion de kivy
        Config.set('input', 'mouse', 'mouse,multitouch_on_demand')
        Config.set('graphics', 'fullscreen', 'auto')
        Config.write()
        '''Creación de un horario vacío para rellenarlo con los datos posteriormente'''
        for dia in ['Lunes', 'Martes', 'Miercoles', 'Jueves', 'Viernes']:
            for i in range(9, 19):
                horarioPrincipal.incluye_hora(dia, 'Libre', dia, 'Sin Aula',
                                              '', i - 8, i - 7)

        self.box = Boxes(horarioPrincipal, filterTotal, documento)

        return self.box

    def save(self):
        '''Llamada al guardado del horario'''
        self.box.saveTimetable()

    def changeAula(self):
        '''Llamada al cambio de asignatura'''
        self.box.changeAsignaturaAula()

    def resetFilter(self):
        '''Llamada al reseteo del filtro'''
        self.box.resetDropdown()
Exemplo n.º 4
0
def tracker(i):
    boxes = Boxes(len(files))
    tex = Texture()
    ims = Slicer()
    th = Threshold()
    hog = Hog()
    cells = Cells(sizeh, sizew)

    names = list(listdir(path))
    names = names[i:i + batch_size]

    net = Network()
    net.load('data/net/dataset_184_nets_ann/', 'compile_config.txt',
             hog_block_size, hog_cell_size, hog_orientations)

    index = 0

    while (len(names) > 0):

        index = len(names) - 1
        name = names.pop()

        img = cv2.imread(path + name)
        img_grey = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

        images, coords = ims.split(img_grey, sizeh, sizew, sizeh, sizew)
        signal = tex.analize(images, haralick_feature)
        indexes = th.threshold_mean(signal)
        #coords_f = []
        #for x in indexes:
        #	coords_f.append(coords[x])
        coords = coords[indexes]
        coords = cells.group(coords)
        coords = cells.reorganize_coords(coords)

        for c in coords:
            part_img = img_grey[c[2]:c[3], c[0]:c[1]]
            part_img = cv2.resize(part_img, resize_img)
            part = hog.runOne(part_img,
                              orient=hog_orientations,
                              pixels=hog_cell_size,
                              cells=hog_block_size)
            part = part.reshape((1, part.shape[0]))
            Y = net.predict(part)[0, 0]
            if (Y > thresh and c[0] != 0 and c[1] != 500
                    and abs(c[0] - c[1]) * abs(c[2] - c[3]) > 625):
                cells.box2(img, c)
                box = Box()
                box.box = [c[0], c[2], c[1], c[3]]
                boxes.add(index, box)
        cv2.imwrite(path_out + name, img)
    boxes.save('boxes_predicted_ann_25.b')
Exemplo n.º 5
0
def tracker(i):
	boxes = Boxes(len(files))
	tex = Texture()
	ims = Slicer()
	th = Threshold()
	hog = Hog()
	cells = Cells(sizeh,sizew)

	names = list(listdir(path))
	names = names[i:i+batch_size]
	
	
	f = open('data/net/dataset_184_nets_svm/svm_c_2_p_8_o_2.svm','rb')
	clf = pickle.load(f)
	f.close()

	while(len(names)>0):
		index = len(names)-1
		name = names.pop()

		img = cv2.imread(path+name)
		img_grey = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

		images,coords = ims.split(img_grey,sizeh,sizew,sizeh,sizew)
		signal_p = tex.analize(images,haralick_feature)
		indexes = th.threshold_mean(signal_p)
		coords_f = []
		for x in indexes:
			coords_f.append(coords[x])

		coords = cells.group(coords_f)
		coords = cells.reorganize_coords(coords)
		for c in coords:
			part_img = img_grey[c[2]:c[3],c[0]:c[1]]
			part_img = cv2.resize(part_img,resize_img)
			part = hog.runOne(part_img,orient=hog_orientations,pixels=hog_cell_size,cells=hog_block_size)
			part = part.reshape((1,part.shape[0]))
			Y = clf.predict(part)
			if(Y>thresh and c[0]!=0 and c[1]!=500 and abs(c[0]-c[1])*abs(c[2]-c[3])>625 ):
				cells.box2(img,c)
				box = Box()
				box.box = [c[0],c[2],c[1],c[3]]
				boxes.add(index,box)
		cv2.imwrite(path_out+name,img)
	boxes.save('boxes_predicted_svm_25.b')
Exemplo n.º 6
0
def tracker(i):
	boxes = Boxes(len(files))
	tex = Texture()
	ims = Slicer()
	th = Threshold()
	cells = Cells(sizeh,sizew)

	names = list(listdir(path))
	names = names[i:i+batch_size]
	
	
	f = open('svmsemhog.svm','rb')
	clf = pickle.load(f)
	f.close()

	while(len(names)>0):
		index = len(names)-1
		name = names.pop()

		img = cv2.imread(path+name)
		img_grey = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

		images,coords = ims.split(img_grey,sizeh,sizew,sizeh,sizew)
		signal_p = tex.analize(images,haralick_feature)
		indexes = th.threshold_mean(signal_p)
		coords_f = []
		for x in indexes:
			coords_f.append(coords[x])

		coords = cells.group(coords_f)
		coords = cells.reorganize_coords(coords)
		for c in coords:
			part_img = img_grey[c[2]:c[3],c[0]:c[1]]
			part_img = cv2.resize(part_img,resize_img).flatten()
			print(part_img)
			input()
			Y = clf.predict(part_img)
			if(Y>thresh and c[0]!=0 and c[1]!=500 and abs(c[0]-c[1])*abs(c[2]-c[3])>625 ):
				cells.box2(img,c)
				box = Box()
				box.box = [c[0],c[2],c[1],c[3]]
				boxes.add(index,box)
		cv2.imwrite(path_out+name,img)
	boxes.save('boxes_predicted_svm.b')
Exemplo n.º 7
0
import time
from Boxes import Boxes

start = time.time()

#Inicializando variables
best=0
NodosVisitados=0
#Estados y Listas Iniciales
EstInicial= Boxes()
EstInicial.leer_entradas("entradas.txt")

Est_solucion=Boxes()
MejorSolucion=Boxes()
Camino=[]
cola=[]
ListEstGenerados={EstInicial}
cola.append(EstInicial)
EstInicial.padre=None

encontre= False
ReglaAplicable=[]

while(len(cola)>0 ):
    Est_Expl=Boxes()
    Est_Expl.copy(cola.pop())
    ReglaAplicable=Est_Expl.encontrar_reglas_aplicables()
    while len(ReglaAplicable)!=0 :
        R=ReglaAplicable.pop()
        NodosVisitados+=1
        Est_Nuevo=Boxes()
def busqueda_tabu(estado, num_iter):
    global NodosVisitados
    NodosVisitados = 0
    est_actual = Boxes()
    est_candidato = Boxes()
    est_nuevo = Boxes()
    est_mejor_por_ahora = Boxes()
    est_actual.copy(estado)
    lista_tabu = ListaTabu(10)
    lista_tabu.insertar(estado)
    est_mejor_por_ahora.copy(est_actual)
    valor_ant = est_actual.calcular_heuristica()
    j = 1
    exito = False
    while not est_actual.cond_terminacion() and j <= num_iter:
        reglas_aplicables = est_actual.encontrar_reglas_aplicables()
        tam = len(reglas_aplicables)
        num = 0
        for i in range(tam):
            R = reglas_aplicables[i]
            est_nuevo.copy(est_actual)
            est_nuevo.aplicar_regla(R)
            NodosVisitados += 1
            valor = calcular_h(est_nuevo)
            if not lista_tabu.estado_existe(est_nuevo):
                if valor > est_mejor_por_ahora.calcular_heuristica():
                    est_mejor_por_ahora.copy(est_nuevo)
                    num = i
                elif valor > valor_ant or tam == 1:
                    est_candidato.copy(est_nuevo)
                    num = 0
                    valor_ant = valor
        if num == 0:
            est_mejor_por_ahora.copy(est_candidato)
            pass
        lista_tabu.actualizar()
        lista_tabu.insertar(est_mejor_por_ahora)
        est_actual.copy(est_mejor_por_ahora)
        j += 1
    if est_actual.cond_terminacion():
        exito = True
        print(est_actual.stack)
    return est_mejor_por_ahora
    if est_actual.cond_terminacion():
        exito = True
        print(est_actual.stack)
    return est_mejor_por_ahora


def calcular_h(estado):
    h = estado.calcular_heuristica()
    return h


start = time.time()
millis = int(round(time.time() * 1000))

#Inicializando variables
#Estados y Listas Iniciales
EstInicial = Boxes()
EstInicial.leer_entradas("entradas.txt")
Est_solucion = Boxes()
MejorSolucion = Boxes()

Est_solucion = busqueda_tabu(EstInicial, 100)

end = time.time()
millis_end = int(round(time.time() * 1000))
print("Estado Inicial: ", EstInicial.boxlist)
print("Tiempo(ms):", end - start)
print("Mejor Numero de Cajas: ", Est_solucion.calcular_heuristica())
print("Mejor Solucion: ", Est_solucion.stack)
print("Nodos Visitados:", NodosVisitados)
def BusqProfRecursiva(EstExplorado, EstSolucion, Camino, encontre):
    if (EstExplorado.cond_terminacion()):
        encontre = True
        EstSolucion.copy(EstExplorado)
        Camino.insert(0, EstExplorado)
    else:
        ReglasAplicables = EstExplorado.encontrar_reglas_aplicables()
        while len(ReglasAplicables) > 0 and not encontre:
            R = ReglasAplicables.pop()
            EstNuevo = Boxes()
            EstNuevo.copy(EstExplorado)
            EstNuevo.aplicar_regla(R)
            global nodos
            nodos += 1
            if EstNuevo not in ListEstGen:
                EstNuevo.padre = EstExplorado
                EstExplorado.copy(EstNuevo)
                ListEstGen.insert(0, EstExplorado)
                Estado = Boxes()
                Estado.copy(EstExplorado)
                BusqProfRecursiva(Estado, EstSolucion, Camino, encontre)
        if encontre:
            Camino.insert(0, EstExplorado)

    return encontre
        while len(ReglasAplicables) > 0 and not encontre:
            R = ReglasAplicables.pop()
            EstNuevo = Boxes()
            EstNuevo.copy(EstExplorado)
            EstNuevo.aplicar_regla(R)
            global nodos
            nodos += 1
            if EstNuevo not in ListEstGen:
                EstNuevo.padre = EstExplorado
                EstExplorado.copy(EstNuevo)
                ListEstGen.insert(0, EstExplorado)
                Estado = Boxes()
                Estado.copy(EstExplorado)
                BusqProfRecursiva(Estado, EstSolucion, Camino, encontre)
        if encontre:
            Camino.insert(0, EstExplorado)

    return encontre


N = 6

n = 10

EstInicial = Boxes()
EstInicial.leer_entradas("entradas.txt")
EstSolucion = Boxes()
ListEstGen = [EstInicial]
BusqProfundidad(EstInicial, EstSolucion)
print(EstSolucion.stack)
print("Nodos:", nodos)
Exemplo n.º 12
0
import pickle
from teste import bb_intersection_over_union
from Boxes import Boxes, Box

boxes_true = Boxes(540)
boxes_predicted = Boxes(540)

boxes_true.load("boxes.b")
boxes_predicted.load("boxes_predicted_svm_25.b")

total_score = 0

true_positive = 0

false_positive = 0

predicteds = 0
trues = 0

for i in range(len(boxes_predicted.boxes)):
    bxs_p = boxes_predicted.get(i)
    bxs_t = boxes_true.get(i)
    predicteds += len(bxs_p)
    trues += len(bxs_t)
    if (len(bxs_t) > 0):
        for bp in bxs_p:
            for bt in bxs_t:
                score = bb_intersection_over_union(bp.box, bt.normalize())
                if (score > 0.1):
                    total_score += score
                    true_positive += 1