From 9a98c9a501ce42363fd4662e9381c8a0215a3344 Mon Sep 17 00:00:00 2001 From: cervantes21 Date: Sun, 5 Feb 2023 21:50:15 -0600 Subject: [PATCH 1/7] bradelev feat: add webcam compatibility for different OS --- webcam.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/webcam.py b/webcam.py index 5994134..afb02d0 100644 --- a/webcam.py +++ b/webcam.py @@ -1,11 +1,12 @@ from threading import Thread import cv2 - +import platform #Sugerencia de bradelev class Webcam: def __init__(self): self.stopped = False self.stream = None self.lastFrame = None + self.os_name = platform.system() # bradelev def start(self): t = Thread(target=self.update, args=()) @@ -13,9 +14,16 @@ def start(self): t.start() return self +# -------------------------DETECCIÓN DE CÁMARA -------------------- # def update(self): if self.stream is None: - self.stream = cv2.VideoCapture(0, cv2.CAP_DSHOW) + if self.os_name == "Windows": + self.stream = cv2.VideoCapture(0, cv2.CAP_DSHOW) + elif self.os_name == "Darwin": #macOS + self.stream = cv2.VideoCapture(0, cv2.CAP_AVFOUNDATION) + else: # Linux + self.stream = cv2.VideoCapture(0, cv2.CAP_V4L) +# ------------------------------------------------------------------ # while True: if self.stopped: return From 51e6edf5d38fc298eb0978e40cda2694eddf8844 Mon Sep 17 00:00:00 2001 From: cervantes21 Date: Sun, 5 Feb 2023 21:58:11 -0600 Subject: [PATCH 2/7] Update README and additional information --- README.md | 97 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 88 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 8671103..4c5e422 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,106 @@ -# Misiles -## Información general +# **Misiles** +[![example](https://cdn.pixabay.com/photo/2014/09/11/12/45/spacecraft-441708_960_720.jpg)](https://www.ringa-tech.com/) + +--- +## **Información general** Este repositorio contiene el código para el juego de Misiles controlado por la cara usando Facemesh, como fue creado en mi canal de Youtube: -https://youtu.be/_BjL6W71mWY +[Ringa-Tech](https://youtu.be/_BjL6W71mWY) + +--- + +## **Información Adicional:** -## Configuración +Este juego no puede ser ejecutado en terminales de subsistemas Linux. Cómo WSL, WSL2, Termux, entre otros. Debido a que hay problemas con los triggers. +Se puede ejecutar pero es una tarea demasiado complicada. Te comparto está información de [Stackoverflow](https://stackoverflow.com/questions/65939167/problem-using-opencv-in-wsl-when-opening-windows) en caso de que lo quieras intentar. + +--- +## **Configuración** El proyecto lo hice con Python 3.7.9 + +Pero mediaPipe acepta versiones desde 3.6, hasta 3.10. + +
Instalar en WINDOWS: + +### ***Sigue los siguentes pasos:*** + +Revisar versión de Python: +``` +python --version +``` +Crear un ambiente virtual: +``` +python3 -m virtualenv venv +``` +Activar ambiente virtual: +``` +.\venv\Scripts\activate +``` +Actualizar pip: +``` +python.exe -m pip --upgrade pip +``` Para instalar las dependencias es necesario ejecutar ``` pip install -r requirements.txt ``` -Para ejecutar el juego, ejecutar +
+ +--- + +
Instalar en LINUX: + +### ***Sigue los siguentes pasos:*** + +Revisar versión de Python: +``` +python --version +``` +Crear un ambiente virtual: +``` +python3 -m venv venv +``` +Activar ambiente virtual: +``` +source venv/bin/activate +``` +Actualizar pip: +``` +python -m pip --upgrade pip +``` +Para instalar las dependencias es necesario ejecutar +``` +pip install -r requirements.txt +``` + +
+ +--- + +## **Para Ejecutar:** + +El siguiente comando para ejecutar el juego: + +**WINDOWS** ``` python .\app.py ``` +**LINUX** +``` +python ./app +``` Si no te funciona, prueba usando "python3" o "py" en lugar de "python" en el comando anterior. -## ¿Problemas? -Solo he probado el juego en mi equipo así que seguramente puedes encontrar problemas. +--- -En ese caso por favor levanta un issue aquí en Github, con el mayor detalle que puedas (versión de python, de paquetes, mensaje completo de error, etc). -Si eres ninja y lo solucionas, ¡levanta un Pull Request! +## **¿Problemas?** +En ese caso por favor levanta un [**issue** aquí en Github](), con el mayor detalle que puedas (versión de python, de paquetes, mensaje completo de error, etc). +Si eres ninja y lo solucionas, [¡levanta un Pull Request!](https://github.com/ringa-tech/juego-python-ia-misiles/pulls) + +--- ## Imágenes utilizadas - [Iconos de cohetes creados por Freepik - Flaticon](https://www.flaticon.com/free-icons/rocket) - [Iconos de misiles creados por Freepik - Flaticon](https://www.flaticon.com/free-icons/rocket-launch) - [Fondo creado por Screaming Brain Studios - OpenGameArt](https://opengameart.org/content/seamless-space-backgrounds) + +[![logo-Ringa-tech](https://www.ringa-tech.com/LogotipoV2-Simple.png)](https://www.ringa-tech.com/) \ No newline at end of file From d08b4203363c10dea4ebe05e1a6e3a712c68a2bd Mon Sep 17 00:00:00 2001 From: cervantes21 Date: Sun, 5 Feb 2023 22:08:06 -0600 Subject: [PATCH 3/7] bradelev feat: add webcam compatibility for different OS --- webcam.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webcam.py b/webcam.py index afb02d0..ac2f553 100644 --- a/webcam.py +++ b/webcam.py @@ -1,6 +1,6 @@ from threading import Thread import cv2 -import platform #Sugerencia de bradelev +import platform # Sugerencia de bradelev class Webcam: def __init__(self): self.stopped = False @@ -46,4 +46,4 @@ def height(self): return self.stream.get(cv2.CAP_PROP_FRAME_HEIGHT ) def ready(self): - return self.lastFrame is not None \ No newline at end of file + return self.lastFrame is not None From 4134b71ebbdd9c96a3c69831adab2ebdbaa872d1 Mon Sep 17 00:00:00 2001 From: cervantes21 Date: Sun, 5 Feb 2023 22:17:48 -0600 Subject: [PATCH 4/7] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4c5e422..9946c67 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ --- ## **Información general** -Este repositorio contiene el código para el juego de Misiles controlado por la cara usando Facemesh, como fue creado en mi canal de Youtube: +Este repositorio contiene el código para el juego de Misiles controlado por la cara usando [Facemesh](https://google.github.io/mediapipe/solutions/face_mesh.html), como fue creado en mi canal de Youtube: [Ringa-Tech](https://youtu.be/_BjL6W71mWY) --- From 7f4a6440631beed7018f41b4e13ac0af95a9047b Mon Sep 17 00:00:00 2001 From: cervantes21 Date: Sun, 16 Jul 2023 06:35:40 -0600 Subject: [PATCH 5/7] Correciones a README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9946c67..d736ace 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Activar ambiente virtual: ``` Actualizar pip: ``` -python.exe -m pip --upgrade pip +python.exe -m pip install --upgrade pip ``` Para instalar las dependencias es necesario ejecutar ``` @@ -65,7 +65,7 @@ source venv/bin/activate ``` Actualizar pip: ``` -python -m pip --upgrade pip +python -m pip install --upgrade pip ``` Para instalar las dependencias es necesario ejecutar ``` @@ -103,4 +103,4 @@ Si eres ninja y lo solucionas, [¡levanta un Pull Request!](https://github.com/r - [Iconos de misiles creados por Freepik - Flaticon](https://www.flaticon.com/free-icons/rocket-launch) - [Fondo creado por Screaming Brain Studios - OpenGameArt](https://opengameart.org/content/seamless-space-backgrounds) -[![logo-Ringa-tech](https://www.ringa-tech.com/LogotipoV2-Simple.png)](https://www.ringa-tech.com/) \ No newline at end of file +[![logo-Ringa-tech](https://www.ringa-tech.com/LogotipoV2-Simple.png)](https://www.ringa-tech.com/) From d624a647ec584315e1cb299279ee65244f198e5e Mon Sep 17 00:00:00 2001 From: cervantes21 Date: Sun, 16 Jul 2023 06:37:34 -0600 Subject: [PATCH 6/7] Correciones a README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d736ace..184fb99 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ source venv/bin/activate ``` Actualizar pip: ``` -python -m pip install --upgrade pip +pip install --upgrade pip ``` Para instalar las dependencias es necesario ejecutar ``` From 06def293a516dd9d01952dfc24128571b5df6f41 Mon Sep 17 00:00:00 2001 From: cervantes21 Date: Sun, 16 Jul 2023 06:46:38 -0600 Subject: [PATCH 7/7] Agregando correciones a README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 184fb99..8daf799 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ python .\app.py ``` **LINUX** ``` -python ./app +python ./app.py ``` Si no te funciona, prueba usando "python3" o "py" en lugar de "python" en el comando anterior.