def draw_R(N1, N2, draw_type):
    para_R = [
        [-10, 0, 5, 100, 0.2, 0.6, 13, 0],
        [2, 3, -4, 100, 0.9, 10, 8 / 3, 0],
        [2, 3, -4, 100, 0.1, 1, 6, 0],
        [160, 10, 2, 100, 0.7, 2, 5, 0],
        [1.e-4, 0, 1, 100, 0.9, 10, 8 / 3, 0],
        [1.e-4, 0, 1, 100, 0.95, 10, 8 / 3, 0],
        [1.e-4, 0, 1, 100, 1.01, 10, 8 / 3, 0],
        [1.e-4, 0, 1, 100, 1.2, 10, 8 / 3, 0],
        [2, 3, -4, 100, 8, 10, 8 / 3, 0],
        [160, 10, 2, 100, 10, 2, 5, 0],
        [-10, 0, 0, 100, 13.962, 10, 8 / 3, 0],
        [0, 0, 10, 100, 13.962, 10, 8 / 3, 0],
        [3, 6, 8, 100, 15, 10, 8 / 3, 0],
        [3, 6, 8, 100, 24, 10, 8 / 3, 0],
        [6.1101, 6.1101 + 1.e-5, 14, 100, 15, 10, 8 / 3, 0],
        [7.6594, 7.6594 + 1.e-5, 23, 100, 24, 10, 8 / 3, 0],
        [3, 2, 6, 100, 28, 10, 8 / 3, 0],
        [50, 20, -60, 100, 28, 10, 8 / 3, 0],
        [8.6, 8.5, 28, 100, 80, 10, 8 / 3, 0],
        [8.6, 8.6, 28.1, 100, 80, 10, 8 / 3, 0],
        [8.6, 8.7, 28, 100, 80, 10, 8 / 3, 0],
        [8.6, 8.6, 28, 100, 80, 10, 8 / 3, 0],
        [100, 100, 100, 100, 28, 1, 8 / 3, 0],
        [100, 100, 100, 100, 28, 10, 8 / 3, 0],
        [1, 1, -1, 100, 470 / 19, 10, 8 / 3, 0],
        [1, 1, -.95, 100, 470 / 19, 10, 8 / 3, 0],
        [19.53, 19.53, 143, 100, 144, 10, 8 / 3, 0],
        [19.53, 19.53, 142, 100, 144, 10, 8 / 3, 0],
        [7.956, 7.956, 23.737, 100, 24.737, 10, 8 / 3, 0],
        [7.956, 7.957, 23.737, 100, 24.737, 10, 8 / 3, 0],
        [1, 1, -1, 100, 167, 10, 8 / 3, 0],
        [1, 1, -.95, 100, 167, 10, 8 / 3, 0],
    ]

    if draw_type == "anima":
        for i in range(len(para_R)):
            para_R[i].append("../Project_Videos/tendency/" + str(i) +
                             "Test.mp4")

        for i in range(N1, N2):
            Draw.Draw(para_R[i][0:8], para_R[i][8], "anima")

    if draw_type == "static":
        for i in range(len(para_R)):
            para_R[i].append("../Project_Pictures/final/" + str(i) + ".png")

        for i in range(N1, N2):
            Draw.Draw(para_R[i][0:8], para_R[i][8], "static")

    else:
        return "Wrong Draw Type!"
Beispiel #2
0
    def __gen_possibilities(self):

        if self.display:
            pbar = tqdm.tqdm(total=12000000)
            for x in range(0, 1000000):
                for y in range(0, 12):
                    self.possibilities.append(Draw(x, y))
                pbar.update(12)
            pbar.close()
        else:
            for x in range(0, 1000000):
                for y in range(0, 12):
                    self.possibilities.append(Draw(x, y))
Beispiel #3
0
 def __init__(self, row, col):
     self.row, self.col = row, col
     self.color_num = len(Game.colors) - 1
     self.matrix = [[0 for _ in range(col)] for _ in range(row)]
     self.chosen = self.highlighted = None
     self.q = queue.Queue()
     self.generate()
     self.height, self.width = self.get_size()
     self.drawer = Draw(self, row, col)
