Flux ascii
emhan
-
yg_be Messages postés 24281 Date d'inscription Statut Contributeur Dernière intervention -
yg_be Messages postés 24281 Date d'inscription Statut Contributeur Dernière intervention -
Bonjour souhaite recupérer le flux de se programme
pour en faire une camera virtuel sous obs mais je sait pas comment m'y prendre merci d'avance.
from cv2 import cv2
import numpy as np
def main():
vc = cv2.VideoCapture(0,cv2.CAP_DSHOW)
if vc.isOpened():
rval, frame = vc.read()
else:
rval = False
while rval:
rval, frame = vc.read()
print(toASCII(frame))
key = cv2.waitKey(50) # 50ms pause -> ~20fps
# Press echap to end
if key == 27:
break
def toASCII(frame, cols = 120, rows = 35):
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
height, width = frame.shape
cell_width = width / cols
cell_height = height / rows
if cols > width or rows > height:
raise ValueError('Too many cols or rows.')
result = ""
for i in range(rows):
for j in range(cols):
gray = np.mean(
frame[int(i * cell_height):min(int((i + 1) * cell_height), height), int(j * cell_width):min(int((j + 1) * cell_width), width)]
)
result += grayToChar(gray)
result += '\n'
return result
def grayToChar(gray):
CHAR_LIST = ' .:-=+*#%@'
num_chars = len(CHAR_LIST)
return CHAR_LIST[
min(
int(gray * num_chars / 255),
num_chars - 1
)
]
if __name__ == '__main__':
main()
pour en faire une camera virtuel sous obs mais je sait pas comment m'y prendre merci d'avance.
| EDIT : Ajout des balises de code (la coloration syntaxique).
Explications disponibles ici : ICI Merci d'y penser dans tes prochains messages. |
A voir également:
- Flux ascii
- Code ascii - Guide
- Capture flux - Télécharger - TV & Vidéo
- Code ascii tabulation ✓ - Forum Programmation
- TABULATION - Forum Access
- Coder une tabulation en XSLT - Forum Programmation
1 réponse
yg_be
Messages postés
24281
Date d'inscription
Statut
Contributeur
Dernière intervention
Ambassadeur
1 586
bonjour,
as-tu déjà fait du python sous obs?
sinon, commence peut-être par un exemple simple, pour comprendre le principe:
https://gist.github.com/nibalizer/a6649abee758da3f8d08ef5e164b524c
as-tu déjà fait du python sous obs?
sinon, commence peut-être par un exemple simple, pour comprendre le principe:
https://gist.github.com/nibalizer/a6649abee758da3f8d08ef5e164b524c