{"id":22170047,"url":"https://github.com/wdv4758h/danboard","last_synced_at":"2026-05-11T07:08:21.422Z","repository":{"id":34138713,"uuid":"37973322","full_name":"wdv4758h/Danboard","owner":"wdv4758h","description":"Danboard is watching you \u003ew\u003c (A project using OpenCV for realtime face detection and using WiringPi to control the motors, running on Raspberry Pi)","archived":false,"fork":false,"pushed_at":"2015-06-29T20:48:51.000Z","size":4588,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-29T22:19:05.366Z","etag":null,"topics":["cpp","opencv","raspberry-pi"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wdv4758h.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-24T08:50:35.000Z","updated_at":"2017-06-01T10:17:35.000Z","dependencies_parsed_at":"2022-08-18T00:35:50.060Z","dependency_job_id":null,"html_url":"https://github.com/wdv4758h/Danboard","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wdv4758h%2FDanboard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wdv4758h%2FDanboard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wdv4758h%2FDanboard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wdv4758h%2FDanboard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wdv4758h","download_url":"https://codeload.github.com/wdv4758h/Danboard/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245316663,"owners_count":20595478,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","opencv","raspberry-pi"],"created_at":"2024-12-02T06:38:19.144Z","updated_at":"2026-05-11T07:08:21.390Z","avatar_url":"https://github.com/wdv4758h.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"========================================\nDanboard\n========================================\n\nWhat's Danboard ?\n========================================\n\n.. image:: img/danboard.jpg\n    :alt: Danboard\n\n`image source \u003chttps://www.flickr.com/photos/meaganmakes/14189116565/\u003e`_\n\nlicense of above image\n\n.. image:: img/cc-by-nc.png\n    :alt: CC BY-NC\n\n\n\nWhat's this project doing ?\n========================================\n\n**make Danbo keep watching you :P**\n\nwe use Raspberry Pi 2 + Raspberry Pi Camera Module + ULN2003 + Stepper Motor\n\nuse camera to get image of current scene, then detect the faces, control stepper to turn Danbo's face\n\n\nTesting Environment\n========================================\n\n+----------+-------------------------+\n| Hardware | Raspberry Pi 2 (mode B) |\n+----------+-------------------------+\n| OS       | Arch Linux ARM          |\n+----------+-------------------------+\n\n\nDependency\n========================================\n\n* OpenCV 2.4\n* WiringPi\n* C++ Compiler which support C++14\n\n\n3D Printing Structure Inside The Body\n========================================\n\nHead :\n\n.. image:: img/danboard-head-v2.2.png\n    :alt: Head\n\nNeck :\n\n.. image:: img/danboard-neck-v2.png\n    :alt: Neck\n\nBody :\n\n.. image:: img/danboard-body-v1.png\n    :alt: Body\n\n\nSTL files are in the ``stl`` folder.\n\n\nAPI\n==================================================\n\nstepper\n------------------------------\n\n``stepper`` class is in the ``src/stepper.h``, it can control your stepper by giving data to ULN2003.\n\nIt talks to GPIO by WiringPi library.\n\nPlease pass in the pin number (in WiringPi) to construct the class instance : ``stepper(PIN1, PIN2, PIN3, PIN4)``\n\n\nmember function\n++++++++++++++++++++\n\n* turn : turn the stepper\n* rturn : turn the stepper (reverse)\n* async_turn : asynchronously turn the stepper, it will return a future object, you can call ``.get()`` to wait for the result\n* async_rturn : asynchronously turn the stepper (reverse), it will return a future object, you can call ``.get()`` to wait for the result\n\n\ndetector\n------------------------------\n\nPlease pass in the model name to construct the class instance : ``detector(\"haarcascade_frontalface_alt.xml\")``\n\nIt will open the camera just like what OpenCV does in ``VideoCapture``.\n\n\nmember function\n++++++++++++++++++++\n\n* detect : return a vector of detected rectangle (feature)\n\n\nAlgorithm - Viola–Jones object detection framework\n==================================================\n\n**Viola–Jones object detection framework** is a **real-time** object detection framework proposed in 2001 by Paul Viola and Michael Jones.\n\nThere are 4 primary steps :\n\n* Haar Features Selection\n* Creating Integral Image\n* Adaboost Training algorithm\n* Cascaded Classifiers\n\nHaar Features Selection\n------------------------------\n\n**Haar features** consider adjacent rectangular regions at a specific location in a detection window,\nsums up the pixel intensities in each region and calculates the difference between these sums.\n\nThe advantage of using Haar features is the **fast calculation speed**.\n\nA Haar feature is a rectangular region in the integral image,\nso you will need to know the position of the starting and ending point.\n\nlike this : ::\n\n    +-----------------+         +-----------------+\n    |                 |         |       +-------+ |\n    |  +---+---+      |         |       |///////| |\n    |  |...|///|      |         |       +-------+ |\n    |  |...|///|      |         |       |.......| |\n    |  |...|///|      |         |       +-------+ |\n    |  |...|///|      |         |      B          |\n    |  +---+---+      |         |                 |\n    |           A     |         |                 |\n    +-----------------+         +-----------------+\n\n\n\n    +-----------------+         +-----------------+\n    |                 |         |      +---+---+  |\n    |                 |         |      |///|...|  |\n    |                 |         |      |///|...|  |\n    | C               |         |      +---+---+  |\n    |  +---+---+---+  |         |      |...|///|  |\n    |  |...|///|...|  |         |      |...|///|  |\n    |  |...|///|...|  |         |      +---+---+  |\n    |  +---+---+---+  |         |     D           |\n    +-----------------+         +-----------------+\n\n* for A we need to know **6** points' integral value\n* for B we need to know **6** points' integral value\n* for C we need to know **8** points' integral value\n* for D we need to know **9** points' integral value\n\nBy this method, we can get **characteristic difference values** (specific regions' value) by simple calculation.\n\nWe can use these kind of features to indicate what does the object looks like.\n\nFor example, we can calculate ``the sum of \".\" area`` minus ``the sum of \"/\" area``,\nthen we will get a single value.\nNow we can compare the single value with the threshold.\nIf it pass the threshold, we vote it (we guess that's what we want).\n\nEach subframe is 24x24 pixels, so possible features are 162336.\n\nHere is a example for calculate features (example subframe is 4x4) :\n\n::\n\n    features type : 2x1, 1x2, 3x1, 1x3, 2x2\n\n    2x1 shapes:\n            size: 2x1 =\u003e count: 12\n            size: 2x2 =\u003e count: 9\n            size: 2x3 =\u003e count: 6\n            size: 2x4 =\u003e count: 3\n            size: 4x1 =\u003e count: 4\n            size: 4x2 =\u003e count: 3\n            size: 4x3 =\u003e count: 2\n            size: 4x4 =\u003e count: 1\n    1x2 shapes:\n            size: 1x2 =\u003e count: 12             +-----------------------+\n            size: 1x4 =\u003e count: 4              |     |     |     |     |\n            size: 2x2 =\u003e count: 9              |     |     |     |     |\n            size: 2x4 =\u003e count: 3              +-----+-----+-----+-----+\n            size: 3x2 =\u003e count: 6              |     |     |     |     |\n            size: 3x4 =\u003e count: 2              |     |     |     |     |\n            size: 4x2 =\u003e count: 3              +-----+-----+-----+-----+\n            size: 4x4 =\u003e count: 1              |     |     |     |     |\n    3x1 shapes:                                |     |     |     |     |\n            size: 3x1 =\u003e count: 8              +-----+-----+-----+-----+\n            size: 3x2 =\u003e count: 6              |     |     |     |     |\n            size: 3x3 =\u003e count: 4              |     |     |     |     |\n            size: 3x4 =\u003e count: 2              +-----------------------+\n    1x3 shapes:\n            size: 1x3 =\u003e count: 8                  Total Count = 136\n            size: 2x3 =\u003e count: 6\n            size: 3x3 =\u003e count: 4\n            size: 4x3 =\u003e count: 2\n    2x2 shapes:\n            size: 2x2 =\u003e count: 9\n            size: 2x4 =\u003e count: 3\n            size: 4x2 =\u003e count: 3\n            size: 4x4 =\u003e count: 1\n\n\nCreating Integral Image\n------------------------------\n\nIn **integral image**,\neach pixel is the sum of all pixels in the original image which are left and above.\n\nlike this : ::\n\n    Original        Integral\n\n    1, 2, 3         0,  0,  0,  0\n    4, 5, 6         0,  1,  3,  6\n    7, 8, 9         0,  5, 12, 21\n                    0, 12, 27, 45\n\ncalculation : ::\n\n    Original        Integral\n\n    1, 2, 3         0,  0,  0,  0\n    4, 5, 6         0,   ,   ,\n    7, 8, 9         0,   ,   ,\n                    0,   ,   ,\n\n\n\n    Original        Integral\n\n    ( 1 ), 2, 3         0, ( 0 ),  0,  0\n        4, 5, 6     ( 0 ), [ 1 ],   ,\n        7, 8, 9         0,      ,   ,\n                        0,      ,   ,\n\n            calculation : 0 + 0 + 1 = 1\n\n\n\n    Original        Integral\n\n    1, ( 2 ), 3     0,   0  , ( 0 ),  0\n    4,     5, 6     0, ( 1 ), [ 3 ],\n    7,     8, 9     0,      ,      ,\n                    0,      ,      ,\n\n            calculation : 0 + 1 + 2 = 3\n\n\n\n    Original        Integral\n\n    1, 2, ( 3 )     0, 0,     0, ( 0 )\n    4, 5,     6     0, 1, ( 3 ), [ 6 ]\n    7, 8,     9     0,  ,      ,\n                    0,  ,      ,\n\n            calculation : 0 + 3 + 3 = 6\n\n\n\n    Original        Integral\n\n        1, 2, 3         0,     0, 0, 0\n    ( 4 ), 5, 6         0, ( 1 ), 3, 6\n        7, 8, 9     ( 0 ), [ 5 ], ,\n                        0,      , ,\n\n            calculation : 1 + 0 + 4 = 5\n\n\n    ...\n\n\n    Original        Integral\n\n    1, 2, 3         0,  0,  0,  0\n    4, 5, 6         0,  1,  3,  6\n    7, 8, 9         0,  5, 12, 21\n                    0, 12, 27, 45\n\n\nAdaboost Training algorithm\n------------------------------\n\n**AdaBoost** was introduced in 1995 by Freund and Schapire, it's a machine learning algorithm which can collaborate with many other types of learning algorithms to improve their performance.\n\nThe concept is to combine some **weak classifier** into a weighted sum to make a **strong classifier**.\n\nAdaBoost use weighted majority vote (or sum) to produce the final prediction.\n\n\nAssume we have N training images (positive and negative),\nwe lable them with 1 or -1 (1, if the image is what we want, otherwise -1).\n\nWe iterate through the features (16K) to find out best N Haar features,\nthen we start training with these N features.\nWe give a weighting variable to every features (N features) to tune the result.\nNow we start voting. By changing the weighting variable, we can minimize the error of the voting result.\n\nFinally, we get a better result. Now we can output the model to an xml for using next time.\n\n\nCascaded Classifiers\n------------------------------\n\n* 1st layer, A simple **2-feature classifier** can achieve **almost 100% detection rate** with **50% false positive rate**.\n    - if it's what we want, it will pass (almost 100% detection rate)\n    - if it's not what we want, it will have 50% probability to pass\n    - this can fast filter the data\n* 2nd layer, 10 features, less false positive rate P%\n    - if it's what we want, it will pass (almost 100% detection rate)\n    - if it's not what we want, it will have P% probability to pass\n    - now the overall false positive rate is (50% * P%)\n* 3rd layer, X features, less false positive rate Q%\n    - if it's what we want, it will pass (almost 100% detection rate)\n    - if it's not what we want, it will have Q% probability to pass\n    - now the overall false positive rate is (50% * P% * Q%)\n\n\n::\n\n    +-----------+       +---------+       +---------+       +---------+           +---------+       +------+\n    |           |       |         |       |         |       |         |           |         |       |      |\n    | sub image | ----\u003e | stage 1 | ----\u003e | stage 2 | ----\u003e | stage 3 | ... ----\u003e | stage n | ---\u003e  | Pass |\n    |           |       |         |       |         |       |         |           |         |       |      |\n    +-----------+       +---------+       +---------+       +---------+           +---------+       +------+\n                            |                  |                 |                     |\n                            |                  |                 |                     |\n                            v                  v                 v                     v\n            +----------------------------------------------------------------------------------+\n            |                                                                                  |\n            |                                      Reject                                      |\n            |                                                                                  |\n            +----------------------------------------------------------------------------------+\n\n\n\n\n\nLicense of this project\n========================================\n\n`GPL v3 \u003cLICENSE\u003e`_\n\n\n\nReference\n========================================\n\n* `Wikipedia - Viola–Jones object detection framework \u003chttps://en.wikipedia.org/wiki/Viola%E2%80%93Jones_object_detection_framework\u003e`_\n* `Wikipedia - Haar-like features \u003chttps://en.wikipedia.org/wiki/Haar-like_features\u003e`_\n* `Wikipedia - AdaBoost \u003chttps://en.wikipedia.org/wiki/AdaBoost\u003e`_\n* `scikit-learn - AdaBoost \u003chttp://scikit-learn.org/stable/modules/ensemble.html#adaboost\u003e`_\n* `Robust Real-time Object Detection \u003chttp://lear.inrialpes.fr/people/triggs/student/vj/viola-ijcv04.pdf\u003e`_\n* `StackOverflow - Viola-Jones' face detection claims 180k features \u003chttp://stackoverflow.com/questions/1707620/viola-jones-face-detection-claims-180k-features\u003e`_\n* `OpenCV Face Detection: Visualized \u003chttps://vimeo.com/12774628\u003e`_\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwdv4758h%2Fdanboard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwdv4758h%2Fdanboard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwdv4758h%2Fdanboard/lists"}