camera: transformer un laptop en camera de surveillance pour appartement
This commit is contained in:
24
camera2.py
Normal file
24
camera2.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# program to capture single image from webcam in python
|
||||
|
||||
# importing OpenCV library
|
||||
import cv2
|
||||
|
||||
# initialize the camera
|
||||
# If you have multiple camera connected with
|
||||
# current device, assign a value in cam_port
|
||||
# variable according to that
|
||||
cam_port = 0
|
||||
cam = cv2.VideoCapture(cam_port)
|
||||
|
||||
# reading the input using the camera
|
||||
result, image = cam.read()
|
||||
|
||||
# If image will detected without any error,
|
||||
# show result
|
||||
if result:
|
||||
# saving image in local storage
|
||||
cv2.imwrite("GeeksForGeeks.png", image)
|
||||
# If captured image is corrupted, moving to else part
|
||||
else:
|
||||
print("No image detected. Please! try again")
|
||||
|
||||
Reference in New Issue
Block a user