iT邦幫忙

0

OpenCV python 相片修正

  • 分享至 

  • xImage

https://github.com/linghugoogle/CarND-Advanced-Lane-Lines
小弟於本網址中學習車道辨識
不過在一開始的相機校正中無法正常運作
參考大量文章後依舊無法解決
煩請大神指點

import cv2
import numpy as np

img=cv2.imread('C:/Users/humaolin/PycharmProjects/pythonProject/camera_cal/calibration1.jpg')
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

objpoints=[]
imgpoints=[]
img_size=gray.shape[1::-1]

ret, corners = cv2.findChessboardCorners(gray, (9,6),None)
ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(objpoints, imgpoints, img_size,None,None)
undistort_img = cv2.undistort(img, mtx, dist, None, mtx)


cv2.imshow('gq',undistort_img)
cv2.waitKey()```
以上是我的程式碼
下方為報錯訊息
C:\Users\humaolin\PycharmProjects\pythonProject\venv\Scripts\python.exe C:/Users/humaolin/PycharmProjects/pythonProject/123.py
Traceback (most recent call last):
  File "C:/Users/humaolin/PycharmProjects/pythonProject/123.py", line 12, in <module>
    ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(objpoints, imgpoints, img_size,None,None)
cv2.error: OpenCV(4.5.2) C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-_8k9tw8n\opencv\modules\calib3d\src\calibration.cpp:3694: error: (-215:Assertion failed) nimages > 0 in function 'cv::calibrateCameraRO'


Process finished with exit code 1
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

1

我要發表回答

立即登入回答