Beispiel #4
0
 def Make_Sequential_Draw(self):
     draw = Draw()
     draw.n_1 = self.random.Get_10()
     draw.n_2 = self.random.Get_10()
     draw.n_3 = self.random.Get_10()
     draw.n_4 = self.random.Get_10()
     draw.n_5 = self.random.Get_10()
     draw.n_6 = self.random.Get_10()
     draw.symbol = self.random.Get_12()
     return draw
Beispiel #5
0
def transformation(imCalRGB, calData, tx1, ty1, tx2, ty2, tx3, ty3, tx4, ty4):

    points = calData.points

    ## sectors are sometimes different -> make accessible
    # used when line rectangle intersection at specific segment is used for transformation:
    newtop = destinationPoint(calData.dstpoints[0], calData)
    newbottom = destinationPoint(calData.dstpoints[1], calData)
    newleft = destinationPoint(calData.dstpoints[2], calData)
    newright = destinationPoint(calData.dstpoints[3], calData)

    # get a fresh new image
    new_image = imCalRGB.copy()

    # create transformation matrix
    src = np.array([(points[0][0] + tx1, points[0][1] + ty1),
                    (points[1][0] + tx2, points[1][1] + ty2),
                    (points[2][0] + tx3, points[2][1] + ty3),
                    (points[3][0] + tx4, points[3][1] + ty4)], np.float32)
    dst = np.array([newtop, newbottom, newleft, newright], np.float32)
    transformation_matrix = cv2.getPerspectiveTransform(src, dst)

    new_image = cv2.warpPerspective(new_image, transformation_matrix,
                                    (800, 800))

    # draw image
    drawBoard = Draw()
    new_image = drawBoard.drawBoard(new_image, calData)

    cv2.circle(new_image, (int(newtop[0]), int(newtop[1])), 2,
               cv.CV_RGB(255, 255, 0), 2, 4)
    cv2.circle(new_image, (int(newbottom[0]), int(newbottom[1])), 2,
               cv.CV_RGB(255, 255, 0), 2, 4)
    cv2.circle(new_image, (int(newleft[0]), int(newleft[1])), 2,
               cv.CV_RGB(255, 255, 0), 2, 4)
    cv2.circle(new_image, (int(newright[0]), int(newright[1])), 2,
               cv.CV_RGB(255, 255, 0), 2, 4)

    cv2.imshow('manipulation', new_image)

    return transformation_matrix
Beispiel #6
0
 def open_uix():
     codeinput = CodeInput(lexer=KivyLexer())
     Draw().run()
Beispiel #7
0
# print(FIND3_API.Post_Data(jsonData1))
# print(FIND3_API.Post_Data(jsonData2))
# print(FIND3_API.Post_Data(jsonData3))
#print(FIND3_API.Post_PassiveData(jsonData1))
#print(FIND3_API.Post_PassiveData(jsonData2))
#print(FIND3_API.Post_PassiveData(jsonData3))
#print(FIND3_API.Post_Data(FIND3_API.Return_Json(0,-60)))
#print(FIND3_API.Post_Data(FIND3_API.Return_Json(1,-50)))
#print(FIND3_API.Post_Data(FIND3_API.Return_Json(2,-60)))

text = FIND3_API.Get_Database(familyName)
WriteFile(fileName, text)
TrackedDevices, Signals, Sensors = ParseFile(fileName)

WriteFile("TrackedDevices.txt", TrackedDevices, isJson=True)
WriteFile("Signals.txt", Signals, isJson=True)
WriteFile("Sensors.txt", Sensors, isJson=True)

draw = Draw()
sensorPositions = {"a": [2, 3.29], "c": [6.35, 2.1], "b": [6.35, 9.5]}
draw.SetMap(12, 12, 1)
timestamp = "1554820270500"
draw.Draw(sensorPositions, TrackedDevices, Signals, Sensors, timestamp)

