250x250
Link
๋์ GitHub Contribution ๊ทธ๋ํ
Loading data ...
Notice
Recent Posts
Recent Comments
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 |
Tags
- ์ฃผ์ฑ๋ถ๋ถ์
- ๋น ๋ฐ์ดํฐ๋ถ์๊ธฐ์ฌ
- Python
- datascience
- ๋ฐ์ดํฐ๋ถ์์ค์ ๋ฌธ๊ฐ
- t-test
- ๋ ๋ฆฝํ๋ณธ
- ๊ตฐ์งํ
- pandas
- iloc
- ํ ์คํธ๋ถ์
- ๋ฐ์ดํฐ๋ถ์์ ๋ฌธ๊ฐ
- dataframe
- ์ธ๋์ํ๋ง
- Lambda
- ์๋ํด๋ผ์ฐ๋
- numpy
- DBSCAN
- opencv
- ํ์ด์ฌ
- ๋ฐ์ดํฐ๋ถ๊ท ํ
- ์ค๋ฒ์ํ๋ง
- PCA
- ๋ฐ์ดํฐ๋ถ์
- ๋์ํ๋ณธ
- LDA
- ADP
- ๋น ๋ฐ์ดํฐ
- ํฌ๋กค๋ง
- ADsP
Archives
Data Science LAB
[Python] OpenCV ๊ธฐ์ด 9 - ์ด๋ฏธ์ง ๋ณํ (2) (์๊ทผ) ๋ณธ๋ฌธ
๐ฅ๏ธ Computer Vision/Opencv
[Python] OpenCV ๊ธฐ์ด 9 - ์ด๋ฏธ์ง ๋ณํ (2) (์๊ทผ)
ใ ใ ใ ใ 2022. 8. 9. 21:51728x90
1. ์ฌ๋ค๋ฆฌ๊ผด ์ด๋ฏธ์ง ํผ์น๊ธฐ
cv2.getPerspectiveTransform([input], [output])
cv2.warpPerspective([์ด๋ฏธ์ง], [matrix], [(width, height)])
import cv2
import numpy as np
img = cv2.imread('img.jpg')
width, height = 640,240
src = np.array([[511,352], [1008,345], [1122,584], [455,594]], dtype = np.float32) # input 4๊ฐ ์ง์
dat = np.array([[0,0], [width,0], [width,height], [0,height]], dtype=np.float32) # output 4๊ฐ ์ง์
# ์ข์, ์ฐ์, ์ฐํ, ์ขํ(์๊ณ ๋ฐฉํฅ์ผ๋ก 4๊ฐ ์ง์ ์ ์)
matrix = cv2.getPerspectiveTransform(src,dat) # matrix ์ป์ด์ด
result = cv2.warpPerspective(img, matrix, (width,height)) # matrix์ ๋ํ ๋ฐํ
cv2.imshow('img',img)
cv2.imshow('result',result)
cv2.waitKey(0)
cv2.destroyAllWindows()
์ฌ๋ค๋ฆฌ๊ผด ํํ๋ก ๊ธฐ์ธ์ด์ ธ ์๋ ์ ๋ฌธ์ ์ผ๋ถ๋ฅผ ๋ฐ๋ฅด๊ฒ ์ธ์์ ํ์ธ
2. ํ์ ๋ ์ด๋ฏธ์ง ์ธ์ฐ๊ธฐ
import cv2
import numpy as np
img = cv2.imread('poker.jpg')
width, height = 530,710
src = np.array([[702,143], [1133,413], [726,1007], [276,700]], dtype = np.float32) # input 4๊ฐ ์ง์
dat = np.array([[0,0], [width,0], [width,height], [0,height]], dtype=np.float32) # output 4๊ฐ ์ง์
# ์ข์, ์ฐ์, ์ฐํ, ์ขํ(์๊ณ ๋ฐฉํฅ์ผ๋ก 4๊ฐ ์ง์ ์ ์)
matrix = cv2.getPerspectiveTransform(src,dat) # matrix ์ป์ด์ด
result = cv2.warpPerspective(img, matrix, (width,height)) # matrix์ ๋ํ ๋ฐํ
cv2.imshow('img',img)
cv2.imshow('result',result)
cv2.waitKey(0)
cv2.destroyAllWindows()
๋์ผํ ์ฝ๋๋ฅผ ์ด์ฉํ์ฌ ๊ธฐ์ธ์ด์ ธ ์๋ ์นด๋๋ฅผ ์ฌ๋ฐ๋ฅด๊ฒ ํ์ ์ํฌ ์ ์๋ค.
์นด๋์ 4 ํฌ์ธํธ๋ฅผ ์ ๋ ฅํ๋ค ์๋ก์ด ์ด๋ฏธ์ง๋ฅผ ๋์์ ์ฌ๋ฐ๋ฅธ ๊ฐ๋๋ก ์ธ์
728x90
'๐ฅ๏ธ Computer Vision > Opencv' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Python] OpenCV ๊ธฐ์ด 11 - ์ด๋ฏธ์ง ๋ณํ(ํฝ์ฐฝ ๋ฐ ์นจ์) (0) | 2022.08.11 |
---|---|
[Python] OpenCV ๊ธฐ์ด 10 - ์ด๋ฏธ์ง ๋ณํ(์ด์งํ) (0) | 2022.08.10 |
[Python] OpenCV ๊ธฐ์ด 8 - ์ด๋ฏธ์ง ๋ณํ(ํ๋ฐฑ, ํ๋ฆผ) (0) | 2022.08.08 |
[Python] OpenCV ๊ธฐ์ด 7 - ์ด๋ฏธ์ง ๋์นญ ๋ฐ ํ์ (0) | 2022.08.07 |
[Python] OpenCV ๊ธฐ์ด 6 - ์ด๋ฏธ์ง ์๋ฅด๊ธฐ(Crop) (0) | 2022.08.06 |
Comments