#im.save("result.png") #exit() total_frame = (stim_offset + stim_duration) / 1000.0 * fps # generate movie if NOMOVIE is False: fourcc = cv2.VideoWriter_fourcc(*'XVID') out = cv2.VideoWriter('./' + dirname + '/' + filename + '.avi', fourcc, fps, (480, 480), False) for t in range(int(total_frame)): im_gray = np.zeros((480, 480), dtype='uint8') for x, y in product(range(width), range(height)): hexarray[x, y] = SW.waveheightave(x, y, t * 1000.0 / fps) # print(hexarray[x,y]) xx, yy = coord(x * hex_size, y * hex_size) #draw.ellipse((int(xx),int(yy),int(xx+hex_size),int(yy+hex_size)), fill=(int(255 * hexarray[x,y]),int(255 * hexarray[x,y]),int(255 * hexarray[x,y])), outline=(0,0,0)) for dx, dy in product(range(int(xx), int(xx + hex_size)), range(int(yy), int(yy + hex_size))): if (dx - xx - hex_size / 2)**2 + ( dy - yy - hex_size / 2)**2 <= (hex_size / 2)**2: im_gray[dy, dx] = int(255 * hexarray[x, y]) # print(im_gray) # exit() out.write(im_gray) out.release() # comvert array to stmfile if NOCONVERT is False: stims = [] for x, y in product(range(width), range(height)):
# draw.ellipse((int(xx),int(yy),int(xx+hex_size),int(yy+hex_size)), fill=(int(255 * hexarray[x,y]),int(255 * hexarray[x,y]),int(255 * hexarray[x,y])), outline=(0,0,0)) #im.save("result.png") #exit() total_frame = (stim_offset + stim_duration) / 1000.0 * fps # generate movie if NOMOVIE is False: fourcc = cv2.VideoWriter_fourcc(*'XVID') out = cv2.VideoWriter('./' + dirname + '/' + filename + '.avi',fourcc,fps,(480,480),False) for t in range(int(total_frame)): im_gray = np.zeros((480,480), dtype = 'uint8') for x,y in product(range(width),range(height)): hexarray[x,y] = SW.waveheightave(x,y,t * 1000.0 / fps) # print(hexarray[x,y]) xx,yy = coord(x*hex_size,y*hex_size) #draw.ellipse((int(xx),int(yy),int(xx+hex_size),int(yy+hex_size)), fill=(int(255 * hexarray[x,y]),int(255 * hexarray[x,y]),int(255 * hexarray[x,y])), outline=(0,0,0)) for dx,dy in product(range(int(xx),int(xx+hex_size)), range(int(yy),int(yy+hex_size))): if (dx - xx - hex_size/2)**2 + (dy - yy - hex_size/2)**2 <= (hex_size/2)**2: im_gray[dy,dx] = int(255 * hexarray[x,y]) # print(im_gray) # exit() out.write(im_gray) out.release() # comvert array to stmfile if NOCONVERT is False: stims = [] for x,y in product(range(width),range(height)): start,end,period = SW.peaktiming(x,y) stim = {}