opencv cam

This commit is contained in:
glmdev 2019-02-10 00:38:47 -06:00
parent a0ce12ba0b
commit f0b35991e8
2 changed files with 19 additions and 13 deletions

View File

@ -32,8 +32,8 @@
<file pinned="false" current-in-tab="true"> <file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/camera.py"> <entry file="file://$PROJECT_DIR$/camera.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="75"> <state relative-caret-position="150">
<caret line="5" column="40" selection-start-line="5" selection-start-column="40" selection-end-line="5" selection-end-column="40" /> <caret line="10" column="9" lean-forward="true" selection-start-line="10" selection-start-column="9" selection-end-line="10" selection-end-column="9" />
<folding> <folding>
<element signature="e#0#13#0" expanded="true" /> <element signature="e#0#13#0" expanded="true" />
</folding> </folding>
@ -277,8 +277,8 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/camera.py"> <entry file="file://$PROJECT_DIR$/camera.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="75"> <state relative-caret-position="150">
<caret line="5" column="40" selection-start-line="5" selection-start-column="40" selection-end-line="5" selection-end-column="40" /> <caret line="10" column="9" lean-forward="true" selection-start-line="10" selection-start-column="9" selection-end-line="10" selection-end-column="9" />
<folding> <folding>
<element signature="e#0#13#0" expanded="true" /> <element signature="e#0#13#0" expanded="true" />
</folding> </folding>

View File

@ -2,16 +2,22 @@ import pygame
import pygame.camera import pygame.camera
import time import time
import cv2
def capture(camera_stream = "/dev/video0", camera_res = (1920, 1080)): def capture(camera_stream = 0, camera_res = (1920, 1080)):
pygame.camera.init() cam = cv2.VideoCapture(camera_stream)
pygame.camera.list_cameras() s, img = cam.read()
cam = pygame.camera.Camera(camera_stream, camera_res)
cam.start() if s:
time.sleep(5) cv2.imwrite('./capture.jpg', img)
img = cam.get_image() # pygame.camera.init()
pygame.image.save(img, './capture.jpg') # pygame.camera.list_cameras()
cam.stop() # cam = pygame.camera.Camera(camera_stream, camera_res)
# cam.start()
# time.sleep(5)
# img = cam.get_image()
# pygame.image.save(img, './capture.jpg')
# cam.stop()
return './capture.jpg' return './capture.jpg'