Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@vapi/node-yolo

rcaceiro50MIT2.1.5

Node.js interface for Yolo/Darknet

yolo, darknet, recognition, artificial, inteligence, AI, object, detection, classification

readme

node-yolo

This Node.js C++ addon allow you to use a state-of-the-art, real-time object detection system called Yolo.
This addon came out from a computer engineering final project, VAPi, guided by Patrício Domingues at Institute Polytechnic of Leiria.
The version 1.x.x was developed by Rúben Caceiro and Ricardo Maltez during the final project.
The version 2.x.x was sponsored by Instituto de Telecomunicações developed by Rúben Caceiro and guided by Patrício Domingues.

Pre-requirements

  • C/C++ Compiler (tested with gcc & g++)
  • nVidia graphic card (Only if you want to use GPU acceleration):
  • Node.js (tested on node.js>= 8)
  • node-gyp
  • OpenCV

Note 1: Before any update please see the changelog.
Note 2: The versions prior 2.0.0 of the module has the ImageMagick as a dependency, but with OpenCV we can archive the desired goal. And by this we remove one dependency of the project.

  • Quad-core processor**
  • 10 GB to run node-yolo
  • At least 4GB of GPU memory***, if you want use GPU acceleration

    Minimum* hardware requirements

  • Dual-core processor**
  • 8 GB to run node-yolo
  • At least 4GB of GPU memory***, if you want use GPU acceleration

    Installation

    npm i @vapi/node-yolo --save

How To Use

const Yolo = require('@vapi/node-yolo');
const detector = new Yolo("darknet_configs", "cfg/coco.data", "cfg/yolov3.cfg", "yolov3.weights");
detector.detectImage(path,threshold,frames_to_process)
        .then(detections =>
        {
         // here you receive the detections
        })
        .catch(error =>
        {
         // here you can handle the errors. Ex: Out of memory
        });

detector.detectVideo(path,threshold,frames_to_process)
        .then(detections =>
        {
         // here you receive the detections
        })
        .catch(error =>
        {
         // here you can handle the errors. Ex: Out of memory
        });

path, required, represents the path to the file

threshold, not required, default behaviour is 0.5, represents the threshold to yolo filter the detections

frames_to_process, not required, default behaviour is 1/1, represents the number of frames that developer wants to process, this means 1/3 process 1 frame for each 3.

darknet_configs is a folder where you should put the Yolo weights, cfg and data files. You need to create two folder, cfg and data and put the files for each one. Like this:

.
├── darknet_configs         # The folder for the Yolo weight, cfg and data files
│   ├── cfg                 # cfg folder
|          |── coco.data
|          |── yolov3.cfg
│   ├── data                # data folder
|   |      |── coco.names
│   └── yolov3.weights      # YoloV3 weights file
└── ...

Note 1: Our suggestion for better accuracy use coco.data, coco.names, yolov3-spp.cfg and yolov3-spp.weights.
Note 2: Our suggestion for faster detection use coco.data, coco.names, yolov3-tiny.cfg and yolov3-tiny.weights.
Note 3: Our suggestion for best of two worlds use coco.data, coco.names, yolov3.cfg and yolov3.weights.

video detection object

Field Type Description
frame long/int64 number of the frame
millisecond double the millisecond that frame appear on video
timeSpentForClassification double time used to classifies one frame
detections array array of detection object, containing all detections

image detection object

Field Type Description
timeSpentForClassification double time used to classifies one image
detections array array of detection object, containing all detections

detection object

Field Type Description
className string name of the class of the object detected
probability double the probability that this className is correct
box box object that contains box info of the object

box object

Field Type Description
x double x coordinate in pixels of the picture
y double y coordinate in pixels of the picture
w double width from x point in pixels
h double height from y point in pixels

* To get that metrics we calculate the usage for video with 3 hours at 60fps.
*If you do not use gpu, may should consider a processor with higher number of cores.
**
The weaker graphics card used was a nVidia GTX960M

changelog

Changelog

Note: In this project the version semantic will be x.y.z, when:

  • z represent, backwards compatible bug fixes are introduced
  • y represent, new backwards compatible functionality are introduced
  • x represent, any backwards incompatible changes are introduced, and/or a big bundle of bug fixes and new functionalities are introduced.

v2.1.2 (24-12-2018)

Full Changelog

Fixed bugs:

  • Fix a bug then make with sudo, the which not run on sudo.

v2.1.1 (24-12-2018)

Full Changelog

Fixed bugs:

  • Removed some extra code that allow gather timings.

v2.1.0 (23-12-2018)

Full Changelog

New Features:

  • node-yolo now can process only x number of frames. 1/3 means process 1 frames for each 3, the default behaviour is process every frame.
  • node-yolo now allow the developer can specify the threshold, the default behavior is 0.5.

Implemented enhancements:

  • now on reject the node-yolo no longer kill nodeJS.

v2.0.1 (23-12-2018)

Full Changelog

Fixed bugs:

  • Small fix then yolo_status_decode is called, it wasn't linked on libyolo

Closed issues: Detect only first object from same class #4

v2.0.0 (15-11-2018)

Full Changelog

New Features:

  • node-yolo classify videos, but for now only video files, not a camera stream.
  • added to results of classification the time that took to be classified.

Implemented enhancements:

  • Creation of a changelog
  • Added a capability on Makefile to detect OpenMP, only on Linux, if macOs users has it installed has to change manually the parameter OPENMP in Makefile.
  • Added constraints on CPU and OS to install this module in package.json

Fixed bugs:

  • Fix on Makefile to include more new object files, needed

Backwards Incompatibility:

  • The versions prior 2.0.0 of the module has the ImageMagick as a dependency, but with OpenCV we can archive the desired goal. And by this we remove one dependency of the project.

Closed issues:

  • Getting Empty Array In Detections Instead Of Object #1
  • Built with GPU stuff enabled but using CPU #3