1313import cv2
1414from datetime import datetime
1515from SIOParser import SIOParser
16+ import argparse
1617
1718kDefaultTimeout = 5
19+ kDefaultIpAddress = "127.0.0.1"
1820
1921def epoch_to_offset (epoch_timestamp ):
2022 return datetime .utcfromtimestamp (epoch_timestamp / 1000 ).strftime ('%H:%M:%S' )
@@ -86,11 +88,11 @@ def onCancel(self, event):
8688
8789class MainFrame (wx .Frame ):
8890 # =========================================================================
89- def __init__ (self , * args , ** kw ):
91+ def __init__ (self , ipAddress , * args , ** kw ):
9092 super (MainFrame , self ).__init__ (* args , ** kw )
9193
9294 self .settings = {
93- "api_ip" : "10.10.10.20" ,
95+ "api_ip" : ipAddress ,
9496 "api_port" : "8888" ,
9597 "refresh_rate" : 10 ,
9698 "max_entries" : 50 ,
@@ -154,7 +156,6 @@ def initUI(self):
154156 search_sizer .Add (self .search_button , 0 , wx .ALIGN_CENTER | wx .ALL , 5 )
155157 self .search_tab .SetSizer (search_sizer )
156158
157-
158159 # Layout for the File tab
159160 file_sizer = wx .BoxSizer (wx .VERTICAL )
160161 self .uploaded_files_list = wx .ListCtrl (self .file_tab , style = wx .LC_REPORT )
@@ -172,17 +173,22 @@ def initUI(self):
172173 self .file_tab .SetSizer (file_sizer )
173174 self .uploaded_files_results = {}
174175
175-
176176 self .list_box = self .initListCtrl (self .panel )
177177 self .image_ctrl = wx .StaticBitmap (self .panel )
178- self .lp_ctrl = wx .StaticBitmap (self .panel , size = (100 ,60 ))
178+ self .lp_ctrl = wx .StaticBitmap (self .panel , size = (200 ,100 ))
179+
180+ # Create a horizontal sizer for image_ctrl and lp_ctrl
181+ self .image_lp_sizer = wx .BoxSizer (wx .HORIZONTAL )
182+ self .image_lp_sizer .Add (self .image_ctrl , 1 , wx .EXPAND | wx .ALL , 5 ) # image_ctrl takes more space
183+ self .image_lp_sizer .Add (self .lp_ctrl , 1 , wx .ALIGN_CENTER | wx .ALL , 5 ) # lp_ctrl stays small
179184
180185 # Layout for the main panel
181186 main_sizer = wx .BoxSizer (wx .VERTICAL )
182187 main_sizer .Add (self .notebook , 1 , wx .EXPAND )
183188 main_sizer .Add (self .list_box , 1 , wx .EXPAND | wx .ALL , 5 )
184- main_sizer .Add (self .image_ctrl , 1 , wx .EXPAND | wx .ALL , 5 )
185- main_sizer .Add (self .lp_ctrl , 1 , wx .ALIGN_CENTER | wx .ALL , 5 )
189+ main_sizer .Add (self .image_lp_sizer , 1 , wx .EXPAND | wx .ALL , 5 )
190+ # main_sizer.Add(self.image_ctrl, 1, wx.EXPAND | wx.ALL, 5)
191+ # main_sizer.Add(self.lp_ctrl, 1, wx.ALIGN_CENTER | wx.ALL, 5)
186192 self .panel .SetSizer (main_sizer )
187193
188194 # Bind events
@@ -267,9 +273,10 @@ def clearSharedUIState(self):
267273 def initListCtrl (self ,parent ):
268274 ctrl = wx .ListCtrl (parent , style = wx .LC_REPORT )
269275 ctrl .InsertColumn (0 , 'Time' )
270- ctrl .InsertColumn (1 , 'Plate/State' )
271- ctrl .InsertColumn (2 , 'Source' )
272- ctrl .InsertColumn (3 , 'UID' )
276+ ctrl .InsertColumn (1 , 'Make/Model/Color' )
277+ ctrl .InsertColumn (2 , 'Plate/State' )
278+ ctrl .InsertColumn (3 , 'Source' )
279+ ctrl .InsertColumn (4 , 'UID' )
273280 # Bind the single-click event
274281 ctrl .Bind (wx .EVT_LIST_ITEM_SELECTED , self .onListItemSelected )
275282 return ctrl
@@ -481,11 +488,15 @@ def populateListWithData(self,data,ctrl,isoffset):
481488 else :
482489 dt = epoch_to_string (int (entry ['time' ]))
483490 ctrl .InsertItem (index , f"{ dt } " )
484- ctrl .SetItem (index , 1 , f"{ entry ['string' ]} /{ entry ['region' ]} " )
485- ctrl .SetItem (index , 2 , f"{ entry ['sourceId' ]} " )
486- ctrl .SetItem (index , 3 , f"{ entry ['oid' ]} " )
491+ ctrl .SetItem (index , 1 , f"{ entry ['make' ]} /{ entry ['model' ]} /{ entry ['color' ]} " )
492+ ctrl .SetItem (index , 2 , f"{ entry ['string' ]} /{ entry ['region' ]} " )
493+ ctrl .SetItem (index , 3 , f"{ entry ['sourceId' ]} " )
494+ ctrl .SetItem (index , 4 , f"{ entry ['oid' ]} " )
487495 index = index + 1
488496
497+ for i in range (4 ): # Adjust all columns
498+ ctrl .SetColumnWidth (i , wx .LIST_AUTOSIZE )
499+
489500 # =========================================================================
490501 def apiRoot (self ):
491502 return f"http://{ self .settings ['api_ip' ]} :{ self .settings ['api_port' ]} "
@@ -628,8 +639,20 @@ def BringToFront(self):
628639 print ("Error bringing window to front:" , e )
629640
630641
631- app = wx .App (False )
632- frame = MainFrame (None , title = "ALPR Demo" , size = (800 , 600 ))
633- frame .Bind (wx .EVT_CLOSE , frame .onClose )
634- frame .Show ()
635- app .MainLoop ()
642+ def main ():
643+
644+ # Load args
645+ parser = argparse .ArgumentParser (description = 'Run ALPR Demo Client UI' )
646+ parser .add_argument ('-i' , '--ipAddress' , type = str , help = 'The Server IP Address' , default = kDefaultIpAddress )
647+
648+ args = parser .parse_args ()
649+ ipAddress = args .ipAddress
650+
651+ app = wx .App (False )
652+ frame = MainFrame (ipAddress , None , title = "ALPR Demo" , size = (800 , 600 ))
653+ frame .Bind (wx .EVT_CLOSE , frame .onClose )
654+ frame .Show ()
655+ app .MainLoop ()
656+
657+ if __name__ == "__main__" :
658+ main ()
0 commit comments