Closed Hatem-Jr closed 3 years ago
It's hard to read the code formatting. Hard to find entrypoint of original code. Hard to reproduce your problems, because there is no code to run. Try to fork the repository at first and make a working example, please.
repo forked
so did you look at it ?
1-when the track.py file finishes execution, the .csv file erases previous results and overwrites it with new ones
because of w parameter, it truncates the file you open. You have to check the file's existence before adding the header since column names are needed only when you are creating a new table and definitely the header has to be placed in the leading line.
2-there are no tracing images saved in the trace folder, even though in the normal code it did save tracing images
because RELATIVE_DESTINATION_PATH is relative and after you pass the file path into trace() you have to check if the file name is file name, not the path. Just debug where you are saving the images.
but the thing is I checked if the cv2.imwrite works or not by adding this:
if not cv2.imwrite(RELATIVE_DESTINATIONPATH + 'traces/' + name + '[distance]=%.2f' % distance + '_[time]=%.1fs' % t + '.png', cv2.resize(imgTrack, (max(HD), max(HD)))): raise Exception("Could not write image")
and the exception is always raised
and If the problem is that I'm passing file path and not just the file name to the trace method then how to get the .mp4 part of the path from "GUI.filepath" only ?
and the exception is always raised
and why it will not if you pass the absolute path? What about just print(RELATIVE_DESTINATION_PATH + 'traces/' + name)
for sanity check?
and If the problem is that I'm passing file path and not just the file name to the trace method then how to get the .mp4 part of the path from "GUI.filepath" only?
Well, folding of os.path.basename and os.path.splitext, then indexing of the extension.
yeah you were right this line: print(RELATIVE_DESTINATION_PATH + 'traces/' + name)
produces this: 2021-07-13_distance/traces/D:/CSEN/Courses/Semester 8/Tests Video Samples/output which means that name is D:/CSEN/Courses/Semester 8/Tests Video Samples/output
now how to make it only output ?
now how to make it only output ?
Did you read this one:
folding of os.path.basename and os.path.splitext, then indexing of the extension
?
Nest these functions. In your case use the only os.path.basename.
Yes I did, I just didn't understand/realize that this was the answer before doing the print statement 😂
Hi I made a GUI and here's it's code: from os import close from tkinter import * from tkinter import filedialog,messagebox import track
FotaGui = Tk() FotaGui.geometry('600x600')
def file_path():
Morris Water Maze
def MWM():
Browsebutton = Button(FotaGui,width = 18,text= "Browse",command = file_path) Browsebutton.pack()
MWMbutton = Button(FotaGui,width = 18,text="Morris Water Maze Test",command = MWM) MWMbutton.pack()
filepathlabel = Label(FotaGui,text = "mp4 file path:",font = ('Times 10')) filepathlabel.pack()
FotaGui.mainloop()
and I changed the last couple of lines in track.py to this:
for filename in glob.glob('*.mp4'):
for filename in glob.glob('*.mp4'):
floorCrop(GUI.filepath) file = open(RELATIVE_DESTINATION_PATH + 'distances.csv', 'a') trace(GUI.filepath)
now there are 2 problems: 1-when the track.py file finishes execution, the .csv file erases previous results and overwrites it with new ones 2-there are no tracing images saved in the trace folder, even though in the normal code it did save tracing images