1313
1414## Function to draw bounding box and facial landmarks on a frame
1515def map_and_draw (frame , face_info , aoi_size , ellipse_size , gaze_crcl_size ):
16- transparency = 60 # Adjust this value as needed
16+ transparency = 60
1717 # Define colors for landmarks
18- default_color = (255 , 0 , 0 ) # Default color for landmarks
19- gaze_color = (0 , 255 , 0 ) # Color for the gazed landmark
18+ default_color = (120 , 120 , 120 ) # Default color for landmarks
19+ gaze_color = (0 , 200 , 0 ) # Color for the gazed landmark
2020
2121 # Draw bounding box
2222 p1 = (int (face_info ["p1 x [px]" ]), int (face_info ["p1 y [px]" ]))
@@ -73,7 +73,6 @@ def map_and_draw(frame, face_info, aoi_size, ellipse_size, gaze_crcl_size):
7373 ):
7474 landmark_list .append (landmark )
7575 color = gaze_color
76-
7776 else :
7877 landmark_list .append ("Not on landmark" )
7978 color = default_color
@@ -173,21 +172,12 @@ def plot_percentages(df_perc, out_path):
173172 plt .bar (df_perc ['landmark' ], df_perc ['percentage' ], color = colors )
174173
175174 # Adjusting font size and style
176- plt .title ('Percentage of Gaze Mapped on Different Landmarks' , fontsize = 30 , fontweight = 'bold' )
175+ plt .title ('Percentage of Gaze Mapped on Different Landmarks' , fontsize = 30 , fontweight = 'bold' , y = 1.05 )
177176 plt .xlabel ('Landmark' , fontsize = 28 )
178177 plt .ylabel ('%-Gaze Mapped \n (out of all data detected on face)' , fontsize = 28 )
179178 plt .xticks (rotation = 45 , fontsize = 25 )
180179 plt .yticks (fontsize = 25 )
181180 plt .tight_layout ()
182- figure_path = os .path .join (out_path , "_barplot .png" )
181+ figure_path = os .path .join (out_path , "barplot .png" )
183182 plt .savefig (figure_path , bbox_inches = 'tight' , pad_inches = 1.0 )
184- logging .info (f"Barplot saved at: { figure_path } " )
185-
186- # Plotting Pie Chart
187- plt .figure (figsize = (12 , 10 ))
188- plt .pie (df_perc ['percentage' ], labels = df_perc ['landmark' ], colors = colors , autopct = '%1.1f%%' , startangle = 140 , textprops = {'fontsize' : 25 }) # Adjust fontsize here
189- plt .title ('Percentage of Gaze Mapped on Different Landmarks' , fontsize = 30 , fontweight = 'bold' )
190- pie_path = os .path .join (out_path , "_pie.png" )
191- # Save the plot to out_path
192- plt .savefig (pie_path ,bbox_inches = 'tight' , pad_inches = 1.0 )
193- logging .info (f"Pie chart saved at: { pie_path } " )
183+ logging .info (f"Barplot saved at: { figure_path } " )
0 commit comments