-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Speeding up video frames loading #52
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contributions! It is a very good idea to add OpenCV support. But please do note that this addition would incur some cost to the user as it further complicates setup, given that it is widely known that OpenCV doesn't play well with some OS as well as very picky about dependencies.
That's why we believe that it would be better to keep skvideo as a default and give the choice to use OpenCV to the user. We would also like to keep the requirement as it is and put cv2
only as an optional requirement.
lipnet/lipreading/videos.py
Outdated
videogen = skvideo.io.vreader(path) | ||
#print("aaaa") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please delete this line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
lipnet/lipreading/videos.py
Outdated
@@ -191,11 +192,30 @@ def get_frames_mouth(self, detector, predictor, frames): | |||
mouth_frames.append(mouth_crop_image) | |||
return mouth_frames | |||
|
|||
def get_video_frames(self, path): | |||
def get_video_frames_skvideo(self, path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't change the current method of video loading as it has been proven to be reliable and doesn't require an additional installation of OpenCV, which is sometimes problematic (not to mention that the program itself sometimes doesn't work as expected).
Instead, provide an additional argument for the user in the from_video
method. Something like this: from_video(self, path, use_open_cv=False)
. Please keep Sk-video to be the default method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
lipnet/lipreading/videos.py
Outdated
@@ -4,6 +4,7 @@ | |||
from scipy import ndimage | |||
from scipy.misc import imresize | |||
import skvideo.io | |||
import cv2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle cv2 import failure (when users don't have OpenCV) as we want to give options to users to opt-out from using the feature
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've decided to import cv2 later in the code
lipnet/lipreading/videos.py
Outdated
frames = np.array([frame for frame in videogen]) | ||
return frames | ||
|
||
|
||
def get_video_frames(self, path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename the method to signify the use of opencv
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
I've just rewrote function for frames reading from skvideo to OpenCV