Study Concept
*) ๋ชฉ์ : ์์ ๋ฐฉ์ก ์์ด๋๋ณ ์ผ๊ตด ์ธ์์ ์ํ CNN ์ผ๊ตด์ธ์ ํ๋ก์ ํธ ์ค ํ์ต
Dev Concept
*) Python opencv ๋ผ์ด๋ธ๋ฌ๋ฆฌ
๊ณผ์
#reference: deftkang.tistory.com/182
[Python] ํ์ด์ฌ์ผ๋ก ๋์์ ์ด๋ฏธ์ง ์ถ์ถํ๋ ๋ฐฉ๋ฒ(์ฌ์ด์ฆ ์ค์ ๊ณผ ์ด๋น 1ํ๋ ์ ์ถ์ถ)
ํ์ด์ฌ๊ณผ, Thoony๋ฅผ ๋ค์ด๋ฐ๋๋ค. Thonny๋ ํ์ด์ฌ ๊ธฐ๋ณธ์ ์ธ ํธ์ง๊ธฐ ํด์ธ๋ฐ ์์ฃผ ๊ฐํธํ๋ค thonny.org/ www.python.org/downloads/ ํ๊ฒฝ๋ณ์๊ฐ ์๋์ฒ๋ผ pythonํ, pythonํ\Script ๊ฐ ๋ผ ์์ด์ผ ํ๋ค. cmd์ฐฝ์ ์ด..
deftkang.tistory.com
Python์ ์ด์ฉํ์ฌ ๋์์์ผ๋ก๋ถํฐ ์ด๋ฏธ์ง์ถ์ถ - (Python(v2.7) / OpenCV / Windows)
- OpenCV API URL : http://docs.opencv.org/3.0-beta/modules/refman.html - OpenCV-Python Tutroals URL : https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_tutorials.html - pip..
shilan.tistory.com
import cv2, os
v_cap = cv2.VideoCapture(os.path.join(os.path.curdir, 'test.mp4'))
cnt = 0
while v_cap.isOpened():
ret, image = v_cap.read()
image = cv2.resize(image, (1920, 1080))
if int(v_cap.get(1)) % 10 == 0:
cv2.imwrite(os.path.join(os.path.curdir, 'capture', '%d.png' % v_cap.get(1)), image)
print("Frame Captured: %d" % v_cap.get(1))
cnt += 1
v_cap.release()
cv2.VideoCapture: ์์ ์ด๋ฏธ์ง ์ฐ์์ผ๋ก ์บก์ณ ๊ฐ๋ฅํ class
=> test.mp4์ ํ๋ ์๋ณ ์ด๋ฏธ์ง๋ฅผ ์ฐ์์ผ๋ก ์บก์ณํ ์ ์๋๋ก ์ง์
v_cap.isOpened(): ์์ ์บก์ณ ์ด๊ธฐํ ์ฌ๋ถ
ret: read ์ ์์ฒ๋ฆฌ ์ฌ๋ถ
image: y*x์ 2์ฐจ์ ๋ฆฌ์คํธ๋ก ์ด๋ฃจ์ด์ง rgb๊ฐ๋ค
cv2.resize(): ์ฒซ๋ฒ์งธ ์ธ์๋ก ๋ค์ด์จ image์ ํฌ๊ธฐ๋ฅผ ๋๋ฒ์งธ ์ธ์๋ก ๋ฐ์ ํํ๊ฐ์ ๋ฐ๋ผ x, y๋ก ์ ์ฉํจ
cv2.imwrite(): ์ง์ ๊ฒฝ๋ก์ (=์ฒซ๋ฒ์งธ ์ธ์) 2์ฐจ์ ๋ฆฌ์คํธ๋ก ์ด๋ฃจ์ด์ง rgb๊ฐ๋ค (=๋๋ฒ์งธ ์ธ์)์ ์ด๋ฏธ์ง๋ก ์ ์ฅํจ
'๐ก Lang > Python' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Study Log] Python ์์ํ์ผ ํธ๋ค๋ง (0) | 2021.04.29 |
---|