๐ ๋ณธ ์์ ๋ Window10์ VSCode, Python3.11.0๋ก ์์ฑ๋์์ต๋๋ค.
๊น์ด ์ ๋ณด๋ ์ด๋ฏธ์ง์์ ๊ฐ ํฝ์ ์ด ์นด๋ฉ๋ผ์ ์ผ๋ง๋ ๋จ์ด์ ธ ์๋์ง๋ฅผ ๋ํ๋ธ๋ค.
์ด ์ ๋ณด๋ 3D ์ฌ๊ตฌ์ฑ, ๋ฌผ์ฒด ์ธ์, ์์จ์ฃผํ์ฐจ, ๋ก๋ด ๋น์ ๋ฑ์์ ํ์์ ์ด๋ค.
๊น์ด ์ถ์ ๋ฐฉ๋ฒ์ ๋ค์๊ณผ ๊ฐ๋ค.
- ์คํ ๋ ์ค ๋น์ (Stereo Vision) : ๋ ๊ฐ์ ์นด๋ฉ๋ผ๋ฅผ ์๋ก ๋ค๋ฅธ ๊ฐ๋์์ ์ด๋ฏธ์ง๋ฅผ ์ดฌ์ํ๊ณ , ๋ ์ด๋ฏธ์ง ๊ฐ์ ์ฐจ์ด๋ฅผ ๋ถ์ํ์ฌ ๊น์ด๋ฅผ ๊ณ์ฐ.
- ๊น์ด ์ผ์(Depth Sensors) : LiDAR, ToF(Time-of-Flight) ์นด๋ฉ๋ผ์ ๊ฐ์ ์ผ์๋ฅผ ์ฌ์ฉํ์ฌ ๋ฌผ์ฒด๊น์ง์ ๊ฑฐ๋ฆฌ๋ฅผ ์ง์ ์ธก์ ํ๋ค.
- ๋ชจ๋ ธํ๋ฌ ๊น์ด ์ถ์ (Monocular Depth Estimation) : ๋จ์ผ ์นด๋ฉ๋ผ ์ด๋ฏธ์ง๋ฅผ ์ฌ์ฉํ์ฌ ๊น์ด๋ฅผ ์ถ์ ํ๋ ๋ฐฉ๋ฒ, ๋ฅ๋ฌ๋ ๋ชจ๋ธ์ ์ฌ์ฉํ์ฌ ์ด๋ฏธ์ง์ ํจํด๊ณผ ๊ตฌ์กฐ๋ฅผ ํ์ตํ๊ณ , ์ด๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ๊น์ด๋ฅผ ์์ธกํ๋ค.
Computer Vision์์์ ์์ฉ
- 3D ์ฌ๊ตฌ์ฑ : ๊น์ด ์ ๋ณด๋ฅผ ํ์ฉํ์ฌ 2D ์ด๋ฏธ์ง์์ 3D ๋ชจ๋ธ์ ์์ฑํ๋ ๋ฐ ์ฌ์ฉ๋๋ค.
- ๋ฌผ์ฒด ์ธ์ ๋ฐ ์ถ์ : ๊น์ด ์ ๋ณด๋ฅผ ํตํด ๋ฌผ์ฒด์ ์์น์ ํํ๋ฅผ ๋ณด๋ค ์ ํํ๊ฒ ์ธ์ํ๊ณ ์ถ์ ํ ์ ์๋ค.
- ์์จ์ฃผํ์ฐจ : ์ฐจ๋ ์ฃผ๋ณ์ ํ๊ฒฝ์ ์ดํดํ๊ณ ์ฅ์ ๋ฌผ ํํผ ๋ฐ ๋ด๋น๊ฒ์ด์ ์ ์ํ ์ค์ํ ์์์ด๋ค.
Stereo Vision
๋ ๊ฐ์ ์นด๋ฉ๋ผ๋ฅผ ์ฌ์ฉํ์ฌ 3D ๊ณต๊ฐ์์ ๋ฌผ์ฒด์ ๊น์ด ์ ๋ณด๋ฅผ ์ถ์ ํ๋ ๊ธฐ์ ์ด๋ค.
์ด ๊ธฐ์ ์ ์ธ๊ฐ์ ๋ ๋์ด ๊น์ด๋ฅผ ์ธ์ํ๋ ๋ฐฉ์๊ณผ ์ ์ฌํ๊ฒ ์๋ํ๋ค.
import numpy as np
import cv2
from matplotlib import pyplot as plt
img_left = cv2.imread("./img_left.jpg",cv2.IMREAD_GRAYSCALE)
img_right = cv2.imread("./img_right.jpg",cv2.IMREAD_GRAYSCALE)
# ์คํ
๋ ์ค ๋งค์นญ ๊ฐ์ฒด ์์ฑ
# numDisparities : ๊น์ด ๋งต์ ๊ณ์ฐํ ๋ ์ฌ์ฉํ ์ต๋ ์์ฐจ ๊ฐ์ ์ง์ , ๊ฐ์ 16์ ๋ฐฐ์
# blockSize : ๋งค์นญ์ ์คใ
ํด ์ฌ์ฉํ ๋ธ๋ก์ ํฌ๊ธฐ, ์ด ๊ฐ์ ํ์์ฌ์ผ ํ๋ฉฐ, ์ผ๋ฐ์ ์ผ๋ก 5,7,9,11 ๋ฑ์
stereo = cv2.StereoBM.create(numDisparities=16,blockSize=9)
# ๊น์ด ๋งต ๊ณ์ฐ
disparity_map = stereo.compute(img_left, img_right)
# ์๋ธํ๋กฏ ์์ฑ
fig, axs = plt.subplots(3, 1, figsize=(10, 15))
# ์๋ณธ ์ด๋ฏธ์ง (์ผ์ชฝ)
axs[0].imshow(img_left, cmap='gray')
axs[0].set_title("Left Image")
axs[0].axis("off")
# ์๋ณธ ์ด๋ฏธ์ง (์ค๋ฅธ์ชฝ)
axs[1].imshow(img_right, cmap='gray')
axs[1].set_title("Right Image")
axs[1].axis("off")
# ๊น์ด ๋งต
axs[2].imshow(disparity_map, cmap='gray')
axs[2].set_title("Depth Map")
axs[2].axis("off")
# ๊ฒฐ๊ณผ ์ถ๋ ฅ
plt.tight_layout()
plt.show()
Depth Sensors
๋ฌผ์ฒด์ ์ผ์ ๊ฐ์ ๊ฑฐ๋ฆฌ๋ฅผ ์ธก์ ํ์ฌ 3D ๊ณต๊ฐ์์์ ๊น์ด ์ ๋ณด๋ฅผ ์ ๊ณตํ๋ ์ฅ์น์ด๋ค.
์ด๋ฌํ ์ผ์๋ ๋ค์ํ ๊ธฐ์ ์ ๊ธฐ๋ฐ์ผ๋ก ํ๋ฉฐ, ์ฌ๋ฌ ๋ถ์ผ์์ ํ์ฉ๋๋ค.
์ข ๋ฅ๋ก๋ LiDAR, ToF, ์คํ ๋ ์ค ์นด๋ฉ๋ผ, ๊ตฌ์กฐ๊ด ์ผ์ ๋ฑ
Monocular Depth Estimation
๋จ์ผ ์นด๋ฉ๋ผ ์ด๋ฏธ์ง๋ฅผ ์ฌ์ฉํ์ฌ 3D ๊ณต๊ฐ์์ ๊น์ด ์ ๋ณด๋ฅผ ์ถ์ ํ๋ ๊ธฐ์ ์ด๋ค.
์ด๋ ์คํ ๋ ์ค ๋น์ ๊ณผ ๋ฌ๋ฆฌ ๋ณ๋์ ๊น์ด ์ผ์๋ ๋ ๊ฐ์ ์ด๋ฏธ์ง๋ฅผ ํ์๋ก ํ์ง ์๊ณ , ์ฃผ๋ก ๋ฅ๋ฌ๋ ๋ชจ๋ธ์ ํตํด ์ํ๋๋ค.
๋ํ์ ์ผ๋ก Depth-Anything์ด ์๋ค.
GitHub - DepthAnything/Depth-Anything-V2: Depth Anything V2. A More Capable Foundation Model for Monocular Depth Estimation
Depth Anything V2. A More Capable Foundation Model for Monocular Depth Estimation - DepthAnything/Depth-Anything-V2
github.com
Demo
Depth Anything V2 - a Hugging Face Space by depth-anything
Running on Zero
huggingface.co
'AI > Computer Vision' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Computer Vision] Skeletonization (0) | 2024.09.20 |
---|---|
[Computer Vision] Segmentation (0) | 2024.09.19 |
[Computer Vision] Trapped-ball Segmentation (0) | 2024.09.14 |
[Computer Vision] IoU(Intersection over Union) (0) | 2024.09.12 |
[Computer Vision] PIL(Python Image Library) (0) | 2024.09.08 |