balintlaczko / MGT-python

Musical Gestures Toolbox for Python
https://www.uio.no/ritmo/english/research/labs/fourms/downloads/software/musicalgesturestoolbox/mgt-python/index.html
GNU General Public License v3.0
1 stars 0 forks source link

Notebook problem reading video #28

Closed alexarje closed 4 years ago

alexarje commented 4 years ago

Continuing my testing of the Jupyter notebook. Running:

mg = mgmodule.MgObject('dance.avi')

gives me this error:


ZeroDivisionError Traceback (most recent call last)

in ----> 1 mg = mgmodule.MgObject('dance.avi') ~/github/MGT-python-balint/MGT-python/mgmodule/__init__.py in __init__(self, filename, method, filtertype, thresh, starttime, endtime, blur, skip, color, contrast, brightness, crop, keep_all) 46 self.keep_all = keep_all 47 self.test_input() ---> 48 self.get_video() 49 self.flow = Flow(self.filename) 50 ~/github/MGT-python-balint/MGT-python/mgmodule/__init__.py in get_video(self) 65 """ Creates a video attribute to the Musical Gestures object with the given correct settings. """ 66 self.video, self.length, self.width, self.height, self.fps, self.endtime, self.of, self.fex = mg_videoreader( ---> 67 self.filename, self.starttime, self.endtime, self.skip, self.contrast, self.brightness, self.crop, keep_all=self.keep_all) 68 69 # update filename after the processes ~/github/MGT-python-balint/MGT-python/mgmodule/_videoreader.py in mg_videoreader(filename, starttime, endtime, skip, contrast, brightness, crop, keep_all) 73 # Overwrite the inputvalue for endtime not to cut the video at 0... 74 if endtime == 0: ---> 75 endtime = length/fps 76 77 # Apply contrast/brightness before the motion analysis ZeroDivisionError: division by zero
balintlaczko commented 4 years ago

Hmm, strange, that one gives me no errors. I can even call functions on mg after evaluating this. The error you pasted happens when the cv2.VideoCapture cannot find the video (or if it is a corrupt one) resulting in the fps variable not getting filled, which leads to the ZeroDivisionError. Are you sure you have an actual dance.avi in the same folder as the notebook?

alexarje commented 4 years ago

Yes, it turns out to be a path problem. I just ran the notebook from the current location, while the dance.avi was in the examples folder. Moving the notebook into the examples folder, where the dance.avi is, solves the problem. We should probably do this in the release, since end users will most likely just start the notebook from where it is located and expect it to work "out of the box".

balintlaczko commented 4 years ago

Oh yes, I actually did this in november, and I completely forgot... :) But I will also write a cell about relative and absolute paths in the notebook.

alexarje commented 4 years ago

Yes, good. Important to make the first experience of the toolbox as easy as possible, otherwize new people will move on quickly.