OpenCV從攝像頭讀取資料,並顯示在視窗上

2021-08-28 22:03:12 字數 603 閱讀 8061

《opencv系列教程》

專案位置:opencv-sample

**位置:1-cameratest.py

import cv2

cameracapture = cv2.videocapture(0)

cv2.namedwindow('test camera')

success, frame = cameracapture.read()

while success:

if cv2.waitkey(1) == 27:

break

cv2.imshow('test camera', frame)

success, frame = cameracapture.read()

cameracapture.release()

namewindow(『test camera』) 其實是建立乙個名字叫」test camera「的視窗。

waitkey(1) 讀取使用者鍵盤輸入引數1,是等待時間單位毫秒milliseconds。

imshow(『test camera』, frame) 將frame中的資料,顯示到名字為」test camera「 的視窗上。

OPENCV讀取攝像頭

opencv highgui cvcreatecameracapture 或cvcapturefromcam windows 中都是由較為低效的 vfw機制實現的,不適合在最終產品中使用。在 windows 中使用directshow opencv 中文網的 yushiqi 提供了乙個基於 dire...

OpenCV攝像頭讀取

在mac下面使用預設的opencv讀取攝像頭程式會報錯 int main int,char videocapture cap 0 open the default camera if cap.isopened check if we succeeded return 1 mat edges name...

OpenCV基礎 讀取攝像頭

這兩天需要做乙個疲勞檢測,目前正在做眼睛部分,額 先丟個讀取攝像頭的 記錄我已經開始 includeusing namespace cv const int desired camera width 640 const int desired camera height 480 int main i...