Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7ce693b

Browse files
committed
camera_calibration 棋盘
1 parent 16a5917 commit 7ce693b

File tree

83 files changed

+58
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+58
-0
lines changed
4.89 KB
Binary file not shown.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# -*- coding: utf-8 -*-
2+
# @Time : 2017年11月14日 17:09
3+
# @Author : play4fun
4+
# @File : cc1.py
5+
# @Software: PyCharm
6+
7+
"""
8+
camera_calibration1.py:
9+
10+
有结果,但是摄像头分辨率太高,程序运行太慢了
11+
12+
所用棋盘来自
13+
http://wiki.ros.org/camera_calibration/Tutorials/MonocularCalibration?action=AttachFile&do=view&target=check-108.pdf
14+
"""
15+
import numpy as np
16+
import cv2
17+
18+
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)
19+
cap = cv2.VideoCapture(0)
20+
21+
22+
#等比缩放
23+
frame_height = cap.get(cv2.CAP_PROP_FRAME_HEIGHT)#4 ,720
24+
frame_width = cap.get(cv2.CAP_PROP_FRAME_WIDTH)#3 ,1280
25+
frame_height=int(480/frame_width*frame_height)#270
26+
ret = cap.set(cv2.CAP_PROP_FRAME_HEIGHT, frame_height)#高
27+
ret = cap.set(cv2.CAP_PROP_FRAME_WIDTH, 480)
28+
#
29+
30+
while cap.isOpened():
31+
# img = cv2.imread(fname)
32+
ret, img = cap.read()
33+
34+
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
35+
36+
ret, corners = cv2.findChessboardCorners(image=gray, patternSize=(6, 4), corners=None)
37+
'''
38+
第一个参数Image,传入拍摄的棋盘图Mat图像,必须是8位的灰度或者彩色图像;
39+
第二个参数patternSize,每个棋盘图上内角点的行列数,一般情况下,行列数不要相同,便于后续标定程序识别标定板的方向;
40+
第三个参数corners,用于存储检测到的内角点图像坐标位置,一般用元素是Point2f的向量来表示:vector<Point2f> image_points_buf;
41+
第四个参数flage:用于定义棋盘图上内角点查找的不同处理方式,有默认值。
42+
'''
43+
print(corners)
44+
print('---------')
45+
if ret == True:
46+
# objpoints.append(objp)
47+
corners2 = cv2.cornerSubPix(gray, corners, (11, 11), (-1, -1), criteria)
48+
# imgpoints.append(corners)
49+
# Draw and display the corners
50+
cv2.drawChessboardCorners(img, (6, 4), corners2, ret)
51+
52+
cv2.imshow('img', img)
53+
54+
key = cv2.waitKey(delay=10)
55+
if key == ord("q"):
56+
break
57+
58+
cv2.destroyAllWindows()
327 KB
244 KB
233 KB
232 KB
321 KB
274 KB
288 KB
313 KB

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /