-
Notifications
You must be signed in to change notification settings - Fork 0
/
picture.py
36 lines (35 loc) · 852 Bytes
/
picture.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""
from SimpleCV import Image, Camera
def picture():
cam = Camera()
img = cam.getImage()
img.save('selfie.jpg')
"""
#
## from VideoCapture import Device
## cam = Device()
## cam.saveSnapshot('image.jpg')
#
#import pygame
#import pygame.camera
#
#pygame.camera.init()
## pygame.camera.list_camera() #Camera detected or not
#cam = pygame.camera.Camera("/dev/video0",(640,480))
#cam.start()
#
#def picture():
# img = cam.get_image()
# pygame.image.save(img,"selfie.jpg")
from cv2 import *
import time
def picture():
# initialize the camera
cam = VideoCapture(0) # 0 -> index of camera
time.sleep(1)
s, img = cam.read()
if s: # frame captured without any errors
namedWindow("cam-test",CV_WINDOW_AUTOSIZE)
imshow("cam-test",img)
destroyWindow("cam-test")
imwrite("selfie.jpg",img) #save image