600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > 制作OpenCV相机标定板棋盘格图像

制作OpenCV相机标定板棋盘格图像

时间:2021-03-29 06:37:50

相关推荐

制作OpenCV相机标定板棋盘格图像

一,OpenCV 相机标定中棋盘格图像要点

1,棋盘格的内部交点个数boardSize:水平方向(board_width, -w=4)和垂直方向(board_height, -h=5)

个人建议:棋盘格的内部交点个数boardSize的w和h的值不要一样以区分旋转。

2,棋盘格格子(正方形)的边长squareSize:(squareSize, -s=0.025):

二,制作棋盘格图像程序

1,程序语言:Python

2,程序依赖项:numpy, opencv-python,screeninfo

3,代码

# pip install screeninfo # import numpy as npimport cv2import screeninfodef gen_board(board_size, squre_size):'''@board_size: board grid num (horz, vert)@squre_size: board squre length, unit:mm '''# ppmm: pixels per mmppmm_x = 1920 / 476 # Monitor.width / Monitor.width_mmppmm_y = 1080 / 268 # Monitor.height / Monitor.height_mm# rect_pixelsrect_width = int( ppmm_x * squre_size )rect_height = int( ppmm_y * squre_size )img_width = board_size[0] * rect_widthimg_height = board_size[1] * rect_heightprint("board: grid={0}, img={1}".format((rect_width, rect_height), (img_width, img_height)))img = np.ones((img_height, img_width, 3), dtype=np.uint8)pixel = 255for y in range(0, img_height, rect_height):colr_grid = [pixel, pixel, pixel]for x in range(0, img_width, rect_width):cv2.rectangle(img, (x, y, rect_width, rect_height), colr_grid, -1)# next colcolr_grid[0] = 255 - colr_grid[0]colr_grid[1] = 255 - colr_grid[1]colr_grid[2] = 255 - colr_grid[2]# next rowpixel = 255 - pixelcv2.imwrite("board.png", img)def main():for m in screeninfo.get_monitors():print(str(m))# board size: 9,7# board squre length=25mmgen_board((9, 7), 25)if __name__ == '__main__':main()

三,示例

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。