In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to achieve camera calibration opencv, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to understand it!
Original drawing
After correction
I created a new jz folder to hold the pictures needed for camera correction, as follows: a total of 12
# coding:utf-8import cv2import numpy as npimport glob# find checkerboard corners # threshold criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001) # Checkerboard template specifications are calculated from 0, w = 9h = checkerboard lattice points in the world coordinate system, for example, (0memo 0pen0), (1jort0jin0), (2jing0jin0), (8core5), remove Z coordinates. Write it down as the two-dimensional matrix objp = np.zeros ((w * h, 3), np.float32) objp [:,: 2] = np.mgrid [0VV w, 0RH] .T.reshape (- 1) 2) # storing the world coordinates of the checkerboard corners and the image coordinate pairs objpoints = [] # 3D points in the world coordinate system imgpoints = [] # match the specific files in the read folder images = glob.glob ('jz/*.jpg') for fname in images: img = cv2.imread (fname) gray = cv2.cvtColor (img, cv2.COLOR_BGR2GRAY) # find the checkerboard corners ret Corners = cv2.findChessboardCorners (gray, (w, h), None) # display the corners on the image cv2.drawChessboardCorners (img, (w, h), corners, ret) cv2.imshow ('findCorners', img) cv2.waitKey (500) cv2.destroyAllWindows () # if enough pairs are found Store it if ret = = True: cv2.cornerSubPix (gray, corners, (11,11), (- 1,-1), criteria) objpoints.append (objp) imgpoints.append (corners) # calibrate ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera (objpoints, imgpoints, gray.shape [::-1], None, None) # in application Write the following two dead print (mtx) print (dist) # de-distorted img2 = cv2.imread ('77.jpg') h, w = img2.shape [: 2] newcameramtx, roi = cv2.getOptimalNewCameraMatrix (mtx, dist, (wjold h), 0, (wjold h)) # Free ratio parameter dst = cv2.undistort (img2, mtx, dist, None, newcameramtx) # crop the picture # x _ jpgh according to the previous ROI region X:x+w] cv2.imwrite ('1.jpg calibration, dst) cv2.imshow (' findCorners', dst) cv2.waitKey (0) cv2.destroyAllWindows () above are all the contents of the article "how to calibrate the camera with opencv" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.