def main(): uh.set_pixel(0, 0, 255, 0, 0) uh.show() global running global draw draw = drawer.Drawer() print(sys.argv) try: print(int(sys.argv[2])) print(int(sys.argv[2]) == 1) if int(sys.argv[2]) == 1: draw.penInvert(True) except: pass try: print(int(sys.argv[1])) selectMachine(int(sys.argv[1])) print(drawerIPSelected) except: pass draw.penUp() receiveThread = threading.Thread(target=receiveDirection, args=(drawerIPSelected, drawIP.drawerPort)) receiveThread.daemon = True receiveThread.start() uh.set_pixel(2, 0, 0, 255, 0) uh.show() statusThread = threading.Thread(target=giveStatus, args=(drawerIPSelected, )) statusThread.daemon = True statusThread.start() uh.set_pixel(1, 0, 255, 0, 255) uh.show() t0 = time.time() while running: t = time.time() - t0 time.sleep(3600) print(">>>>>>>>>>>> the drawer is in service since " + str(int(t / 3600)) + " hours")
def draw_results(draw_list, output_path): count = 1 res_draw = fld.Drawer(None) res_draw.initialize_drawing() cond_id = count l_count, t_count, f_count = 0, 0, 0 # This is buggy, but yet works with one single while loop is_while = False for item in draw_list: ''' Drawing simple shapes like single line statements $x = 'hello world'; ''' # print("DRAW_RESULTS method") # pprint.pprint(item) ''' Adding the conditional check to use only tuples with the first element as a string ''' if isinstance(item, tuple) and isinstance(item[0], str): drawing_shape = getattr(res_draw, item[0]) if isinstance(item[1], str): drawing_shape(item[1], count) if (count - 1 != cond_id): res_draw.connect(count - 1, count) if cond_id == 1: ''' There is no condition in the resultant drawing ''' res_draw.connect(count - 1, count) ''' Blocked statement - Complex statements Like If-else-elseif and While ''' # print('ITEM 1', (item[1])) # print('ITEM 1 type', type(item[1])) if isinstance(item[1], dict): ''' Makes is_while with the value True if the while_last element is not empty ''' is_while = item[1]['while_last'] != [] # print('CONDITIONAL WITHIN', item) cond_id = count l_count, t_count, f_count = condition_drawing( drawing_shape, res_draw, item, cond_id) # print('Complex BLOCK:', count, item) # print('LATEST COUNTS', l_count, t_count, f_count) ''' When the false block of if-else needs to connect to the outer block ''' if l_count + 1 == count and f_count > 0: # print('LATEST COUNTS', l_count, t_count, f_count, count) res_draw.connect(f_count - 1, count) # The last node of if-true block connects to the rest of # the statement outside the else block # Check if this is not a while loop and the very next element after the while loop # (not is_while and count == t_count-1) if t_count != 0 and count == l_count + 1 and not is_while: if (is_while): print() else: res_draw.connect(t_count - 1, l_count + 1) elif f_count != 0 and count == l_count + 1: res_draw.connect(f_count - 1, l_count + 1) elif is_while: try: res_draw.connect(cond_id, l_count + 1, 'False') except KeyError: pass count += 1 ''' END NODE ''' all_nodes_in_reverse = [x for x in res_draw.get_nodes()[::-1]] if count - 1 == int(res_draw.get_nodes()[-1]): ''' If the last item is less then 1 from the current count, which is 1+ the original last node ''' res_draw.end(count - 1) else: ''' Adds all those elements before the last shallow node into the END node ''' for node in all_nodes_in_reverse: node = int(node) if node == count - 1: break res_draw.end(node) res_draw.get_drawing().write(output_path + '.dot') res_draw.get_drawing().draw(output_path + '.png', prog='dot')
def main(): mouseThread = threading.Thread(target=mouseListener) mouseThread.daemon = True mouseThread.start() draw = drawer.Drawer() draw.penInvert() draw.penUp() draw.toPosition(0, 0) set_brightness(.05) blinked.switchColor('g', [0]) while (not backgroundSub): time.sleep(.1) try: kinect = kinecter.kinect() blinked.switchColor('o', [1]) kinect.start() kinect.backGroundSubstractor(nFrames=100) kinect.stop() blinked.switchColor('p', [1]) while (not drawLoop): time.sleep(1) for k in range(0, 6): time.sleep(.4) blinked.switchColor('r', [7]) time.sleep(.2) blinked.switchColor('k', [7]) for k in range(0, 5): time.sleep(.3) blinked.switchColor('o', [7]) time.sleep(.1) blinked.switchColor('k', [7]) for k in range(0, 5): deltaT = .3 / ((k + 1)) time.sleep(.9 * deltaT) blinked.switchColor('g', [7]) time.sleep(.1 * deltaT) blinked.switchColor('k', [7]) kinect.start() kinect.getDepthFrames(nFrames=100, delay=.01, maxDepth=2049) kinect.stop() blinked.switchColor('c', [1]) kinect.backgroundSubstract(blur=True, level=15) dX, dY, angle, angleZ = kinect.derivateFrames() except Exception as e: print(traceback.format_exc()) blinked.switchColor('g', [5, 6]) draw.penUp() #draw.squareCorner(0,0,widthPaper,heightPaper) blinked.switchColor('g', [5, 6, 7]) nLines = 400 size = 0 nx0 = 0 scale, nx, dist, offsetX, offsetY = spacer(kinect.frames, nx0, 100) print("scale : " + str(scale)) print("n : " + str(nx)) print("offsetX : " + str(offsetX)) print("offsetY : " + str(offsetY)) print("dist : " + str(dist)) xu, yu = scaler(1, 1, scale=scale, offsetX=0, offsetY=0) offsetA = [[-np.pi / 3, 0, np.pi / 3], [-2 * np.pi / 3, np.pi, 2 * np.pi / 3]] blinked.switchColor('a', [0]) blinked.switchColor('g', [1]) offsetX0 = 1 - offsetY offsetY0 = 1 - offsetX if np.random.random() < .12: Nmin = np.random.randint(300, 600) Nmax = np.random.randint(50, 200) nL = np.linspace(Nmin, Nmax, nx, dtype=int) if random.random() < .5: nL = np.flip(nL) else: nL = random.randint(250, 350) * np.ones(nx, dtype=int) if np.random.random() < .098: dMin = .05 + .5 * (1 - np.random.power(5)) dMax = 1 + 4 * np.random.random() d = np.linspace(dMin, dMax, nx) if random.random() < .5: d = np.flip(d) else: d = (.2 + (1 - np.random.power(3))) * np.ones(nx) if np.random.random() < .105: speedMin = .1 + .2 * np.random.random() speedMax = .5 + np.random.random() speed = np.linspace(speedMin, speedMax, nx) if np.random.random() < .5: speed = np.flip(speed) else: speed = (.1 + .1 * np.random.random()) * np.ones(nx) if np.random.random() < .106: cropMin = 0 + .1 * np.random.random() cropMax = .1 + .4 * np.random.random() crop = np.linspace(cropMin, cropMax, nx) if random.random() < .5: crop = np.flip(crop) else: crop = (.05 * random.random()) * np.ones(nx) if np.random.random() < .085: noiseMin = (1 - np.random.power(11)) noiseMax = noiseMin + 1.0 * np.random.random() noise = np.linspace(noiseMin, noiseMax, nx) if np.random.random() < .5: noise = np.flip(noise) else: noise = (1 - np.random.power(11)) * np.ones(nx) if np.random.random() < .19: colors = 2 else: colors = 1 A0 = 0 X2 = [] print("----- Parameters -----") print("-- Lines : " + str(nL) + "--") print("-- dista : " + str(d) + "--") print("-- speed : " + str(speed) + "--") print("-- crops : " + str(crop) + "--") print("-- noise : " + str(noise) + "--") print("-- color : " + str(colors) + "--") try: for l in range(0, colors): print("color : " + str(l)) for j in range(0, nx): blinked.progressColor(j / nx, 'v', 'y', [4]) kFrames = j + nx0 #dist = random.uniform((j-nx*math.floor(j/nx)),1+(j-nx*math.floor(j/nx)))*5 # offsetX = offsetX0 offsetY = offsetY0 + j * dist #print("offset : "+str((offsetX,offsetY))) X2 = drawing(kFrames,kinect.frames,angle,angleZ,draw,nLines = nL[j],scale = scale,A0=A0,\ offsetX = offsetX,offsetY=offsetY,figurePosition = X2,distanceLine = d[l] ,speed = speed[l],cropFactor=crop[l],\ noise = noise[l]) if l == 0: time.sleep(0) X2 = [] A0 = math.pi / 2.0 except Exception as e: print(traceback.format_exc()) draw.toPosition(0, 0) draw.closeDrawer() switchColor(1)
def main(): draw = drawer.Drawer() drawer.penInvert() draw.penUp() draw.toPosition(0, 0) set_brightness(.05) blinked.switchColor('g', [0]) try: kinect = kinecter.kinect() blinked.switchColor('o', [1]) kinect.start() kinect.backGroundSubstractor(nFrames=100) kinect.stop() blinked.switchColor('p', [1]) time.sleep(20) kinect.start() kinect.getDepthFrames(nFrames=40, delay=.01, maxDepth=2049) kinect.stop() blinked.switchColor('c', [1]) kinect.backgroundSubstract(blur=True, level=15) dX, dY, angle, angleZ = kinect.derivateFrames() except Exception as e: print(traceback.format_exc()) blinked.switchColor('g', [5, 6]) draw = drawer.DrawerNet() draw.penUp() draw.squareCorner(0, 0, widthPaper, heightPaper) blinked.switchColor('g', [5, 6, 7]) nLines = 400 size = 0 X2 = [] nx0 = np.int(len(kinect.frames) / 2) scale, nx, dist, offsetX, offsetY = spacer(kinect.frames, nx0 - 1, nx0) print("scale : " + str(scale)) print("n : " + str(nx)) print("offsetX : " + str(offsetX)) print("offsetY : " + str(offsetY)) print("dist : " + str(dist)) xu, yu = scaler(1, 1, scale=scale, offsetX=0, offsetY=0) offsetA = [[-np.pi / 3, 0, np.pi / 3], [-2 * np.pi / 3, np.pi, 2 * np.pi / 3]] blinked.switchColor('a', [0]) blinked.switchColor('g', [1]) offsetX0 = 5 - offsetY offsetY0 = 5 - offsetX d = np.linspace(.1, 4, nx) nL = np.linspace(250, 600, nx) sp = np.linspace(.2, 1.0, nx) crop = np.linspace(0, .6, nx) try: for j in range(0, nx): blinked.progressColor(j / nx, 'v', 'y', [4]) kFrames = j + nx0 #dist = random.uniform((j-nx*math.floor(j/nx)),1+(j-nx*math.floor(j/nx)))*5 # offsetX = offsetX0 offsetY = offsetY0 + j * dist #print("offset : "+str((offsetX,offsetY))) X2 = drawing(kFrames,kinect.frames,angle,angleZ,draw,nLines = 300,scale = scale,A0=0,\ offsetX = offsetX,offsetY=offsetY,figurePosition = X2,distanceLine = .2 ,speed = .2,cropFactor=crop[j]) except Exception as e: print(traceback.format_exc()) draw.toPosition(0, 0) draw.closeDrawer() switchColor(1)
def main(): set_brightness(.05) blinked.switchColor('g', [0]) try: kinect = kinecter.kinect() blinked.switchColor('o', [1]) kinect.start() kinect.backGroundSubstractor(nFrames=100) kinect.stop() blinked.switchColor('p', [1]) time.sleep(10) kinect.start() kinect.getDepthFrames(nFrames=40, delay=.01, maxDepth=2049) kinect.stop() blinked.switchColor('c', [1]) kinect.backgroundSubstract(blur=True, level=20) dX, dY, angle, angleZ = kinect.derivateFrames() except Exception as e: print(traceback.format_exc()) noProblem = False draw = drawer.Drawer(output=False) switchColor(2) print('---Switch is strating') #intializeDrawer() flip = False z = kinect.frames[6] A = angle[6] idx = [6, 7, 8] nLines = 200 size = 0 X = [] X2 = [] scale = 70 xu, yu = scaler(1, 1, scale=scale, offsetX=0, offsetY=0) offsetA = [[-np.pi / 3, 0, np.pi / 3], [-2 * np.pi / 3, np.pi, 2 * np.pi / 3]] blinked.switchColor('a', [0]) blinked.switchColor('g', [1]) rounder = .5 speed = 2 * rounder rounder2 = 3 * rounder if speed < rounder: speed = rounder try: for j in range(0, 64): X3 = [] blinked.progressColor(j / 10, 'v', 'y', [4]) nLines = 200 #75*(3*l+j+1) kFrames = random.randint(0, len(angle) - 1) z = kinect.frames[kFrames] A = angle[kFrames] dist = random.uniform((j - 8 * math.floor(j / 8)), 1 + (j - 8 * math.floor(j / 8))) * 25 offsetX = 5 + math.floor(j / 8) * 10 offsetY = 5 + dist print('offset : ' + str((offsetX, offsetY))) #offsetY = 5+j*27 #offsetX = 5 rounder = .5 speed = 2 * rounder rounder2 = 3 * rounder if speed < rounder: speed = rounder for k in range(0, nLines): blinked.progressColor(k / nLines, 'v', 'y', [5]) size = 0 while (size == 0): xLines = [] yLines = [] size = 0 xChecking = True while xChecking: kx = random.randint(0, 639) ky = random.randint(0, 479) x, y = scaler(kx, ky, scale=scale, offsetX=offsetX, offsetY=offsetY) x = round(x + (.5 - random.random()) * xu, rounder / 2.0) y = round(y + (.5 - random.random()) * yu, rounder / 2.0) x2 = round(x, rounder2) y2 = round(y, rounder2) zTest = z[ky, kx] Atest = A[ky, kx] if (x2, y2) not in X2: xChecking = False running = True if np.isnan(zTest) or np.isnan(Atest): running = False while running: #print('x : '+str((x,y))) #print('k : '+str((kx,ky))) xLines.append(y) yLines.append(x) X.append((x, y)) X3.append((x2, y2)) dx = round(x + speed * np.cos(A[ky, kx]), rounder) dy = round(y + speed * np.sin(A[ky, kx]), rounder) dx2 = round(x + speed * np.cos(A[ky, kx]), rounder2) dy2 = round(y + speed * np.sin(A[ky, kx]), rounder2) dxk, dyk = scaler(dx, dy, scale=scale, offsetX=offsetX, offsetY=offsetY, invert=True) if (dxk > -1) and (dxk < 640) and (dyk > -1) and ( dyk < 480) and size < 100 and ( dx, dy) not in X and (dx2, dy2) not in X2: x = dx y = dy kx = dxk ky = dyk zTest = z[ky, kx] Atest = A[ky, kx] size += speed if np.isnan(zTest) or np.isnan(Atest): running = False else: running = False print('new Line : ' + str(k)) draw.lines(xLines, yLines) for x3 in X3: if x3 not in X2: X2.append(x3) #line(50,50,length=50,angle=0) #line(50,50,length=55,angle=.1) #line(50,50,length=60,angle=.2) #line(50,50,length=65,angle=.4) #line(50,50,length=70,angle=.8) #line(50,50,length=75,angle=1.6) #for k in range(0,10): #draw.square(100,70,10*k/2.0,noise = 3,speed=500) #for j in range(0,10): #square((k+1)*11,(j+1)*11,10,angle=math.pi*(k*j)/(400)) #draw.circle((k+1)*11,(j+1)*11,k+j) except Exception as e: print(traceback.format_exc()) draw.toPosition(0, 0) draw.closeDrawer() switchColor(1)
def main(): set_brightness(.05) switchColor(1) try: frames = kinecter.getFrames(7) dX, dY, angle, angleZ = kinecter.derivateFrames(frames) noProblem = True except Exception as e: print(traceback.format_exc()) noProblem = False draw = drawer.Drawer(output=False) switchColor(2) print('---Switch is strating') #intializeDrawer() flip = False speed = 1 z = frames[6] A = angle[6] idx = [6, 7, 8] nLines = 200 size = 0 X = [] scale = 70 xu, yu = scaler(1, 1, scale=scale, offsetX=0, offsetY=0) offsetA = [[2 * np.pi / 3, 0, np.pi / 3], [2 * np.pi / 3, 0, np.pi / 3]] try: for j in range(0, 3): for l in range(0, 2): #z = frames[j] #A = angle[j] offsetX = 5 + j * 80 offsetY = 5 + l * 80 nLines = 75 * (3 * l + j + 1) xLines, yLines = kinecter.drawGradient(z, A, nLines=nLines, speed=speed, offsetX=offsetX, offsetY=offsetY, scale=scale) draw.lines(xLines, yLines) #line(50,50,length=50,angle=0) #line(50,50,length=55,angle=.1) #line(50,50,length=60,angle=.2) #line(50,50,length=65,angle=.4) #line(50,50,length=70,angle=.8) #line(50,50,length=75,angle=1.6) #for k in range(0,10): #draw.square(100,70,10*k/2.0,noise = 3,speed=500) #for j in range(0,10): #square((k+1)*11,(j+1)*11,10,angle=math.pi*(k*j)/(400)) #draw.circle((k+1)*11,(j+1)*11,k+j) except Exception as e: print(traceback.format_exc()) draw.toPosition(0, 0) draw.closeDrawer() switchColor(1)
def main(): mouseThread = threading.Thread(target = mouseListener) mouseThread.daemon = True mouseThread.start() draw = drawer.Drawer(dx=450,dy=230) draw.penInvert() draw.penUp() draw.toPosition(0,0) set_brightness(.05) blinked.switchColor('g',[0]) #draw.squareCorner(0,0,heightPaper,widthPaper,polar=True,xOffset = -heightPaper/2.0,yOffset =20) #draw.lines([0,0,heightPaper,heightPaper],[0,widthPaper,widthPaper,0],xOffset = -heightPaper/2.0,yOffset =20,polar = True) while(not backgroundSub): time.sleep(.1) try: kinect = kinecter.kinect() blinked.switchColor('o',[1]) kinect.start() kinect.backGroundSubstractor(nFrames=100) kinect.stop() blinked.switchColor('p',[1]) while(not drawLoop): time.sleep(.1) for k in range(0,12): time.sleep(.8) blinked.switchColor('r',[7]) time.sleep(.2) blinked.switchColor('k',[7]) for k in range(0,10): time.sleep(.35) blinked.switchColor('o',[7]) time.sleep(.15) blinked.switchColor('k',[7]) for k in range(0,5): deltaT = .3/((k+1)) time.sleep(.9*deltaT) blinked.switchColor('g',[7]) time.sleep(.1*deltaT) blinked.switchColor('k',[7]) kinect.start() kinect.getDepthFrames(nFrames = 40,delay=.01,maxDepth=2049) kinect.stop() blinked.switchColor('c',[1]) kinect.backgroundSubstract(blur=True,level=15) dX,dY,angle,angleZ = kinect.derivateFrames() except Exception as e: print(traceback.format_exc()) blinked.switchColor('g',[5,6]) blinked.switchColor('g',[5,6,7]) nLines = 400 size = 0 X2 = [] nx0=np.int(len(kinect.frames)/2) scale,nx,dist,offsetX,offsetY = spacer(kinect.frames,nx0-1,nx0) print("scale : "+str(scale)) print("n : "+str(nx)) print("offsetX : "+str(offsetX)) print("offsetY : "+str(offsetY)) print("dist : "+str(dist)) xu,yu = scaler(1,1,scale=scale,offsetX=0,offsetY=0) offsetA=[[-np.pi/3,0,np.pi/3],[-2*np.pi/3,np.pi,2*np.pi/3]] blinked.switchColor('a',[0]) blinked.switchColor('g',[1]) offsetX0 = 5-offsetY offsetY0 = 5-offsetX d = np.linspace(.1,4,nx) nL = np.linspace(250,1200,nx) sp = np.linspace(.2,1.0,nx) crop = np.linspace(0,.6,nx) speedRange = np.linspace(1,10,nx) try: for j in range(0,nx): blinked.progressColor(j/nx,'v','y',[4]) kFrames = j+nx0 #dist = random.uniform((j-nx*math.floor(j/nx)),1+(j-nx*math.floor(j/nx)))*5 # offsetX = offsetX0 offsetY = offsetY0+j*dist #print("offset : "+str((offsetX,offsetY))) X2 = drawing(kFrames,kinect.frames,angle,angleZ,draw,nLines = 200,scale = scale,A0=0,\ offsetX = offsetX,offsetY=offsetY,figurePosition = X2,distanceLine = .1 ,speed = .1 ,cropFactor=0,resolution=.05) except Exception as e: print(traceback.format_exc()) draw.toPosition(0,0) draw.closeDrawer() switchColor(1)
def main(): set_brightness(.05) blinked.switchColor('g', [0]) try: kinect = kinecter.kinect() blinked.switchColor('o', [1]) kinect.start() kinect.backGroundSubstractor(nFrames=100) kinect.stop() blinked.switchColor('p', [1]) time.sleep(120) kinect.start() kinect.getDepthFrames(nFrames=30, delay=.01, maxDepth=2049) kinect.stop() blinked.switchColor('c', [1]) kinect.backgroundSubstract(blur=True, level=20) dX, dY, angle, angleZ = kinect.derivateFrames() except Exception as e: print(traceback.format_exc()) noProblem = False draw = drawer.Drawer(output=False) switchColor(2) print('---Switch is strating') #intializeDrawer() flip = False speed = 3 z = kinect.frames[6] A = angle[6] Az = angleZ[6] idx = [6, 7, 8] nLines = 200 size = 0 X = [] scale = 200 xu, yu = scaler(1, 1, scale=scale, offsetX=0, offsetY=0) offsetA = np.pi / 3 #[[-np.pi/3,0,np.pi/3],[-2*np.pi/3,np.pi,2*np.pi/3]] blinked.switchColor('a', [0]) blinked.switchColor('g', [1]) try: for l in range(0, 1): for j in range(0, 1): nLines = 1000000 #75*(3*l+j+1) #z = frames[j] #A = angle[j] offsetX = 5 + j * 80 offsetY = 5 + l * 80 for k in range(0, nLines): size = 0 while (size == 0): print('new Line : ' + str(k)) xLines = [] yLines = [] size = 0 kx = random.randint(0, 639) ky = random.randint(0, 479) x, y = scaler(kx, ky, scale=scale, offsetX=offsetX, offsetY=offsetY) x = round(x + (.5 - random.random()) * xu, .1) y = round(y + (.5 - random.random()) * yu, .1) zTest = z[ky, kx] Atest = A[ky, kx] Aztest = Az[ky, kx] running = True if np.isnan(zTest) or np.isnan(Atest) or np.isnan( Aztest): running = False if running: R = random.random() * ( speed * (1 + np.sin(A[ky, kx] + offsetA)) * np.sin(Az[ky, kx])) xLines.append(round(x - R * np.cos(A[ky, kx]), .1)) xLines.append(round(x + R * np.cos(A[ky, kx]), .1)) yLines.append(round(y - R * np.sin(A[ky, kx]), .1)) yLines.append(round(y + R * np.sin(A[ky, kx]), .1)) draw.lines(xLines, yLines) size += 1 #line(50,50,length=50,angle=0) #line(50,50,length=55,angle=.1) #line(50,50,length=60,angle=.2) #line(50,50,length=65,angle=.4) #line(50,50,length=70,angle=.8) #line(50,50,length=75,angle=1.6) #for k in range(0,10): #draw.square(100,70,10*k/2.0,noise = 3,speed=500) #for j in range(0,10): #square((k+1)*11,(j+1)*11,10,angle=math.pi*(k*j)/(400)) #draw.circle((k+1)*11,(j+1)*11,k+j) except Exception as e: print(traceback.format_exc()) draw.toPosition(0, 0) draw.closeDrawer() switchColor(1)
def main(): global speedList global speedMinList global A0List mouseThread = threading.Thread(target=mouseListener) mouseThread.daemon = True mouseThread.start() draw = drawer.Drawer(dx=350, dy=230) draw.penInvert(True) draw.penUp() draw.toPosition(0, 0) set_brightness(.05) blinked.switchColor('g', [0]) #draw.squareCorner(0,0,heightPaper,widthPaper,polar=True,xOffset = -heightPaper/2.0,yOffset =20) #draw.lines([0,0,heightPaper,heightPaper],[0,widthPaper,widthPaper,0],xOffset = -heightPaper/2.0,yOffset =20,polar = True) while (not backgroundSub): time.sleep(.1) try: kinect = kinecter.kinect() blinked.switchColor('o', [1]) kinect.start() kinect.backGroundSubstractor(nFrames=100) kinect.stop() blinked.switchColor('p', [1]) while (not drawLoop): time.sleep(1) #for k in range(0,12): # time.sleep(.8) # blinked.switchColor('r',[7]) # time.sleep(.2) # blinked.switchColor('k',[7]) for k in range(0, 10): time.sleep(.35) blinked.switchColor('o', [7]) time.sleep(.15) blinked.switchColor('k', [7]) for k in range(0, 5): deltaT = .3 / ((k + 1)) time.sleep(.9 * deltaT) blinked.switchColor('g', [7]) time.sleep(.1 * deltaT) blinked.switchColor('k', [7]) kinect.start() kinect.getDepthFrames(nFrames=1, delay=.01, maxDepth=2049) kinect.stop() blinked.switchColor('c', [1]) kinect.backgroundSubstract(blur=True, level=5) dX, dY, angle, angleZ = kinect.derivateFrames() except Exception as e: print(traceback.format_exc()) colorsChosen() nLines = 400 size = 0 X2 = [] nx0 = np.int(len(kinect.frames) / 2) scale, offsetX, offsetY = spacer(kinect.frames) print("scale : " + str(scale)) print("offsetX : " + str(offsetX)) print("offsetY : " + str(offsetY)) xu, yu = scaler(1, 1, scale=scale, offsetX=0, offsetY=0) blinked.switchColor('a', [0]) blinked.switchColor('g', [1]) offsetX0 = 5 - offsetY offsetY0 = 5 - offsetX for k in range(0, nColors): A0List.append(2 * np.pi * np.random.rand()) speedMinList.append(1 + 10 * (1 - np.random.power(6))) speedList.append(10 + 10 * (1 - np.random.power(3))) A1 = 2 * np.pi * np.random.rand() try: #dist = random.uniform((j-nx*math.floor(j/nx)),1+(j-nx*math.floor(j/nx)))*5 # offsetX = offsetX0 offsetY = offsetY0 #print("offset : "+str((offsetX,offsetY))) X2 = drawing(0,kinect.frames,angle,angleZ,draw,nLines = 40000,scale = scale,A0=A0List[colorK],A1=A1,noise = 0,\ offsetX = offsetX,offsetY=offsetY,figurePosition = X2,distanceLine = .1 ,speed = speedList[colorK] ,speedMin = speedMinList[colorK],cropFactor=0,resolution=.05) except Exception as e: print(traceback.format_exc()) draw.toPosition(0, 0) draw.closeDrawer() switchColor(1)