# Signals=[{"timestamp": "1", "deviceID": "G", "sensordata": {"a": -87,"c":-74,"b":-85,}}]
#
# draw=Draw()
# sensorPositions={"a":[5,5],"b":[5,10],"c":[15,5]}
# draw.SetMap(20,15,1)
# timestamp="1"
# draw.Draw(sensorPositions,TrackedDevices,Signals,Sensors,timestamp)
Beispiel #8
0
        l.Value = l.Tail

def VergelijkYN(l)
    while l.IsEmpty == False:
        tempL = l.Value
        if event.type == MOUSEBUTTONUP and mousex > l.PositionX and mousex < (l.PositionX + 42) and mousey > l.PositionY and mousey < (l.PositionY + 42)
                l.PositionY = l.PositionY - 42

        l.Value = l.Tail


    while start == True:
        DISPLAYSURF.fill(WHITE)
        DISPLAYSURF.blit(spelImg, (0 ,0))
        Draw(player1soldaat)
        for event in pygame.event.get():
            if event.type == MOUSEMOTION:
                mousex, mousey = pygame.mouse.get_pos()
            if event.type == KEYUP and event.key == K_ESCAPE or (mousex > 1198 and mousex < 1360 and mousey > 690 and mousey < 763):
                start = False
            if event.type == MOUSEBUTTONUP and mousex > 775 and mousex < 937 and mousey > 440 and mousey < 478:
                start = False
                train = True
            if event.type == MOUSEBUTTONUP and mousex > 775 and mousex < 937 and mousey > 230 and mousey < 268:
                    walk = True
                    fight = False
                    build = False
                    train = False
                    instruction = False
            if event.type == MOUSEBUTTONUP and mousex > 775  and mousex < 937 and mousey > 300 and mousey < 338:
Beispiel #9
0
# plt.hist(rvs2,bins=hist)
# plt.show()
import Model5
import Environment
import Individual
import Cal_para
import Draw

args_model = [0.6, -0.21]
args_time = [2, 1, 10000]
args_steps = [-1.80, 5]
args_grid = [[20, 20], [10, 2, 10, 2], 200]
time = 100
temp_routeList = []
Envir = Environment.normal_Environment(dimenssion=[20],
                                       xy_args=args_grid[1],
                                       size=200)
#model=Model5.HomeOrWork_Model(args_model=args_model,args_t=args_time,args_steps=args_steps,environment=Envir,visited_Place=[],homeposition=random.choice(Envir.locations),workposition=random.choice(Envir.locations))
model = Individual.Nomal_Individual(args_model=args_model,
                                    args_t=args_time,
                                    args_step=args_steps,
                                    simulate_time=time,
                                    Environment=Envir)
