fix indexing errors
This commit is contained in:
parent
73c31c0fb3
commit
f285eca6d6
|
@ -32,9 +32,9 @@ def find_dorminant_color(im):
|
|||
|
||||
return color
|
||||
else:
|
||||
NUM_CLUSTERS = 3
|
||||
NUM_CLUSTERS = 1
|
||||
|
||||
im = im.resize((50, 50))
|
||||
im = im.resize((100, 100))
|
||||
ar = np.asarray(im)
|
||||
shape = ar.shape
|
||||
ar = ar.reshape(np.product(shape[:2]), shape[2]).astype(float)
|
||||
|
@ -56,12 +56,11 @@ if __name__ == '__main__':
|
|||
|
||||
|
||||
|
||||
BOARDER_SIZE = 150
|
||||
BOARDER_SIZE = 300
|
||||
TOP_LEDS = 19
|
||||
RIGHT_LEDS = 11
|
||||
BUTTOM_LEDS = 17
|
||||
LEFT_LEDS = 10
|
||||
REDUCTION = 4
|
||||
NUM_LEDS = TOP_LEDS+RIGHT_LEDS+BUTTOM_LEDS+LEFT_LEDS
|
||||
|
||||
board.set_pin_mode_neopixel(pin_number=2,num_pixels=NUM_LEDS)
|
||||
|
@ -69,8 +68,8 @@ if __name__ == '__main__':
|
|||
|
||||
size = size()
|
||||
|
||||
size.width=pyautogui.size().width/REDUCTION
|
||||
size.height=pyautogui.size().height/REDUCTION
|
||||
size.width=pyautogui.size().width
|
||||
size.height=pyautogui.size().height
|
||||
|
||||
board.neopixel_show()
|
||||
screenshot = pyautogui.screenshot()
|
||||
|
@ -87,20 +86,21 @@ if __name__ == '__main__':
|
|||
right = screenshot.crop(box=[size.width-BOARDER_SIZE,0,size.width,size.height])
|
||||
for i in range(0,TOP_LEDS):
|
||||
segment = top.crop(box=[i*size.width/TOP_LEDS,0,(i+1)*size.width/TOP_LEDS,BOARDER_SIZE])
|
||||
chunk.insert(i,segment)
|
||||
|
||||
for i in range(0,LEFT_LEDS):
|
||||
segment = left.crop(box=[0,i*size.height/LEFT_LEDS,BOARDER_SIZE,(i+1)*size.height/LEFT_LEDS])
|
||||
chunk.insert(TOP_LEDS+RIGHT_LEDS+BUTTOM_LEDS+LEFT_LEDS-i,segment)
|
||||
|
||||
for i in range(0,BUTTOM_LEDS):
|
||||
segment = buttom.crop(box=[i*size.width/BUTTOM_LEDS,0,(i+1)*size.width/BUTTOM_LEDS,BOARDER_SIZE])
|
||||
chunk.insert(TOP_LEDS+RIGHT_LEDS+BUTTOM_LEDS-i,segment)
|
||||
board.neopixel_show()
|
||||
|
||||
chunk.append(segment)
|
||||
|
||||
for i in range(0,RIGHT_LEDS):
|
||||
segment = right.crop(box=[0,i*size.height/RIGHT_LEDS,BOARDER_SIZE,(i+1)*size.height/RIGHT_LEDS])
|
||||
chunk.insert(i+TOP_LEDS,segment)
|
||||
chunk.append(segment)
|
||||
|
||||
for i in reversed(range(0,BUTTOM_LEDS)):
|
||||
segment = buttom.crop(box=[i*size.width/BUTTOM_LEDS,0,(i+1)*size.width/BUTTOM_LEDS,BOARDER_SIZE])
|
||||
chunk.append(segment)
|
||||
|
||||
for i in reversed(range(0,LEFT_LEDS)):
|
||||
segment = left.crop(box=[0,i*size.height/LEFT_LEDS,BOARDER_SIZE,(i+1)*size.height/LEFT_LEDS])
|
||||
chunk.append(segment)
|
||||
|
||||
|
||||
colors = pool.map(find_dorminant_color,chunk)
|
||||
for i in range(0,len(colors)):
|
||||
board.neo_pixel_set_value(i,r=int(colors[i][0]),g=int(colors[i][1]),b=int(colors[i][2]))
|
||||
|
|
Loading…
Reference in New Issue