opencv cam
This commit is contained in:
parent
a0ce12ba0b
commit
f0b35991e8
@ -32,8 +32,8 @@
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/camera.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="75">
|
||||
<caret line="5" column="40" selection-start-line="5" selection-start-column="40" selection-end-line="5" selection-end-column="40" />
|
||||
<state relative-caret-position="150">
|
||||
<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>
|
||||
<element signature="e#0#13#0" expanded="true" />
|
||||
</folding>
|
||||
@ -277,8 +277,8 @@
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/camera.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="75">
|
||||
<caret line="5" column="40" selection-start-line="5" selection-start-column="40" selection-end-line="5" selection-end-column="40" />
|
||||
<state relative-caret-position="150">
|
||||
<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>
|
||||
<element signature="e#0#13#0" expanded="true" />
|
||||
</folding>
|
||||
|
24
camera.py
24
camera.py
@ -2,16 +2,22 @@ import pygame
|
||||
import pygame.camera
|
||||
import time
|
||||
|
||||
import cv2
|
||||
|
||||
def capture(camera_stream = "/dev/video0", camera_res = (1920, 1080)):
|
||||
pygame.camera.init()
|
||||
pygame.camera.list_cameras()
|
||||
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()
|
||||
def capture(camera_stream = 0, camera_res = (1920, 1080)):
|
||||
cam = cv2.VideoCapture(camera_stream)
|
||||
s, img = cam.read()
|
||||
|
||||
if s:
|
||||
cv2.imwrite('./capture.jpg', img)
|
||||
# pygame.camera.init()
|
||||
# pygame.camera.list_cameras()
|
||||
# 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'
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user