Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

imported cv2 as cv#26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
AdityaShimpi wants to merge1 commit intoCodecWang:master
base:master
Choose a base branch
Loading
fromAdityaShimpi:patch-1
Open
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions03-Open-Camera/cv2_capture_live_video_from_camera.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
import cv2
import cv2 as cv

# 1.打开摄像头
capture =cv2.VideoCapture(2)
capture =cv.VideoCapture(2)

# 2.获取捕获的分辨率
width, height = capture.get(3), capture.get(4)
print(width, height)
# 以原分辨率的一倍来捕获,
# 参数1可以直接写数字,或者OpenCV符号表示
capture.set(cv2.CAP_PROP_FRAME_WIDTH, width * 2)
capture.set(cv2.CAP_PROP_FRAME_HEIGHT, height * 2)
capture.set(cv.CAP_PROP_FRAME_WIDTH, width * 2)
capture.set(cv.CAP_PROP_FRAME_HEIGHT, height * 2)

while(True):
# 获取一帧
ret, frame = capture.read()
# 将这帧转换为灰度图
gray =cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
gray =cv.cvtColor(frame,cv.COLOR_BGR2GRAY)

cv2.imshow('frame', gray)
ifcv2.waitKey(1) == ord('q'):
cv.imshow('frame', gray)
ifcv.waitKey(1) == ord('q'):
break

[8]ページ先頭

©2009-2025 Movatter.jp