- Providing lightweight web-services for autonomous vehicles clients (UAV)s
- Providing lightweight web-services for IoT clients
- Creating an evolving environment for Unmanned Tech developers
- Data collection for improvement of models
- Data collection for data banks
Check my RUP
This project is a lightweight web-service providing trajectory estimation API for users. Nowadays, Trajectory estimation and detection as a fundamental means to robotics and autonomus vehicles technology is in demand of the market of this industry. Thus we decided to develop a web service which can provide a lightweight, responsive web-service for autonomous vehicles and IoT-devices.
Install docker
- First clone the repo or download the repo as a zip and extract it.
git clone https://github.com/Ahuratus/Trajectory-Detection-Web-services.git
- Change Directory
cd Trajectory-Detection-Web-services
- Install application packages
docker-compose --file docker-compose.yml up --build
-
If you faced with issues, check the issues page. if you can't find your problem. place your problem there. we would answer you ASAP!
-
You can use Postman to check our APIs. the
nginx
is running on the port12345
- Full Test
- JWT Auth. Test
- API Test
- Visual output of the trajectory model
I used pyflake
for static analyse. the results are pretty decent as we see in following images. And there are no criticial issues in the code.
I used codacy for checking my code quality. and the results are as following.
However you can see majority issues are related to my readme as following. Moreover my code issues are not such a critical issues which may be ignored for now.
-
Token - tokens are artifacts that allow application systems to perform the authorization and authentication process.
-
Access Token - an access token contains the security credentials for a login session
-
Refresh Token - Once an
access token
expire, clients can use a refresh token to "refresh" the access token. That is, a refresh token is a credential artifact that lets a client application get new access tokens without having to ask the user to log in again. -
Detection model - class of machine learning models with a well defined interface for detecting user desired class of entities
-
Trajectory detection - a sort of detection models which estimates trajectory of the user desired class of entities
- Ehsan Shaghaei
- Project Manager
- Back-End Developer
- Computer Vision
- DevOps
- QA
- Registration User registers through the API providing his "email" and "password" and receives an access token and a refresh token.
http://localhost:12345/api/registration
Example request:
Example Body
{
"email":"dummyuser@ahuratus.ir",
"password":"dummypass"
}
Example Responses
{
"message": "Logged in as dummyuser@ahuratus.ir",
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmcmVzaCI6ZmFsc2UsImlhdCI6MTYzMzg5MjQwNywianRpIjoiOTgxYjE3MDctMTBmZC00YjQ4LTg3ZWQtYzZlNzlmY2E5NzRjIiwidHlwZSI6ImFjY2VzcyIsInN1YiI6ImR1bW15dXNlckBhaHVyYXR1cy5pciIsIm5iZiI6MTYzMzg5MjQwNywiZXhwIjoxNjMzODkzMzA3fQ.GzyMkQb7b4fSGFsSLLKg853K-psydMtDBN47gGS50AM",
"refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmcmVzaCI6ZmFsc2UsImlhdCI6MTYzMzg5MjQwNywianRpIjoiMzM3ZTAyNjMtM2MxMS00MTk1LWI5NTctOTEzZDQ5Y2MyMDFjIiwidHlwZSI6InJlZnJlc2giLCJzdWIiOiJkdW1teXVzZXJAYWh1cmF0dXMuaXIiLCJuYmYiOjE2MzM4OTI0MDcsImV4cCI6MTYzNjQ4NDQwN30.abwFLlwyfd3zQkLnuQNrIy2lRCWjhKUXyXgVzrudFVc"
}
{
"message": "Email dummyuser@ahuratus.ir already exists"
}
- login Registered user logs in through the API providing his "email" and "password" and receives
refresh token
andaccess token
.
http://localhost:12345/api/login
Example request:
Example Body
{
"email":"dummyuser@ahuratus.ir",
"password":"dummypass"
}
Example Responses
{
"message": "User dummyuser@ahuratus.ir was created",
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmcmVzaCI6ZmFsc2UsImlhdCI6MTYzMzg5MjIyNywianRpIjoiZGE4MzQxY2EtMGJhNC00ZGNmLWJhYmUtZDRlMGIxNTFlOWUwIiwidHlwZSI6ImFjY2VzcyIsInN1YiI6ImR1bW15dXNlckBhaHVyYXR1cy5pciIsIm5iZiI6MTYzMzg5MjIyNywiZXhwIjoxNjMzODkzMTI3fQ.ZlUMHK1eWKOIsrzkt2En4zaIyY1rxkbvopmWBnFvZDc",
"refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmcmVzaCI6ZmFsc2UsImlhdCI6MTYzMzg5MjIyNywianRpIjoiN2JkN2RmZDMtYTkxYS00YjFhLWJiNDktOTgwYmRmNGIwNWVlIiwidHlwZSI6InJlZnJlc2giLCJzdWIiOiJkdW1teXVzZXJAYWh1cmF0dXMuaXIiLCJuYmYiOjE2MzM4OTIyMjcsImV4cCI6MTYzNjQ4NDIyN30.Em6RwVhZY5ygKCJKajRC9Qo80-_feRLLBPMrrijJNQA"
}
Example Body
{
"email":"trickyuser@ahuratus.ir",
"password":"dummypass"
}
Example Responses
{
"message": "Email trickyuser@ahuratus.ir doesn't exist"
}
Trajectory Estimation Session: Logged in user send a BASE64
frame and a buffer_size
to the server through the provided API; providing his/her ACCESS TOKEN and receives the estimated trajectory vector,and base64
output frame.
localhost:12345/api/process/trajectory
Example request:
Example Body
{
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmcmVzaCI6ZmFsc2UsImlhdCI6MTYzMzg5Mjc1MiwianRpIjoiYjhjOTgwMzMtYTc1OC00MWU4LWIwMTQtZGM1MzBlYTZhMDcyIiwidHlwZSI6ImFjY2VzcyIsInN1YiI6ImR1bW15dXNlckBhaHVyYXR1cy5pciIsIm5iZiI6MTYzMzg5Mjc1MiwiZXhwIjoxNjMzODkzNjUyfQ.Geahy1wgrbLd94RoOg7_g0Ip1R4JMJRTZ_uruSbX0bg",
"buffer_size":"10",
"frame":"B64 INPUT FRAME"
}
Example Responses
{
"result": "[(693, 390)]",
"trajectory": "b'/9j/4AAQSkZJRgABAQAAAQABAAD/
}
- logout
Logged in user requests for log out and his session will be terminaited,
access token
andrefresh token
will be revoked.
http://localhost:12345/api/logout/access
-
Fast Expired Token Handling beside Postgres, we use Redis to keep track of the expiered tokens because of its fast accessibility.
-
Database recovery: In case of server failure/relocation, respectively failed/new server pulls the newest version of the software from the repository and deploys it. Server runs server initialization script and downloads and extracts the database backup.
-
Database backup: After every 10 requests, server creates a new backup from database.
Simplicity: Service provides a well defined REST API for the well defined user use case scenarios.
Accessibility: We want this service to have 99% uptime and be accessible from any device. We will achieve that using Amazon Cloud Web Service.
Stability: After every 10 requests, server creates a backup. In case of server failure/relocation, respectively failed/new server pulls the newest version of the software from the repository and deploys it. Server runs server initialization script and downloads and extracts the database back up.
Authentication: Service provides the sign up feature with email verification requirement for user, provides a session TOKEN for user login, provides logout
Session safety: Service will log off the user automatically after 10 minutes after last activity. Service supports HTTPS protocol for safer communication
Login Tracking: Service tracks the user login activities
- Single Responsibility: The implemented classes in this project has their own responsibility.
- Open/Closed principle: Classes are open for extection and does not require modifications .
- Liskov Substitution: The hierarchy of the classes in program might be substituted by it's child and that will not lead to any change. example: AImodel class and TrajectoryEstimationModel class
- Interface Segregation: There is no interfaces in the program, which are excessively big.
- Dependency Inversion Principle: in implemented classes high level modules depends on low level modules
Application consist of trajectory detecton service, web service, avaliable for users, and database. Trajectory detection service is a script, written on Python, database is PostgreSQL relational database management system, and web service works with REST API standart. During development we followed ISO 29148:2011 standart, which contains provisions for the processes and products related to the engineering of requirements for systems and software products and services throughout the life cycle.
- the program interface is RESTful API
- the request body must be in JSON format
- the format of the frame in requests must be
base64
encoded 'JPG
'
- Docker
- nginx
- gunicorn
- flask
- jwt
- Postgres
- redis (Used to store jwt token information)
- SQLalchemy
- OpenCV
- numpy
Feel free to contact me for contribution. The project is open source and I would like to invite anybody interested in feild of unmanned control to contribute.
MIT © Ahuratus