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 c17a3b7

Browse files
Add files via upload
1 parent 7d65be0 commit c17a3b7

File tree

1 file changed

+31
-0
lines changed

1 file changed

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

0 commit comments

Comments
(0)

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