I have created a python script which uses tensorflow with deep sort to detect and track vehicles in a video.
Depending on each vehicles position it gets a value to its attributes
Each vehicle has the following:
Car.Id Car.Origin Car.Destination
Origin and Destination can be any of E, N, S or V (but not the same).
So each vehicle should then have an ID, Origin and Destination as in
Car.Id = 575
Car.Origin = E
Car.Destination = V
Now I append these to a Pandas dataframe and I can export unique combinations as in
sum((df['orig']=='E') & (df['dest']=='V'))
However, this would mean I need to update 12 different variables in each loop (EE, EV, ES, NV, NS etc etc.)
So, I tried to dynamically create and set values through the loop as in the following code
exec(str(track.origin + track.destination) + "=" + str(sum((df['orig']==track.origin) & (df['dest']==track.destination))))
But still Print(EV)
doesn't work.
So, I am stuck.
Should i put E, V, N, S in some dictionary and loop around it, or do you guys have any other tip or recommendation?
I really want these simple variables as EV and SV for different reasons.
question from:
https://stackoverflow.com/questions/65923542/create-new-variable-from-combined-variables 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…