pande
@pande1104
說
Tue, Feb 7, 2023 2:03 PM
[讀書學習] 《AIOT與OpenCV實戰應用(第三版):Python、樹莓派、物聯網與機器視覺》
第三篇 OpenCV
3-3 讀取圖檔與存檔
Raspberry_pi
pande
@pande1104
說
Tue, Feb 7, 2023 2:08 PM
Tue, Feb 7, 2023 2:19 PM
復習2-11(攝影機)
製備圖檔的方法
1. 命令列 $raspistill -t mSec -o 'Filename'
2. Python: from picamera import PiCamera
pande
@pande1104
說
Tue, Feb 7, 2023 2:19 PM
Tue, Feb 7, 2023 3:02 PM
復習3-2(影像顯示與儲存)
cv2.VideoCapture(0)
ret, frame = cv2.VideoCapture(0).read()
cv2.imshow('WindowsName', frame)
cv2.waitKey(mSec)
cv2.destroyAllWindows()
cv2.VideoWriter('videoFilename',fourcc,FPS,(寬,高))
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
cv2.VideoWriter(略).write(frame)
pande
@pande1104
說
Tue, Feb 7, 2023 2:31 PM
3-3-1 讀取圖檔
cv2.imread('picFilename', cv2.IMREAD_GRAYSCALE)
cv2讀檔屬性
IMREAD_UNCHANGED (值-1):原色道(含α)
IMREAD_GRAYSCALE (值0):灰階
IMREAD_COLOR (值1):RGB三色道
3-3-2 存檔
cv2.imwrite('picFilename', frame)
檔案副檔名:jpg格式/jpeg格式 (OpenCV依命名自動調整)
載入新的回覆
第三篇 OpenCV
3-3 讀取圖檔與存檔
Raspberry_pi
製備圖檔的方法
1. 命令列 $raspistill -t mSec -o 'Filename'
2. Python: from picamera import PiCamera
cv2.VideoCapture(0)
ret, frame = cv2.VideoCapture(0).read()
cv2.imshow('WindowsName', frame)
cv2.waitKey(mSec)
cv2.destroyAllWindows()
cv2.VideoWriter('videoFilename',fourcc,FPS,(寬,高))
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
cv2.VideoWriter(略).write(frame)
cv2.imread('picFilename', cv2.IMREAD_GRAYSCALE)
cv2讀檔屬性
IMREAD_UNCHANGED (值-1):原色道(含α)
IMREAD_GRAYSCALE (值0):灰階
IMREAD_COLOR (值1):RGB三色道
3-3-2 存檔
cv2.imwrite('picFilename', frame)
檔案副檔名:jpg格式/jpeg格式 (OpenCV依命名自動調整)