์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
- segmentation
- ์ ๋ณด์ฒ๋ฆฌ๊ธฐ์ฌ
- homogeinous
- SQL
- ๋งฅ์ผ์ด๋ธ
- ์ปดํจํฐ๊ตฌ์กฐ
- Computer
- ํฉ๋ณ
- robotics
- ๋ช ๋ น์ด
- ์์ค ์ฝ๋ ํ์ง ๋ถ์
- AI
- ํ์ ๋ณต์ก๋
- ๋ฆฌ๋ ์ค
- Coding
- sort
- Java
- sam2
- MIPS
- CentOS
- humble
- ๊ธฐ๊ตฌํ
- 3dof
- ์ ๋ ฌ
- ์ ์ฒ๊ธฐ
- Linux
- ๋คํธ์ํฌ ์ถฉ๋
- ์๊ณ ๋ฆฌ์ฆ
- homogenous
- ROS2
- Today
- Total
UTF-404
SAM2 ๋ค์ํ๊ฒ ์ด์ฉํด๋ณด๊ธฐ!! ๋ณธ๋ฌธ
๐ฏ SAM ๊ธฐ๋ฐ ์ด๋ฏธ์ง ๋ฐ ๋น๋์ค ์ถ์ ๊ธฐ | Image & Video Tracker using SAM
์ด ํ๋ก์ ํธ๋ Meta์ Segment Anything Model (SAM)์ ๊ธฐ๋ฐ์ผ๋ก ์ด๋ฏธ์ง ๋ฐ ์์์์ ํน์ ์์์ ๊ธฐ์ค์ผ๋ก ๊ฐ์ฒด๋ฅผ ๋ถํ ํ๊ณ ์ถ์ ํ๋ Python ์คํฌ๋ฆฝํธ ๋ชจ์์
๋๋ค.
This project uses Meta’s Segment Anything Model (SAM) to segment and track objects in images and videos based on color.
Meta์์ ๊ณต๊ฐํ ๊ฐ๋ ฅํ ๋ฒ์ฉ ๋ถํ ๋ชจ๋ธ SAM์ ๊ฐ์ฒด์ ๊ฒฝ๊ณ์ ํํ๋ฅผ ๊ณ ์ ๋ ํ๋กฌํํธ ์์ด๋ ์ ํํ๊ฒ ์๋ณํ ์ ์์ต๋๋ค. ๋ณธ ํ๋ก์ ํธ๋ ์ด ๊ธฐ๋ฅ์ ์์ ๊ธฐ๋ฐ ๊ฐ์ฒด ์ถ์ ์ ์์ฉํ์ฌ, ๋ค์ํ ์ด๋ฏธ์ง ๋ฐ ์์ ๋ด ์์ฉ ๊ฐ๋ฅ์ฑ์ ํ์ํฉ๋๋ค.
SAM by Meta can detect object boundaries with high precision even without predefined prompts. This project applies SAM for color-based object tracking, showcasing its flexibility in both image and video domains.
๐ ํ๋ก์ ํธ ๊ตฌ์ฑ | Project Structure
ํ์ผ๋ช (Filename) | ์ค๋ช (Description) |
---|---|
image_color_sam2.py |
๋ง์ฐ์ค ํด๋ฆญ์ผ๋ก ์ ํํ ์์ ์์ญ์ ๊ธฐ์ค์ผ๋ก ์ด๋ฏธ์ง์์ ๊ฐ์ฒด๋ฅผ ๋ถํ ํฉ๋๋ค. SAM ๋ชจ๋ธ์ ํ์ฉํ์ฌ ๋ง์คํฌ๋ฅผ ์์ฑํ๊ณ , ํด๋น ๊ฐ์ฒด์ ์์์ ์
ํ๋๋ค. Interactive color-based object segmentation on static images using SAM. |
video_color_sam2.py |
์์ ๋ด ํน์ ์์์ ๊ธฐ์ค์ผ๋ก SAM์ ์ด์ฉํ์ฌ ๊ฐ์ฒด๋ฅผ ์ถ์ ํฉ๋๋ค. ๋ง์ฐ์ค๋ก ์์์ ์ ํํ๋ฉด ํ๋ ์๋ง๋ค ์ ์ฌ ๊ฐ์ฒด๋ฅผ ์ถ์ ํ๋ฉฐ ๋ง์คํฌ๋ฅผ ์์ฑํฉ๋๋ค. Color-based object tracking in video streams using SAM and mouse-guided selection. |
tracking_sam2.py |
์ค๋ณต ๊ฐ์ฒด ์ ๊ฑฐ, ์ค์ฌ์ ๊ณ์ฐ, ๊ฑฐ๋ฆฌ ๊ธฐ๋ฐ ๋ณด์ ๋ฑ ์ ๊ตํ ์ถ์ ๊ธฐ๋ฅ์ ํฌํจํ SAM ๊ธฐ๋ฐ ๊ฐ์ฒด ์ถ์ ์คํฌ๋ฆฝํธ์
๋๋ค. Advanced tracking using SAM with centroid detection, duplicate filtering, and repulsion adjustment. |
video_sam2_demo.py |
๋ง์ฐ์ค๋ก ํด๋ฆญํ ๊ฐ์ฒด๋ฅผ SAM์ผ๋ก ์ถ์ ํ๋ ์์ ๋ฐ๋ชจ์
๋๋ค. ๋จ์ํ ์คํ์ฉ UI ๋ฐ ๊ธฐ๋ฅ ํ์ธ์ฉ์ผ๋ก ์ ํฉํฉ๋๋ค. Simple video demonstration of SAM tracking triggered by mouse input. |
test_sam2.py |
Kalman ํํฐ ์์ฑ, ์ค๋ณต ์ ๊ฑฐ, ์ค์ฌ์ ๊ณ์ฐ ๋ฑ SAM๊ณผ ๋ค์ํ ๊ธฐ๋ฅ์ ํ
์คํธํ๊ธฐ ์ํ ์ข
ํฉ ํ
์คํธ์ฉ ์คํฌ๋ฆฝํธ์
๋๋ค. Multi-function test script including SAM, Kalman filter creation, and object duplicate handling. |
color_run_sam2.py |
๋ค์ํ ์์์ ์์๋ก ์์ฑํ๊ณ , ํด๋ฆญ ์ด๋ฒคํธ ๊ธฐ๋ฐ ๊ฐ์ฒด ์ถ์ ์ ์คํํฉ๋๋ค. ์์ ๊ธฐ๋ฐ ๋ง์คํฌ ์ ์ฅ ๊ธฐ๋ฅ ํฌํจ. Interactive color-triggered segmentation with random color generation and save functionality. |
last_test_sam2.py |
๋ค์ํ ๊ธฐ๋ฅ์ ํตํฉํ ์ต์ข
ํ
์คํธ ์คํฌ๋ฆฝํธ๋ก, ๋ง์คํฌ ์๊ฐํ ๋ฐ ํฌ์ธํธ ๊ธฐ๋ฐ ์ถ์ ํ์ธ์ฉ์
๋๋ค. Final integration test script including mask display and point-based interaction. |
๐ง ์ค์น ๋ฐฉ๋ฒ | Installation
1๏ธโฃ Python ๊ฐ์ํ๊ฒฝ ์์ฑ | Create a virtual environment
conda create -n sam_env python=3.10 -y
conda activate sam_env
2๏ธโฃ ํ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ค์น | Install dependencies
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
pip install opencv-python matplotlib
pip install git+https://github.com/facebookresearch/segment-anything.git
3๏ธโฃ SAM ์ฌ์ ํ์ต ๋ชจ๋ธ ๋ค์ด๋ก๋ | Download SAM pretrained model
Meta์ ๊ณต์ ๋ชจ๋ธ์ ์๋ ๊ฒฝ๋ก์์ ๋ฐ์ ์ ์์ต๋๋ค.
Download the pretrained model from Meta using:
wget https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h.pth -P ./checkpoints
SAM์ ์๋ ๋ฐฉ์์ ๋ํ ์์ธํ ๋ด์ฉ์ Segment Anything ๋
ผ๋ฌธ๊ณผ ๊ณต์ GitHub ๋ฌธ์๋ฅผ ์ฐธ๊ณ ํ์ธ์.
For more details on how SAM works, refer to the Segment Anything Paper and official GitHub.
โถ๏ธ ์ฌ์ฉ ๋ฐฉ๋ฒ | How to Use
๐ท ์ด๋ฏธ์ง ์์ ๊ธฐ๋ฐ ๋ถํ | Image color-based segmentation
python image_color_sam2.py --image_path path/to/image.jpg
๐ฅ ์์ ์์ ๊ธฐ๋ฐ ์ถ์ | Video color-based tracking
python video_color_sam2.py --video_path path/to/video.mp4
๐งช ์์ ๋ฐ๋ชจ ์คํ | Run SAM video demo
python video_sam2_demo.py --video_path path/to/sample.mp4
์ฌ์ฉ์๋ ์์/์ด๋ฏธ์ง ์ ๊ฐ์ฒด์ ์์์ ์ ํํ๊ณ ํด๋น ์์๊ณผ ์ ์ฌํ ํฝ์
๊ตฐ์ง์ ๋ํด SAM์ ํตํด ๋ง์คํฌ๋ฅผ ์์ฑํฉ๋๋ค. ์ด๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ๊ฐ์ฒด๋ฅผ ํ๋ ์ ๋จ์๋ก ์ถ์ ํฉ๋๋ค.
Users can select object colors in an image/video, and SAM generates masks for clusters of similar pixels to track them frame-by-frame.
๐ก ํ๋ก์ ํธ ํ์ฉ ๋ฐ ํ์ฅ ๋ฐฉํฅ | Notes and Potential Applications
- ๋ณธ ํ๋ก์ ํธ๋ ์ค์๊ฐ ๊ฐ์ ์์คํ
, ์๋ ๋ก๋ด ์๊ฐ ์ฒ๋ฆฌ, ์์ ๊ธฐ๋ฐ ํ์ง ๊ฒ์ฌ ๋ฑ์ ์ฐ์
์ ์์ฉ์ ์ ํฉํฉ๋๋ค.
This project is suitable for industrial applications like real-time surveillance, robotic vision, and color-based quality inspection. - SAM์ prompt-free ๋ถํ ๊ธฐ๋ฅ์ ํตํด ์์ ๋ด ๋ค์ํ ์ฌ๋ฌผ ์ธ์ ๋ฐ ๋ถ๋ฆฌ ์์
์์ ๊ฐ๋ ฅํ ์ฑ๋ฅ์ ๋ณด์ด๋ฉฐ, ์ด ํ๋ก์ ํธ๋ ํด๋น ๋ชจ๋ธ์ ์ ์ฐ์ฑ์ ์์ ๋ถ์ ์์
์ ์ ๋ชฉํ ๊ฒ์
๋๋ค.
SAM’s prompt-free segmentation offers high flexibility, and this project integrates it with color analysis for robust tracking. - ๋ค์ํ ์์ ๋ฒ์, ํด์๋, ์กฐ๋ช
์กฐ๊ฑด์์๋ ์ ์๋ํ๋๋ก ๊ตฌ์ฑ๋์ด ์์ผ๋ฉฐ, ์ฝ๋ ์ผ๋ถ๋ ์ฌ์ฉ์ ์ง์ ์ผ๋ก ํ์ฅ ๊ฐ๋ฅํฉ๋๋ค.
It is robust to color variation, resolution, and lighting, and can be easily extended for custom use cases.
โ
๋ณธ ํ๋ก์ ํธ๋ ์ฐ๊ตฌ ๋ฐ ํ๋กํ ํ์ดํ์ ์ํ ์์์ ์ผ๋ก ํ์ฉ๋๋ฉฐ, ํฅํ ๋ค์๊ณผ ๊ฐ์ ๋ฐฉํฅ์ผ๋ก ํ์ฅ๋ ์ ์์ต๋๋ค:
This project serves as a prototype and can be extended to:
- ์ค์๊ฐ ์์ ์คํธ๋ฆฌ๋ฐ ์ฒ๋ฆฌ (Real-time video streaming)
- ์ฌ์ฉ์ ๋ง์ฐ์ค ํด๋ฆญ ๊ธฐ๋ฐ ๊ฐ์ฒด ์ถ์ (Click-to-track systems)
- ๋ก๋ด ์ ์ด ๋๋ ํ๋ ํธ๋ฆฌ๊ฑฐ์ฉ ๊ฐ์ฒด ์ธ์ (Object-triggered robotic actions)
๐ Github
https://github.com/utf-404/sam2_image_video_detection
'private study' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๐ก SAM2 ์ง์ ์ ์ฉํด๋ณด๊ธฐ (2) | 2025.02.04 |
---|---|
๐ก SAM2 ์์๋ณด๊ธฐ (0) | 2025.02.02 |
mac ํ๊ฒฝ์์ tkinter gui ์ค๋ฅ ํด๊ฒฐ๋ฐฉ๋ฒ!! (3) | 2024.05.02 |
Raspberry Pi ์ค์นํด๋ณด๊ธฐ (0) | 2024.05.02 |
Docker๋ฅผ ํ์ฉํ Ubuntu ์ค์น!! (0) | 2024.03.14 |