model.simulate()
print(9)
cal = Cal_para.Cal_para(model.data_mid.route, Envir)
dis = cal.get_visit_location_number_disput()
draw = Draw.Draw(cal, [model.home_loc, model.work_loc])
draw.draw_visit_location_number_disput()
draw.draw_location_disput(model.data_mid)
print(1)
Beispiel #10
0
def Main(menu,player1,player1soldaat):
    while menu == True:
        start = False
        rules = False
        rulespage2 = False
        DISPLAYSURF.fill(WHITE)
        DISPLAYSURF.blit(SpelImg, (0,0))
        DISPLAYSURF.blit(start2Img, (928.5,250))
        DISPLAYSURF.blit(start4Img, (928.5,325))
        DISPLAYSURF.blit(rulesImg, (928.5,400))
        DISPLAYSURF.blit(endImg,(928.5,475))
        for event in pygame.event.get():

            if event.type == MOUSEMOTION:
                    mousex, mousey = pygame.mouse.get_pos()
            if event.type == QUIT or (event.type == KEYUP and event.key == K_ESCAPE) or (event.type == MOUSEBUTTONUP and mousex > 928.5 and mousex < 778.5 and mousey > 475 and mousey < 519):
                    pygame.quit()
                    sys.exit()

            if event.type == MOUSEBUTTONUP and mousex > 928.5 and mousex < 1042.5 and mousey > 200 and mousey < 244:
                    DISPLAYSURF.blit(spelImg, (0,0))

            if event.type == MOUSEBUTTONUP and mousex > 928.5 and mousex < 1042.5 and mousey > 250 and mousey < 294: #player 2
                    menu = False
                    start = True
                    rules = False
                    rulespage2 = False

            if event.type == MOUSEBUTTONUP and mousex > 928.5 and mousex < 1042.5 and mousey > 325 and mousey < 369: #player 4
                    menu = False
                    start = True
                    rules = False
                    rulespage2 = False


            if event.type == MOUSEBUTTONUP and mousex > 928.5 and mousex < 1042.5 and mousey > 400 and mousey < 444: #rules
                    menu = False
                    start = False
                    rules = True
                    rulespage2 = False



            pygame.display.update()

    while start == True:
        DISPLAYSURF.fill(WHITE)
        DISPLAYSURF.blit(spelImg, (0 ,0))
        Draw(player1soldaat)
        for event in pygame.event.get():
            if event.type == MOUSEMOTION:
                mousex, mousey = pygame.mouse.get_pos()
            if event.type == KEYUP and event.key == K_ESCAPE or (mousex > 1198 and mousex < 1360 and mousey > 690 and mousey < 763):
                start = False
            if event.type == MOUSEBUTTONUP and mousex > 775 and mousex < 937 and mousey > 440 and mousey < 478:
                start = False
                train = True
            if event.type == MOUSEBUTTONUP and mousex > 775 and mousex < 937 and mousey > 230 and mousey < 268:
                    walk = True
                    fight = False
                    build = False
                    train = False
                    instruction = False
            if event.type == MOUSEBUTTONUP and mousex > 775  and mousex < 937 and mousey > 300 and mousey < 338:
                    walk = False
                    fight = True
                    build = False
                    train = False
                    instruction = False
            if event.type == MOUSEBUTTONUP and mousex > 775 and mousex < 937 and mousey > 370 and mousey < 408:
                    walk = False
                    fight = False
                    build = True
                    train = False
                    instruction = False
            if event.type == MOUSEBUTTONUP and mousex > 775 and mousex < 937 and mousey > 440 and mousey < 478:
                walk = False
            if event.type == MOUSEBUTTONUP and mousex > 802 and mousex < 965 and mousey > 691 and mousey < 730:
                    walk = False
                    fight = False
                    build = False
                    train = False
                    instruction = True
            if event.type == MOUSEBUTTONUP and mousex > 998 and mousex < 1160 and mousey > 725 and mousey < 763:
                end = True







            pygame.display.update()


    while train == True:
        DISPLAYSURF.fill(WHITE)
        DISPLAYSURF.blit(train1, (0 ,0))
        Draw(player1soldaat)
        for event in pygame.event.get():
            if event.type == MOUSEMOTION:
                mousex, mousey = pygame.mouse.get_pos()
            if event.type == KEYUP and event.key == K_ESCAPE or (mousex > 1198 and mousex < 1360 and mousey > 690 and mousey < 763):
                train = False
            if event.type == MOUSEBUTTONUP and mousex > 936 and mousex < 1114 and mousey > 259 and mousey < 296:
                soldaat = True
                train = False
            pygame.display.update()

    while soldaat == True:
        DISPLAYSURF.fill(WHITE)
        DISPLAYSURF.blit(train1, (0 ,0))
        Draw(player1soldaat)
        for event in pygame.event.get():
            if event.type == MOUSEMOTION:
                mousex, mousey = pygame.mouse.get_pos()
            if event.type == MOUSEBUTTONUP and mousex > player1.startPosX and mousex < (player1.startPosX + 42) and mousey > player1.startPosY and mousey < (player1.startPosY +42):
                player1soldaat = Node(Soldier(sol1,(player1.startPosX+42),player1.startPosY),player1soldaat)
            pygame.display.update()







    Main(False,player1,player1soldaat)
