欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

基于python opencv單目相機(jī)標(biāo)定的示例代碼

 更新時(shí)間:2022年01月05日 09:31:53   作者:冰軟  
這篇文章主要介紹了基于python opencv單目相機(jī)標(biāo)定的實(shí)現(xiàn)代碼,代碼簡(jiǎn)單易懂,對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

相機(jī)固定不動(dòng),通過標(biāo)定版改動(dòng)不同方位的位姿進(jìn)行抓拍

import cv2
camera=cv2.VideoCapture(1)
i = 0
while 1:
    (grabbed, img) = camera.read()
    cv2.imshow('img',img)
    if cv2.waitKey(1) & 0xFF == ord('j'):  # 按j保存一張圖片
        i += 1
        u = str(i)
        firename=str('./img'+u+'.jpg')
        cv2.imwrite(firename, img)
        print('寫入:',firename)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

將抓拍好的圖片存放程序的同一級(jí)目錄下 運(yùn)行標(biāo)定代碼如下:

# 相機(jī)標(biāo)定
import cv2
# 修改目錄
# 首先讀取圖像并轉(zhuǎn)為灰度圖
img = cv2.imread('c1.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# cv2.imshow("img",img)
# cv2.imshow("gray",gray)
# 使用OpenCV的cv2.findChessboardCorners()函數(shù)找出棋盤圖中的對(duì)角(即圖片中黑白相對(duì)的點(diǎn)的坐標(biāo)),
# 同時(shí)使用cv2.drawChessboardCorners()將之畫出來
# cv2.findChessboardCorners參數(shù)patternSize?。?,5)--棋盤圖中每行和每列交點(diǎn)的個(gè)數(shù)
# 其原因在于導(dǎo)入的圖片./camera_cal/calibration1.jpg數(shù)一下交點(diǎn)的數(shù)目,一行有9個(gè),一列有5個(gè)
# Adam博客當(dāng)中?。?,6)原因在于他的圖和我的圖不一樣,認(rèn)真數(shù)一下可以發(fā)現(xiàn)他的圖確實(shí)是一行9個(gè)一列6個(gè)角點(diǎn)
# 事實(shí)證明,可以取任何只要在size小于圖片中的交點(diǎn)數(shù)即可
# 函數(shù)解析參見官網(wǎng)https://docs.opencv.org/3.3.0/dc/dbb/tutorial_py_calibration.html
# It returns the corner points and retval which will be True if pattern is obtained.
# These corners will be placed in an order (from left-to-right, top-to-bottom)
ret, corners = cv2.findChessboardCorners(gray, (9, 5),None)
print(ret)
print(corners)  # 交點(diǎn)坐標(biāo)
if ret == True:
    img = cv2.drawChessboardCorners(img, (9, 5), corners, ret)
cv2.imshow("final",img)
cv2.waitKey()
cv2.destroyAllWindows()

到此這篇關(guān)于基于python opencv單目相機(jī)標(biāo)定的文章就介紹到這了,更多相關(guān)python opencv相機(jī)標(biāo)定內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論