GithubHelp home page GithubHelp logo

mercurialjd / concentration-detection Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 2.0 73.85 MB

This repo takes advantages of OpenCV and TensorFlow to achieve the goal of concentration analysis (camera/video part).

License: MIT License

Python 100.00%

concentration-detection's Introduction

Concentration Analysis (Camera/Video Part)

This repo takes advantages of OpenCV and TensorFlow to achieve the goal of concentration analysis (camera/video part).

If you prefer Chinese README, please refer to this file.

demo

Note: The original video before being processed is referred from the Internet

Tested Prerequisites

  • opencv-python 4.2.0.32
  • tensorflow 1.14.0
  • Python 3.6.9
  • Codes from this repo has been tested on Ubuntu 18.04

Installation

git clone https://github.com/MercurialJD/Concentration-Detection.git

User's Guidance

This project accepts video files or real-time camera records. In the case no argument is provided or the given argument points to a camera, the corresponding camera will be automatically invoked; If a video file is given as an argument, the video will be analyzed.

Video Mode

For video formats that can be identified by OpenCV:

python3 concentration_estimation.py --video /path/to/your/video.mp4

Camera Mode

Default camera:

python3 concentration_estimation.py

Explicitly designated camera:

python3 concentration_estimation.py --cam 0

Output Adjustments

Please adjust concentration_estimation.py w.r.t. your requirements.

  • If the processed video is needed, please uncomment following lines:

    # fourcc = cv2.VideoWriter_fourcc(*'mp4v')
    # out = cv2.VideoWriter('output.mp4', fourcc, 20.0, (width, height))
    ...
    # cv2.putText(frame, "FACING", (height//50, width//50), cv2.FONT_HERSHEY_DUPLEX, 1, (0, 0, 0), 1)
    ...
    # cv2.putText(frame, "UNFACED", (height//50, width//50), cv2.FONT_HERSHEY_DUPLEX, 1, (0, 0, 0), 1)
    ...
    # out.write(frame)
    ...
    # out.release()
    
  • If real-tile preview is needed, please uncomment the following line:

    # cv2.imshow("Preview", frame)
    
  • If the facial identification box need to be customized, please modify:

    pose_estimator.draw_annotation_box(...)
    
  • If head-pose axes need to be customized, please modify:

    pose_estimator.draw_axis(...)
    

Basic Procedure

  1. Facial recognition with DNN module provided by OpenCV
  2. Facial landmarks with 68-point estimation provided by TensorFlow
  3. Pose estimation with PnP algorithm
  4. Stabilization with Kalman filter
  5. Concentration analysis

License

Please refer to LICENSE.md.

Acknowledgements

concentration-detection's People

Contributors

mercurialjd avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

concentration-detection's Issues

运行时报错,请教如何处理

运行时报错,请问下如何解决,能否提供一下requirements.txt,谢谢。
Traceback (most recent call last):
File "concentration_estimation.py", line 178, in
main()
File "concentration_estimation.py", line 65, in main
box_process.start()
File "C:\Users\xxx.conda\envs\tensorflow-gpu\lib\multiprocessing\process.py", line 105, in start
self._popen = self._Popen(self)
File "C:\Users\xxx.conda\envs\tensorflow-gpu\lib\multiprocessing\context.py", line 223, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "C:\Users\xxx.conda\envs\tensorflow-gpu\lib\multiprocessing\context.py", line 322, in _Popen
return Popen(process_obj)
File "C:\Users\xxx.conda\envs\tensorflow-gpu\lib\multiprocessing\popen_spawn_win32.py", line 65, in init
reduction.dump(process_obj, to_child)
File "C:\Users\xxx.conda\envs\tensorflow-gpu\lib\multiprocessing\reduction.py", line 60, in dump
ForkingPickler(file, protocol).dump(obj)
TypeError: can't pickle cv2.dnn_Net objects

Traceback (most recent call last):
File "", line 1, in
File "C:\Users\xxx.conda\envs\tensorflow-gpu\lib\multiprocessing\spawn.py", line 105, in spawn_main
exitcode = _main(fd)
File "C:\Users\xxx.conda\envs\tensorflow-gpu\lib\multiprocessing\spawn.py", line 115, in _main
self = reduction.pickle.load(from_parent)
EOFError: Ran out of input

what's the version

I want to run this project in my own computer, and what's the version of the OpenCV and TensorFlow in this project?

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.