Skip to content
Snippets Groups Projects
Commit bdcb791b authored by Dorababu A's avatar Dorababu A
Browse files

clean the code

parent 316e3b3d
No related branches found
No related tags found
No related merge requests found
"""
Analysis of FP data
"""
import numpy as np
import serial
import time
import matplotlib.pyplot as plt
import fingerprint_enhancer
import cv2
from PIL import Image, ImageOps
# replace space to new line
def create_np_array(file_name):
'''
Read data from text file and save in an array
'''
temps = []
with open(file_name, "r") as r:
with open("fpData/temp.txt", "w") as w:
......@@ -26,39 +29,20 @@ def create_np_array(file_name):
print("Space")
f.close()
'''
ser = serial.Serial('com12', 115200, timeout = 0.1)
time.sleep(0.2)
for i in range(25600):
line = ser.readline()
if line:
string = line.decode()
num = int(string)
print(num, end = ' ')
temps.append(int(string))
ser.close()
'''
# print(temps)
# Store list into numpy array
# store list in to numpy array
fp_array = np.array(temps)
# print(fp_array)
print(type(fp_array))
print(len(fp_array))
return (fp_array)
# Display array
def display_fp(fp_arr):
'''
shape array to show as pixels
'''
# Construct image from data
# width and height
# 25600 = 160*160
w,h = 160, 160
t=(h,w,3)
......@@ -68,34 +52,17 @@ def display_fp(fp_arr):
a = int( index % 160 )
b = int( index / 160 )
fp_sample[a,b] = [a, b, (int(value)*255)]
# fp_sample[a,b] = [40+a, 80+b, int(value)]
# fp_sample[a,b] = [10+a, 20+b, int(value)]
i = Image.fromarray(fp_sample)
i.show()
# i = Image.fromarray(fp_sample)
# i.show()
plt.gray()
plt.imshow(fp_sample)
plt.show()
'''
i.save("Img/temp.png")
og_image = Image.open("Img/temp.png")
gray_image= ImageOps.grayscale(og_image)
gray_image.save("Img/temp.png")
gray_image.show("img/temp.png")
'''
'''
img = cv2.imread("Img/temp.png", 0)
out = fingerprint_enhancer.enhance_Fingerprint(img)
cv2.imshow('enhanced_image', out); # display the result
cv2.waitKey(0)
'''
# Plot on xy axis
'''
x = np.arange(0,25600)
y = fp_array[x]
plt.plot(x, y, color = 'red')
plt.show()
'''
# main function
if __name__ == '__main__':
fp_array1 = create_np_array("fpData/RawData1.txt")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment