/Hackathon-Mobility-BCN

This project was acknowledged with the first prize, which included an economic compensation of 2000€ and the opportunity of going to SEAT headquarters to present our idea.

Primary LanguagePython

Hackaton Mobility 2018

Project Structure

It's mandatory that you respect the structure of the project. The folders are:

  • docs/: autogenerated documentation of the hackmob package.
  • hackmob/: main package of the project. All the modules (in Python, every .py file is a module) must be inside this folder. ONLY FUNCTIONAL CODE MUST BE UPLOADED HERE
  • hackmob_tests/: tests package of the project. Code in this folder will not be uploaded to GitHub. Use this package to make every test you want.
  • img/: folder to store the images of the people in the face recognition database.
  • models/: deep learning models used in the project.
  • res/: folder to place resource files, like SQLite Databases.

Project Requirements

We will use Python 3.6 to develop this project. The list of dependencies so far is:

numpy, opencv-python

To install dependencies using pip use the following syntax:

pip3 install dependency_name

How-To: Execute the Code

We will use the __main__.py file to execute the hackmob package.

Executing the code from the Terminal

Move to the root folder and execute:

python3 hackmob

Executing the code from PyCharm

We need to modify the default execution behavior. To do that:

  1. Go to Run -> Edit Configurations
  2. Click the + icon and select "Python".
  3. Change "Script path" by "Module name" and set it to "hackmob".
  4. Uncheck the "Show command line afterwards" option (if checked).

If you want to execute a test module execute it as you always do. If it doesn't work tell me

How-To: Include HackMob Modules

To include modules of the hackmob package we must use the following notation:

from hackmob.my_module include MyClass

We can access modules from the hackmob_tests package as well:

from hackmob_tests.my_test_module include MyClass

Remember that the project folder must be in the $PYTHONPATH environment variable.

How-To: Comment Python Code

In order to create the documentation automatically, certain comment rules must be followed. The Sphinx Domain is the standard way to comment Python Code. An example of a commented function is:

def compute_sum(a,b):
    """
    Computes the sum of the input values
    
    :param a: first number
    :param b: second number
    :return: sum of the numbers
    """
    return a + b

How-To: Create Absolute Paths

It's a good practice to use absolute paths to avoid problems. Python provides the os.path package to work with paths. We will use two main functions:

  • os.path.dirname(file_path): returns the absolute path of the directy containing the file.
  • os.path.join(path, *paths): joins various paths.

For example, if we want to load an image from the img/ path from the hackmob/main.py, we can obtain the absolute with the command:

image_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'img', 'image_name.png')

Where __file__ would return the absolute path of the executed file. Notice that we have to use two os.path.dirname.