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

Commit d97c51f

Browse files
Add files via upload
1 parent 7c7452b commit d97c51f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

‎webcam-capture-v1.01.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import cv2
2+
3+
key = cv2. waitKey(1)
4+
webcam = cv2.VideoCapture(0)
5+
while True:
6+
7+
check, frame = webcam.read()
8+
print(check) #prints true as long as the webcam is running
9+
print(frame) #prints matrix values of each framecd
10+
cv2.imshow("Capturing", frame)
11+
key = cv2.waitKey(1)
12+
if key == ord('s'):
13+
cv2.imwrite(filename='saved_img.jpg', img=frame)
14+
15+
break
16+
elif key == ord('q'):
17+
break
18+
webcam.release()
19+
img_new = cv2.imread('saved_img.jpg', cv2.IMREAD_GRAYSCALE)
20+
img_new = cv2.imshow("Captured Image", img_new)
21+
cv2.waitKey(1650)
22+
cv2.destroyAllWindows()
23+
24+
img_ = cv2.imread('saved_img.jpg', cv2.IMREAD_ANYCOLOR)
25+
gray = cv2.cvtColor(img_, cv2.COLOR_BGR2GRAY)
26+
img_ = cv2.resize(gray,(28,28))
27+
img_resized = cv2.imwrite(filename='saved_img-final.jpg', img=img_)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /