DrawingProcess
๋“œํ”„ DrawingProcess
DrawingProcess
์ „์ฒด ๋ฐฉ๋ฌธ์ž
์˜ค๋Š˜
์–ด์ œ
ยซ   2025/06   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
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
  • ๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ (964)
    • Profile & Branding (22)
      • Career (15)
    • IT Trends (254)
      • Conference, Faire (Experien.. (31)
      • News (187)
      • Youtube (19)
      • TED (8)
      • Web Page (2)
      • IT: Etc... (6)
    • Contents (97)
      • Book (66)
      • Lecture (31)
    • Project Process (94)
      • Ideation (0)
      • Study Report (34)
      • Challenge & Award (22)
      • 1Day1Process (5)
      • Making (5)
      • KRC-FTC (Team TC(5031, 5048.. (10)
      • GCP (GlobalCitizenProject) (15)
    • Study: ComputerScience(CS) (72)
      • CS: Basic (9)
      • CS: Database(SQL) (5)
      • CS: Network (14)
      • CS: OperatingSystem (3)
      • CS: Linux (39)
      • CS: Etc... (2)
    • Study: Software(SW) (95)
      • SW: Language (29)
      • SW: Algorithms (1)
      • SW: DataStructure & DesignP.. (1)
      • SW: Opensource (15)
      • SW: Error Bug Fix (43)
      • SW: Etc... (6)
    • Study: Artificial Intellige.. (149)
      • AI: Research (1)
      • AI: 2D Vision(Det, Seg, Tra.. (35)
      • AI: 3D Vision (70)
      • AI: MultiModal (3)
      • AI: SLAM (0)
      • AI: Light Weight(LW) (3)
      • AI: Data Pipeline (7)
      • AI: Machine Learning(ML) (1)
    • Study: Robotics(Robot) (33)
      • Robot: ROS(Robot Operating .. (9)
      • Robot: Positioning (8)
      • Robot: Planning & Control (7)
    • Study: DeveloperTools(DevTo.. (83)
      • DevTool: Git (12)
      • DevTool: CMake (13)
      • DevTool: NoSQL(Elastic, Mon.. (25)
      • DevTool: Container (17)
      • DevTool: IDE (11)
      • DevTool: CloudComputing (4)
    • ์ธ์ƒ์„ ์‚ด๋ฉด์„œ (64)
      • ๋‚˜์˜ ์ทจ๋ฏธ๋“ค (7)
      • ๋‚˜์˜ ์ƒ๊ฐ๋“ค (42)
      • ์—ฌํ–‰์„ ๋– ๋‚˜์ž~ (10)
      • ๋ถ„๊ธฐ๋ณ„ ํšŒ๊ณ  (5)

๊ฐœ๋ฐœ์ž ๋ช…์–ธ

โ€œ ๋งค์ฃผ ๋ชฉ์š”์ผ๋งˆ๋‹ค ๋‹น์‹ ์ด ํ•ญ์ƒ ํ•˜๋˜๋Œ€๋กœ ์‹ ๋ฐœ๋ˆ์„ ๋ฌถ์œผ๋ฉด ์‹ ๋ฐœ์ด ํญ๋ฐœํ•œ๋‹ค๊ณ  ์ƒ๊ฐํ•ด๋ณด๋ผ.
์ปดํ“จํ„ฐ๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ๋Š” ์ด๋Ÿฐ ์ผ์ด ํ•ญ์ƒ ์ผ์–ด๋‚˜๋Š”๋ฐ๋„ ์•„๋ฌด๋„ ๋ถˆํ‰ํ•  ์ƒ๊ฐ์„ ์•ˆ ํ•œ๋‹ค. โ€

- Jef Raskin

๋งฅ์˜ ์•„๋ฒ„์ง€ - ์• ํ”Œ์ปดํ“จํ„ฐ์˜ ๋งคํ‚จํ† ์‹œ ํ”„๋กœ์ ํŠธ๋ฅผ ์ฃผ๋„

์ธ๊ธฐ ๊ธ€

์ตœ๊ทผ ๊ธ€

์ตœ๊ทผ ๋Œ“๊ธ€

ํ‹ฐ์Šคํ† ๋ฆฌ

hELLO ยท Designed By ์ •์ƒ์šฐ.
DrawingProcess

๋“œํ”„ DrawingProcess

[Perception] ์นด๋ฉ”๋ผ ์บ˜๋ฆฌ๋ธŒ๋ ˆ์ด์…˜ ์‹ค์Šต (camera calibration): opencv, intrinsic, extrinsic, checker(chess) board ํ™œ์šฉ
Study: Artificial Intelligence(AI)/AI: 2D Vision(Det, Seg, Trac)

[Perception] ์นด๋ฉ”๋ผ ์บ˜๋ฆฌ๋ธŒ๋ ˆ์ด์…˜ ์‹ค์Šต (camera calibration): opencv, intrinsic, extrinsic, checker(chess) board ํ™œ์šฉ

2024. 2. 17. 12:46
๋ฐ˜์‘ํ˜•
๐Ÿ’ก ๋ณธ ๋ฌธ์„œ๋Š” '[Perception] ์นด๋ฉ”๋ผ ์บ˜๋ฆฌ๋ธŒ๋ ˆ์ด์…˜ ์‹ค์Šต (camera calibration): intrinsic, checker(chess) board ํ™œ์šฉ'์— ๋Œ€ํ•ด ์ •๋ฆฌํ•ด๋†“์€ ๊ธ€์ž…๋‹ˆ๋‹ค.
Checker board๋ฅผ ํ™œ์šฉํ•˜์—ฌ Intrinsic Metrix๋ฅผ ๊ตฌํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉํ–ˆ๋˜ ์ฝ”๋“œ ๋ฐ return๊ฐ’์— ๋Œ€ํ•ด ์ •๋ฆฌํ•˜์˜€์œผ๋‹ˆ ์ฐธ๊ณ ํ•˜์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค.

Intrinsic Metrix(K) ์ „์ฒด ์ฝ”๋“œ

import numpy as np
import cv2 as cv
import glob

wc = 8 - 1
hc = 5 - 1
square_size = 70     # QHD 7cm
square_size = 52.5   # FHD 5.25cm

# termination criteria
criteria = (cv.TERM_CRITERIA_EPS + cv.TERM_CRITERIA_MAX_ITER, 30, 0.001)
# prepare object points, like (0,0,0), (1,0,0), (2,0,0) ....,(6,5,0)
objp = np.zeros((wc*hc,3), np.float32)
objp[:,:2] = np.mgrid[0:wc,0:hc].T.reshape(-1,2)*square_size # square_size unit [mm]
# Arrays to store object points and image points from all the images.
objpoints = [] # 3d point in real world space
imgpoints = [] # 2d points in image plane.

dataset = "/home/avs/dataset/blackbox_intrinsic/QHD/"
images = glob.glob(dataset + '*.jpg')

for fname in images:
    img = cv.imread(fname)
    gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
    # Find the chess board corners
    ret, corners = cv.findChessboardCorners(gray, (wc,hc), None)
    # If found, add object points, image points (after refining them)
    if ret == True:
        objpoints.append(objp)
        corners2 = cv.cornerSubPix(gray,corners, (11,11), (-1,-1), criteria)
        imgpoints.append(corners)
        # Draw and display the corners
        cv.drawChessboardCorners(img, (wc,hc), corners2, ret)
        print(fname)
        # cv.imshow('img', img)
        # cv.waitKey(1000)

cv.destroyAllWindows()

ret, mtx, dist, rvecs, tvecs = cv.calibrateCamera(objpoints, imgpoints, gray.shape[::-1], None, None)

print(ret, mtx, dist,rvecs,tvecs,sep='\n')

Intrinsic Metrix ๋ถ€๋ถ„ ์„ค๋ช…

calibration metrix๋ฅผ ๊ตฌํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ๋Œ€๊ฒŒ chess board ์ฝ”๋„ˆ์˜ Width, Height์™€ chess board square size๋ฅผ ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ ๋„ฃ์–ด์ฃผ๋ฉด ๋ฉ๋‹ˆ๋‹ค. ์œ„ ์ฝ”๋“œ์—์„œ๋Š” ์•„๋ž˜์™€ ๊ฐ™์ด ๊ฐ€๋กœ์˜ ์‚ฌ๊ฐํ˜• ๊ฐœ์ˆ˜์ธ 8๊ฐœ, ์„ธ๋กœ ์‚ฌ๊ฐํ˜• ๊ฐœ์ˆ˜์ธ 5๊ฐœ ์‚ฌ์ด์˜ internal ์ฝ”๋„ˆ์˜ ๊ฐœ์ˆ˜๋ฅผ ๊ตฌํ•˜๊ธฐ ์œ„ํ•ด์„œ 1์”ฉ ๋นผ์คŒ์œผ๋กœ์„œ ๋„ฃ์–ด์ฃผ์—ˆ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ chess board square size๋Š” ์‹ค์ œ ํฌ๊ธฐ๋ฅผ ๊ตฌํ•œ ํ›„ mm ๋‹จ์œ„๋กœ ๋„ฃ์–ด์ฃผ์–ด 3์ฐจ์› ๋ณ€ํ™˜์‹œ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

wc = 8 - 1
hc = 5 - 1
square_size = 70     # QHD 7cm
...
objp[:,:2] = np.mgrid[0:wc,0:hc].T.reshape(-1,2)*square_size # square_size unit [mm]

์ดํ›„์˜ ์ฝ”๋“œ๋Š” ๊ทธ๋Œ€๋กœ ๋„ฃ์–ด์ฃผ๋ฉด๋˜๋ฉฐ, ๊ฒฐ๊ณผ ๊ฐ’์œผ๋กœ ๋ฝ‘ํžˆ๋Š” ๊ฐ’๋“ค์„ ๋ถ„์„ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

ret, mtx, dist, rvecs, tvecs = cv.calibrateCamera(objpoints, imgpoints, gray.shape[::-1], None, None)

cv.calibrateCamera() which returns the camera matrix, distortion coefficients, rotation and translation vectors etc.

  • retval: average re-projection error. This number gives a good estimation of precision of the found parameters. This should be as close to zero as possible.
  • camera matrix(mtx): intrinsic parameters of the camera
  • distortion coefficients(dist): radial and tangential distortion parameters (k1, k2, p1, p2, k3)
  • rotation and translation vectors(rvecs, tvecs): extrinsic parameters of the camera

์ถ”๊ฐ€๋กœ retval ์˜ ๊ฒฝ์šฐ, parameter๋ฅผ ์–ผ๋งˆ๋‚˜ ์ž˜ ์ถ”์ •ํ–ˆ๋Š”์ง€๋ฅผ ๋‚˜ํƒ€๋‚ด๋ฉฐ, rms ๊ฐ’์ด 1์ผ ๊ฒฝ์šฐ 3D chess board point๋ฅผ 2D์— ํˆฌ์˜ํ–ˆ์„ ๋•Œ image point์™€ ๋น„๊ตํ•˜์—ฌ ํ‰๊ท ์ ์œผ๋กœ 1.0px๊ฐ€ ์ฐจ์ด๊ฐ€ ๋‚˜๋Š” ๊ฒƒ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ 0์— ๊ฐ€๊นŒ์šธ์ˆ˜๋ก ์ข‹์€ ๊ฐ’์ด๋ฉฐ, ๋Œ€๊ฒŒ [0,1] ์‚ฌ์ด์˜ ๊ฐ’์„ ๊ฐ–๋Š”๋‹ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. 

์ฐธ๊ณ 

  • [opencv] Camera Calibration: https://docs.opencv.org/4.x/dc/dbb/tutorial_py_calibration.html
  • [opencv] Camera calibration With OpenCV(retval): https://docs.opencv.org/2.4/doc/tutorials/calib3d/camera_calibration/camera_calibration.html
  • [stackoverflow] Meaning of the retval return value in cv2.CalibrateCamera: https://stackoverflow.com/questions/29628445/meaning-of-the-retval-return-value-in-cv2-calibratecamera
  • [stackoverflow] Camera Calibration with OpenCV - How to adjust chessboard square size?: https://stackoverflow.com/questions/37310210/camera-calibration-with-opencv-how-to-adjust-chessboard-square-size 
๋ฐ˜์‘ํ˜•
์ €์ž‘์žํ‘œ์‹œ ๋น„์˜๋ฆฌ ๋ณ€๊ฒฝ๊ธˆ์ง€ (์ƒˆ์ฐฝ์—ด๋ฆผ)

'Study: Artificial Intelligence(AI) > AI: 2D Vision(Det, Seg, Trac)' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[๋…ผ๋ฌธ๋ฆฌ๋ทฐ] SAM (CVPR 2023): Foundation - Segment Anything Model  (0) 2024.03.02
[Perception] open-mmlab mmdeploy ์‚ฌ์šฉ ๊ฐ€์ด๋“œ(feat. onnx tenserrt ๋ชจ๋ธ ๋ณ€ํ™˜, RTMDet)  (0) 2024.02.25
[๋…ผ๋ฌธ๋ฆฌ๋ทฐ] Transformer: Attention is All you need  (1) 2024.02.07
[Vision] CNN Network ๊ธฐ๋ณธ ๋ชจ๋ธ ์ •๋ฆฌ (LeNet-5 ๋ถ€ํ„ฐ ResNet ๊นŒ์ง€)  (1) 2024.02.06
[Vision] Object Tracking: VOT(Visual Object Tracking), MOT(Multiple Object Tracking)  (0) 2024.02.05
    'Study: Artificial Intelligence(AI)/AI: 2D Vision(Det, Seg, Trac)' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€
    • [๋…ผ๋ฌธ๋ฆฌ๋ทฐ] SAM (CVPR 2023): Foundation - Segment Anything Model
    • [Perception] open-mmlab mmdeploy ์‚ฌ์šฉ ๊ฐ€์ด๋“œ(feat. onnx tenserrt ๋ชจ๋ธ ๋ณ€ํ™˜, RTMDet)
    • [๋…ผ๋ฌธ๋ฆฌ๋ทฐ] Transformer: Attention is All you need
    • [Vision] CNN Network ๊ธฐ๋ณธ ๋ชจ๋ธ ์ •๋ฆฌ (LeNet-5 ๋ถ€ํ„ฐ ResNet ๊นŒ์ง€)
    DrawingProcess
    DrawingProcess
    ๊ณผ์ •์„ ๊ทธ๋ฆฌ์ž!

    ํ‹ฐ์Šคํ† ๋ฆฌํˆด๋ฐ”