Beispiel #11
0
import numpy as np
import Data, InitPeople, Draw, Rule, Income
import matplotlib.pyplot as plt
import matplotlib.animation
import time

init = InitPeople.InitPeoples()
draw = Draw.Draw()
# move=Rule.PeopleMove()
income = Income.outDirection()
# allPeople=init.creatPeople()
allPeople = init.creatForemostPeo()
allWall = init.creatWall()
allExit = init.creatExit()
# while Data.flag:

# for p in allPeople:
#     income.outDirection(p,allPeople)
#     direction=max(p.allInComeBySort.items(),key=lambda  x:x[1])[0]
#     print('direction ==',direction)
while Data.flag:
    for p in allPeople:
        income.outDirection(p, allPeople)

        direction = max(p.allInComeBySort.items(), key=lambda x: x[1])[0]

        Rule.chickOverAround(p, allPeople)
        Rule.PeopleMove(p, direction)
        # print(p.grendIncome)
        # print(p.isInGrend)
        print(p.allInComeBySort)
Beispiel #12
0
def main():
    ConSerial().serial_ports
    Draw().run()
Beispiel #13
0
def calibrate(cam_R, cam_L):

    try:
        success, imCalRGB_R = cam_R.read()
        _, imCalRGB_L = cam_L.read()

    except:
        print "Could not init cams"
        return

    imCal_R = imCalRGB_R.copy()
    imCal_L = imCalRGB_L.copy()

    imCalRGBorig = imCalRGB_R.copy()

    cv2.imwrite("frame1_R.jpg", imCalRGB_R)  # save calibration frame
    cv2.imwrite("frame1_L.jpg", imCalRGB_L)  # save calibration frame

    global calibrationComplete
    calibrationComplete = False

    while calibrationComplete == False:
        #Read calibration file, if exists
        if os.path.isfile("calibrationData_R.pkl"):
            try:
                calFile = open('calibrationData_R.pkl', 'rb')
                calData_R = CalibrationData()
                calData_R = pickle.load(calFile)
                calFile.close()

                calFile = open('calibrationData_L.pkl', 'rb')
                calData_L = CalibrationData()
                calData_L = pickle.load(calFile)
                calFile.close()

                #copy image for old calibration data
                transformed_img_R = imCalRGB_R.copy()
                transformed_img_L = imCalRGB_L.copy()

                transformed_img_R = cv2.warpPerspective(
                    imCalRGB_R, calData_R.transformation_matrix, (800, 800))
                transformed_img_L = cv2.warpPerspective(
                    imCalRGB_L, calData_L.transformation_matrix, (800, 800))

                draw_R = Draw()
                draw_L = Draw()

                transformed_img_R = draw_R.drawBoard(transformed_img_R,
                                                     calData_R)
                transformed_img_L = draw_L.drawBoard(transformed_img_L,
                                                     calData_L)

                cv2.imshow("Right Cam", transformed_img_R)
                cv2.imshow("Left Cam", transformed_img_L)

                test = cv2.waitKey(0)
                if test == 13:
                    cv2.destroyAllWindows()
                    #we are good with the previous calibration data
                    calibrationComplete = True
                    return calData_R, calData_L
                else:
                    cv2.destroyAllWindows()
                    calibrationComplete = True
                    #delete the calibration file and start over
                    os.remove("calibrationData_R.pkl")
                    os.remove("calibrationData_L.pkl")
                    #restart calibration
                    calibrate(cam_R, cam_L)

            #corrupted file
            except EOFError as err:
                print err

        # start calibration if no calibration data exists
        else:

            calData_R = CalibrationData()
            calData_L = CalibrationData()

            imCal_R = imCalRGB_R.copy()
            imCal_L = imCalRGB_L.copy()

            calData_R.points = getTransformationPoints(imCal_R, "right")
            # 13/6: 0 | 6/10: 1 | 10/15: 2 | 15/2: 3 | 2/17: 4 | 17/3: 5 | 3/19: 6 | 19/7: 7 | 7/16: 8 | 16/8: 9 |
            # 8/11: 10 | 11/14: 11 | 14/9: 12 | 9/12: 13 | 12/5: 14 | 5/20: 15 | 20/1: 16 | 1/18: 17 | 18/4: 18 | 4/13: 19
            # top, bottom, left, right
            # 12/9, 2/15, 8/16, 13/4
            calData_R.dstpoints = [12, 2, 8, 18]
            calData_R.transformation_matrix = manipulateTransformationPoints(
                imCal_R, calData_R)

            calData_L.points = getTransformationPoints(imCal_L, "left")
            # 12/9, 2/15, 8/16, 13/4
            calData_L.dstpoints = [12, 2, 8, 18]
            calData_L.transformation_matrix = manipulateTransformationPoints(
                imCal_L, calData_L)

            cv2.destroyAllWindows()

            print "The dartboard image has now been normalized."
            print ""

            cv2.imshow(winName4, imCal_R)
            test = cv2.waitKey(0)
            if test == 13:
                cv2.destroyWindow(winName4)
                cv2.destroyAllWindows()

            #write the calibration data to a file
            calFile = open("calibrationData_R.pkl", "wb")
            pickle.dump(calData_R, calFile, 0)
            calFile.close()

            calFile = open("calibrationData_L.pkl", "wb")
            pickle.dump(calData_L, calFile, 0)
            calFile.close()

            calibrationComplete = True

            return calData_R, calData_L

    cv2.destroyAllWindows()
