⚲
Projet
Général
Profil
Connexion
S'enregistrer
Accueil
Projets
Aide
Recherche
:
Polytech Ge Sous Traitance
Tous les projets
Polytech Projets Ge
»
Polytech Ge Sous Traitance
Aperçu
Activité
Roadmap
Demandes
Gantt
Calendrier
Annonces
Documents
Wiki
Fichiers
Dépôt
Télécharger (1,05 ko)
Capture de video au ralentit
» capture.py
Marouane SOBTI
, 02/12/2022 14:14
import
cv2
import
sched
,
time
import
sys
import
subprocess
n
=
int
(
sys
.
argv
[
1
])
s
=
sched
.
scheduler
(
time
.
time
,
time
.
sleep
)
img_counter
=
0
def
capture_image
(
sc
):
global
img_counter
print
(
img_counter
)
img_name
=
"opencv_frame_{}.png"
.
format
(
img_counter
)
cv2
.
imwrite
(
img_name
,
frame
)
print
(
"{} written!"
.
format
(
img_name
))
img_counter
+=
1
cam
=
cv2
.
VideoCapture
(
0
)
cv2
.
namedWindow
(
"test"
)
while
True
:
ret
,
frame
=
cam
.
read
()
if
not
ret
:
print
(
"failed to grab frame"
)
break
cv2
.
imshow
(
"test"
,
frame
)
k
=
cv2
.
waitKey
(
1
)
if
k
%
256
==
27
:
# ESC pressed
print
(
"Escape hit, closing..."
)
subprocess
.
call
([
'python'
,
'combine.py'
])
print
(
"Finished:"
+
'combine.py'
)
break
else
:
# SPACE pressed
#img_counter
s
.
enter
(
n
,
1
,
capture_image
,
(
s
,))
#s.enter(5, 1, capture_image, (s,))
s
.
run
()
cam
.
release
()
cv2
.
destroyAllWindows
()
« Précédent
1
2
Suivant »
(1-1/2)
Chargement...