Giter Club home page Giter Club logo

realtime-closest-person-detection-mongodb's Introduction

Realtime closest person detection <-> MongoDB

This project is a demo that performs a detection of the closest person in a real-time video. The calculation chosen to evaluate who is closer to the camera is the person's height (Change the calculation to your context of use). A value of -1 means that no person is detected.

This value is written to a MongoDB collection evey frame (given by OpenCV).

This project also contains code with a simple Flask app to make requests to obtain the value

Installation

  1. Pull the code
  2. Create a python environment (e.g. Virtualenv), activate it and install de requirements

e.g.

virtualenv -p python3 .venv

source .venv/bin/activate

pip install -r requirements.txt

  1. Install MongoDB on your machine and run it as a service (e.g. through Homebrew on macOS)

e.g. With Homebrew

brew services start [email protected]

  1. Check that everything works by executing the mongo command

  2. Since the code in this project works with specific collections, either create them or modify the code (and create them as well)

e.g. Inside the mongo environment, execute

use ssexpo

db.data

db.data.insertOne({"description":"User proximity value", "value":100000})

db.data.find()

These commands create the DB, the collection, inserts the document we'll be working and retrieves all documents in the collection

  1. Everything ready!!

Runnig the code

In this project, there are two separated parts, the person-detection part and the Flask part, so the steps I follow to 'run' the application are the following:

  1. Make sure MongoDB is running as a service (e.g. brew services list to check)
  2. Launch the flask server (this will also launch the recognition process/window)

python flask_server.py

If everything works, navigating to http://127.0.0.1:5000/closest_person on a browser should give you a numeric value (the value stored in MongoDB)

Note for Windows users: Take into account that it might be neccessary to change the Python executable in flask_server.py to the one used in the virtual environment (e.g. .venv\Scripts\python)

3. Launch the person detection script

python detect_and_write_to_mongo.py --prototxt MobileNetSSD_deploy.prototxt.txt --model MobileNetSSD_deploy.caffemodel

A small window should open, showing the input from your webcam

  1. To validate that everything works, you can either refresh the web browser or perform commands through the mongo terminal

Demo

This gif shows an example, retrieving the value from Unity

Unity demo

Other scripts in the project

  • mongo_test.py: A simple test I did to learn MongoEngine
  • real_time_object_detection.py: If you run it, the model will detect all the object it's been trained for (saves nothing to MongoDB)
  • real_time_people_detection.py: Only detects people (saves nothing to MongoDB)
  • real_time_closest_person_detection.py: Filters to get the closest person (saves nothing to MongoDB)

References

realtime-closest-person-detection-mongodb's People

Contributors

juanizquierdodomenech avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.