Beispiel #14
0











while start == True:
        DISPLAYSURF.fill(WHITE)
        DISPLAYSURF.blit(spelImg, (0 ,0))
        Draw(player1soldaat)
        Draw(player1tank)
        for event in pygame.event.get():
            if event.type == MOUSEMOTION:
                mousex, mousey = pygame.mouse.get_pos()
            if event.type == KEYUP and event.key == K_ESCAPE or (mousex > 1198 and mousex < 1360 and mousey > 690 and mousey < 763):
                start = False
            if event.type == MOUSEBUTTONUP and mousex > 775 and mousex < 937 and mousey > 440 and mousey < 478:
                start = False
                train = True
            if event.type == MOUSEBUTTONUP and mousex > 775 and mousex < 937 and mousey > 230 and mousey < 268:
                    walk = True
                    fight = False
                    build = False
                    train = False
                    instruction = False
Beispiel #15
0
rawpath = planner.path()

from Draw import *
###################         SMOOTHING
spath = smooth(grid=grid, path=rawpath[:])

###################         WAYPOINTING
waypoints = waypointing(path=spath, speed=0.5)

###################         FORCE FIELD
waypoints = forceField(planner=planner, waypoints=waypoints, neighborhood=2)

###################         WAYPOINTING AGAIN
waypoints = waypointing(path=waypoints, speed=0.5)

###################         DRAWING

d = Draw(rows=grid.rows, cols=grid.cols, cellSize=20)
d.drawGrid()

d.fillCells(grid=grid.obstacleGrid, color='green')
d.fillCells(grid=grid.closedGrid, color='grey')

d.drawLine(path=rawpath, color='red')
d.drawLine(path=spath, color='orange')
d.drawLine(path=waypoints, color='blue')

# d.drawPoints(pointset=waypoints, color='blue')

d.loop()
Beispiel #16
0
from ResetDeck import * # Imports the Reset function for Deck.txt
from Draw import * # Imports the Draw class which allows us to draw cards from Deck.txt

ResetDeck() # Resets Deck.txt to default

Card=Draw() # Draws a card using the class Draw
Card1=Card.Card # Turns the card drawn over to Card1
Card=Draw()
Card2=Card.Card
Card=Draw()
Card3=Card.Card
Card=Draw()
Card4=Card.Card
Card=Draw()
Card5=Card.Card

print([Card1,Card2,Card3,Card4,Card5]) # Prints the 5 cards drawn