Skip to content

Instantly share code, notes, and snippets.

@orejuelajd
Last active July 28, 2016 19:20
Show Gist options
  • Save orejuelajd/2257f243273815db0d898f9d10228da5 to your computer and use it in GitHub Desktop.
Save orejuelajd/2257f243273815db0d898f9d10228da5 to your computer and use it in GitHub Desktop.
Este apunte es para instalar pyhton y opencv en Ubuntu, además de como hacer un hello world con opencv y python en Ubuntu.

Hello world con OpenCv y Python en Ubuntu

Nota: La versión de Ubuntu es la 16.04 LTS.

  1. Para instalar Python en Ubuntu (La versión 16.04 de Ubuntu LTS ya tiene Python instalado):
sudo apt-get install python
  1. Instalar OpenCV para Python
sudo apt-get install libopencv-*
sudo apt-get install python-opencv
sudo apt-get install python-numpy
  1. Crear un archivo .py (ex: "helloworld.py") y en el archivo colocar este código:
print "Hola mundo"
  1. Ejecutar el archivo en la terminal:
python helloworld.py
  1. En el archivo creado podemos agregar líneas para probar si la instalación de opencv fue exitosa. Cabe resaltar que hay que preparar y guardar cualquier imagen jpg, en este caso en el escritorio de ubuntu, llamada "imagen.jpg". Al ejecutar el script se mostrará la imagen en una ventana y se cerrará al presionar la tecla cero (0).
import cv2
imagen = cv2.imread("/home/juan/Escritorio/imagen.jpg")
cv2.imshow("ventana", imagen)
print "Hola mundo"
cv2.waitKey(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment