Beispiel #1
0
def calibrate():
	#Take a known sound, take a recording from a microphone, and figure out how to Transform
	#the recording to the known sound.

	#Will finish at some time, I guess now I'll just equalize.

	threads = [] #Array of threads.

	#Initialize the mic streams
	for i in range(0,len(micChannels)):
		t = threading.Thread(target=recordThread, args=(i,))
		threads.append(t)
		#Run the threads in parallel
	for j in range(0,len(threads)):
		threads[j].start()
		#Streams should autoclose after completion.

	for k in range(0,len(threads)):
		threads[k].join()
		#Wait until all threads are finished.


	equalize()

	if len(streamData) == 2:
		streamData[1] = np.asArray(streamData[1])
		streamData[1] = np.toList(np.multiply(streamData[1], eqRatio))

	streamAnalysis()
Beispiel #2
0
def butter_filter(freq, fs=RATE, order=5):
	nyq = 0.5 * fs
	low = freq / nyq
	b, a = butter(order, low, 'lowpass')
	for i in streamData:
		i = np.asArray(i)
		i = lfilter(b, a, i)
		i = np.tolist(i)
Beispiel #3
0
def imageToNumpy(image):
    image = np.asArray(image)
    userUpload = Image.open(image)
    userUpload.show()
    w, h = userUpload.size

    print(userUpload.size)

    width = w
    height = h

    if w > 1500:
        width = 1499
        height = h * (1499 / w)
    if h > 1500:
        height = 1499
        width = w * (1499 / h)
    userUpload = userUpload.resize((int(width), int(height)))
    userUpload.show()
    def worldToPixels(world):
        '''
        TODO
        Compute the pixel coordinates given the world coordinates
        and an inverse transformation matrix. You have access to the
        transformationMatrixInv variable above.
        '''

        world_y, world_x = world
        world_arr = np.asArray([world_x, world_y, 1])

        scaled_pixel_arr = np.dot(transformationMatrixInv, world_arr)
        scaled_pixel_list = np.toList(scaled_pixel_arr)

        w_inverse = scaled_pixel_list[2]

        pixel_x = scaled_pixel_list[0] / w_inverse
        pixel_y = scaled_pixel_list[1] / w_inverse

        pixelCoord = (pixel_y, pixel_x)

        return pixelCoord