-
Notifications
You must be signed in to change notification settings - Fork 14
Finish Homework #9
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| import sys | ||
| sys.path.append('/usr/local/lib/python2.7/site-packages') | ||
| import cv2 | ||
|
|
||
| from styler.utils import resize | ||
|
|
@@ -28,9 +30,19 @@ def read_frames(self, image_h, image_w): | |
| ''' | ||
| frames = [] | ||
| # 5-1 /5-2 Read video and collect them | ||
|
|
||
| self.frames = ... # 5-3 let object have the result | ||
| return ... # return your results | ||
| success,image = self.cap.read() | ||
| count = 0 | ||
| success = True | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line 33 self.cap.read()本身回傳值,第一個參數是True/False,代表有沒有讀到圖片,第二個參數代表當前截取一幀的圖片。這邊如果有讀到,success會回傳True,所以不必在 Line 35 將它再次賦值為True |
||
| while success: | ||
| image2 = cv2.resize(image, (image_h, image_w)) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line37 這邊希望使用的是 utils.py 裡的 resize()。可以看下 utils.py 的版本有對這份應用做一些特殊處理(擷取中心位置之後才 resize)所以跟直接 cv2.resize 結果可能有些出入 |
||
| frames.append(image2) | ||
| success, image = self.cap.read() | ||
|
|
||
| print ('Read a new frame: ', success , count) | ||
| count += 1 | ||
|
|
||
| self.frames = frames # 5-3 let object have the result | ||
| return frames # return your results | ||
|
|
||
| def __exit__(self, exc_type, exc_val, exc_tb): | ||
| self.cap.release() | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
Line 45 路徑也可以使用相對路徑
e.g. 'input/jagauar.mp4' 或 './input/jagauar.mp4'
如果程式在不同環境或是交給其他人使用時,路徑也許就不用修改了