Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
66549414
Commit
66549414
authored
May 17, 2016
by
Hannes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed "tot_error" to "mean_error" & nicer whitespace
parent
3b2a194c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
py_calibration.markdown
...torials/py_calib3d/py_calibration/py_calibration.markdown
+10
-10
No files found.
doc/py_tutorials/py_calib3d/py_calibration/py_calibration.markdown
View file @
66549414
...
...
@@ -150,7 +150,7 @@ So now we have our object points and image points we are ready to go for calibra
use the function,
**cv2.calibrateCamera()**
. It returns the camera matrix, distortion coefficients,
rotation and translation vectors etc.
@code{.py}
ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(objpoints, imgpoints, gray.shape
[
::-1
]
,
None,
None)
ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(objpoints, imgpoints, gray.shape
[
::-1
]
,
None,
None)
@endcode
### Undistortion
...
...
@@ -165,7 +165,7 @@ So we take a new image (left12.jpg in this case. That is the first image in this
@code{.py}
img = cv2.imread('left12.jpg')
h, w = img.shape
[
:2
]
newcameramtx, roi=cv2.getOptimalNewCameraMatrix(mtx,
dist,(w,h),1,
(w,h))
newcameramtx, roi=cv2.getOptimalNewCameraMatrix(mtx,
dist, (w,h), 1,
(w,h))
@endcode
#### 1. Using **cv2.undistort()**
...
...
@@ -175,9 +175,9 @@ This is the shortest path. Just call the function and use ROI obtained above to
dst = cv2.undistort(img, mtx, dist, None, newcameramtx)
# crop the image
x,
y,w,
h = roi
x,
y, w,
h = roi
dst = dst
[
y:y+h, x:x+w
]
cv2.imwrite('calibresult.png',dst)
cv2.imwrite('calibresult.png',
dst)
@endcode
#### 2. Using **remapping**
...
...
@@ -185,13 +185,13 @@ This is curved path. First find a mapping function from distorted image to undis
use the remap function.
@code{.py}
# undistort
mapx,
mapy = cv2.initUndistortRectifyMap(mtx,dist,None,newcameramtx,(w,h),
5)
dst = cv2.remap(img,
mapx,mapy,
cv2.INTER_LINEAR)
mapx,
mapy = cv2.initUndistortRectifyMap(mtx, dist, None, newcameramtx, (w,h),
5)
dst = cv2.remap(img,
mapx, mapy,
cv2.INTER_LINEAR)
# crop the image
x,
y,w,
h = roi
x,
y, w,
h = roi
dst = dst
[
y:y+h, x:x+w
]
cv2.imwrite('calibresult.png',dst)
cv2.imwrite('calibresult.png',
dst)
@endcode
Both the methods give the same result. See the result below:
...
...
@@ -215,8 +215,8 @@ calibration images.
mean_error = 0
for i in xrange(len(objpoints)):
imgpoints2, _ = cv2.projectPoints(objpoints
[
i
]
, rvecs
[
i
]
, tvecs
[
i
]
, mtx, dist)
error = cv2.norm(imgpoints
[
i
]
,imgpoints2, cv2.NORM_L2)/len(imgpoints2)
tot
_error += error
error = cv2.norm(imgpoints
[
i
]
,
imgpoints2, cv2.NORM_L2)/len(imgpoints2)
mean
_error += error
print "total error: ", mean_error/len(objpoints)
@endcode
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment