### Install phpMyAdmin on Raspberry Pi Source: https://github.com/watershedarts/footfall/blob/master/docs/server.md Command to install phpMyAdmin, a web-based database management tool for MySQL. This command installs the necessary packages and prompts for configuration. ```bash sudo apt-get install phpmyadmin ``` -------------------------------- ### Run getrepos.sh Script Source: https://github.com/watershedarts/footfall/blob/master/docs/rpi.md This command executes the 'getrepos.sh' script, which is responsible for downloading and installing the necessary packages and addons for the Footfall project on the Raspberry Pi. ```shell ./getrepos.sh ``` -------------------------------- ### Install MySQL on Raspberry Pi Source: https://github.com/watershedarts/footfall/blob/master/docs/server.md Command to install the MySQL server and the PHP MySQL extension. MySQL is a popular open-source relational database management system. ```bash sudo apt-get install mysql-server php5-mysql -y ``` -------------------------------- ### Update and Upgrade Raspberry Pi System Source: https://github.com/watershedarts/footfall/blob/master/docs/rpi.md This sequence of commands updates the package list, upgrades installed packages to their latest versions, and applies any pending Raspberry Pi firmware updates. This ensures the system is up-to-date before proceeding with application setup. ```shell sudo apt-get update sudo apt-get upgrade sudo apt-raspi-update ``` -------------------------------- ### Install Apache on Raspberry Pi Source: https://github.com/watershedarts/footfall/blob/master/docs/server.md Commands to update the Raspberry Pi's package list and install the Apache web server. Apache is a widely used open-source web server software that serves web pages. ```bash sudo apt-get update sudo apt-get upgrade ``` ```bash sudo apt-get install apache2 -y ``` -------------------------------- ### Create and Edit getrepos.sh Script Source: https://github.com/watershedarts/footfall/blob/master/docs/rpi.md This snippet demonstrates how to create a new file named 'getrepos.sh' in the '~/openFrameworks/addons' directory and then open it using the vim editor to paste content. This script is used to fetch required packages for the Footfall project. ```shell cd ~/openFrameworks/addons touch getrepos.sh && vim getrepos.sh ``` -------------------------------- ### Test Raspberry Pi Camera Source: https://github.com/watershedarts/footfall/blob/master/docs/rpi.md This command tests the Raspberry Pi camera by capturing an image and saving it as 'testimage.jpg'. This is a verification step to ensure the camera is functioning correctly after setup. ```shell raspistill -o testimage.jpg ``` -------------------------------- ### Install PHP on Raspberry Pi Source: https://github.com/watershedarts/footfall/blob/master/docs/server.md Commands to install PHP version 5 and the Apache module for PHP 5 on a Raspberry Pi. PHP is a server-side scripting language used for web development. ```bash sudo apt-get install php5 libapache2-mod-php5 -y ``` -------------------------------- ### Configure Apache for phpMyAdmin Source: https://github.com/watershedarts/footfall/blob/master/docs/server.md Steps to add phpMyAdmin's Apache configuration to the main Apache configuration file and restart the Apache server. This makes phpMyAdmin accessible via the web browser. ```bash sudo nano /etc/apache2/apache2.conf ``` ```bash Include /etc/phpmyadmin/apache.conf ``` ```bash /etc/init.d/apache2 restart ``` -------------------------------- ### Simple Compilation of Footfall Project Source: https://github.com/watershedarts/footfall/blob/master/docs/compiling.md This snippet outlines the steps for directly compiling the Footfall project using 'make'. It assumes openFrameworks is already set up. The process involves cloning the repository, navigating to the project directory, and executing the make command. Finally, it shows how to run the compiled application. ```bash cd openFrameworks/apps/ git clone https://github.com/WatershedArts/Footfall.git cd Footfall/Footfall/ make -j3 DISPLAY=:0 make RunRelease # or DISPLAY=:0 bin/Footfall ``` -------------------------------- ### Configure Database Connection Source: https://github.com/watershedarts/footfall/blob/master/docs/server.md Edit the `dbconnect.php` file to set the database name and password. This file contains the credentials needed to connect to the MySQL database. ```bash sudo nano includes/dbconnect.php ``` -------------------------------- ### Copy Public Files to Webroot Source: https://github.com/watershedarts/footfall/blob/master/docs/server.md Command to copy the contents of the 'public' folder from the GitHub repository to the Raspberry Pi's webroot directory. This makes the web application files accessible via the server. ```bash cd /var/www/ sudo cp -r /home/pi/Footfall/Web/* . ``` -------------------------------- ### Configure Secret Key Source: https://github.com/watershedarts/footfall/blob/master/docs/server.md Edit the `secret.php` file to set the secret key. This key should match the `secretkey` variable in the `config.json` file and is used for HTTP system operations. ```bash sudo nano includes/secret.php ``` -------------------------------- ### Troubleshooting Compilation Errors by Rebuilding Project Structure Source: https://github.com/watershedarts/footfall/blob/master/docs/compiling.md This method addresses potential compilation errors by creating a new project structure and transferring source files. It involves copying an empty example, modifying the addons.make file to include necessary ofx addons, and then copying the Footfall source files into the new project. This approach can resolve issues related to addon configurations. ```bash cd openFrameworks/apps/myApps/ cp -r emptyExample/ Footfall/ cd Footfall mkdir bin mkdir bin/data pico addons.make # Add the following lines to addons.make: ofxCv ofxCsv ofxOpenCv ofxJSON ofxHttpUtils ofxCvPiCam # Save and exit pico editor (CTRL + x) cd src cp ../../../../Footfall/Footfall/src/* . cd .. make -j3 cp ../../../../Footfall/Footfall/bin/data/config.json ./bin/data/ ``` -------------------------------- ### Create Footfall Database Table Source: https://github.com/watershedarts/footfall/blob/master/docs/server.md SQL statement to create the 'data' table in the MySQL database. This table is used to store event data, including timestamp, location ID, and event type. ```sql CREATE TABLE IF NOT EXISTS `data` ( `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `locationID` tinyint(4) NOT NULL, `event` tinyint(4) NOT NULL, KEY `timestamp` (`timestamp`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; ``` -------------------------------- ### Footfall Application Start Script Source: https://context7.com/watershedarts/footfall/llms.txt A shell script named 'startFootfall.sh' designed to launch the Footfall application. It includes a loop to automatically restart the application if it crashes. ```bash #!/bin/sh cd ~/openFrameworks/apps/myApps/Footfall/bin/ ret=1 while [ $ret -ne 0 ]; do ./Footfall ret=$? done ``` -------------------------------- ### Start Footfall Application Script Source: https://github.com/watershedarts/footfall/blob/master/docs/running.md A shell script to start the Footfall application. It continuously attempts to run the application until it exits successfully. It changes the directory to the application's bin folder before execution. ```sh #!/bin/sh cd ~/openFrameworks/apps/myApps/Footfall/bin/ ret=1 while [ $ret -ne 0 ]; do ./Footfall ret=$? done ``` -------------------------------- ### Run Footfall Application Manually Source: https://context7.com/watershedarts/footfall/llms.txt Shell commands to manually start the Footfall application on a Raspberry Pi. It includes options to run the application in the background and detach it from the terminal. ```bash # Run in background and detach from terminal DISPLAY=:0 make run & disown # Or run the compiled binary directly DISPLAY=:0 bin/Footfall & disown ``` -------------------------------- ### Resolving ofxCvPiCam Compilation Issues Source: https://github.com/watershedarts/footfall/blob/master/docs/compiling.md This snippet provides a solution for specific compilation errors related to the ofxCvPiCam addon. It involves navigating into the addon's directory and moving the 'libs' folder to a backup location ('old-libs'). This prevents the compiler from attempting to use the addon's internal libraries, which can sometimes cause conflicts. ```bash cd "Path/To/openFrameworks/addons/ofxCvPiCam/" mv libs/ old-libs/ ``` -------------------------------- ### Remove and Reinstall ofxCv for openFrameworks Compatibility Source: https://github.com/watershedarts/footfall/blob/master/docs/troubleshooting.md This process involves removing an existing ofxCv installation and cloning a fresh copy, checking out a specific branch to ensure compatibility with different openFrameworks versions. It's crucial for resolving issues with later versions of openFrameworks. ```bash cd ~/openFrameworks/addons sudo rm -r ofxCv git clone https://github.com/kylemcdonald/ofxCv.git ``` -------------------------------- ### Schedule Footfall Application with Cron Source: https://context7.com/watershedarts/footfall/llms.txt Configuration for cron jobs to automate the start and stop of the Footfall application, as well as scheduled reboots. Uses standard cron syntax for scheduling tasks. ```bash # Edit crontab crontab -e # Add these entries: 00 07 * * * /home/pi/startFootfall.sh 59 23 * * * /home/pi/stopFootfall.sh 00 03 * * * /sbin/reboot ``` -------------------------------- ### Clone openFrameworks Stable Branch to Fix GLM Errors Source: https://github.com/watershedarts/footfall/blob/master/docs/troubleshooting.md This command clones the stable branch of openFrameworks, which resolves GLM errors often encountered with older versions. It's recommended to remove existing openFrameworks installations before cloning this branch. ```bash git clone -b stable --single-branch https://github.com/openframeworks/openFrameworks.git ``` -------------------------------- ### Retrieve Footfall Data API Endpoint Source: https://context7.com/watershedarts/footfall/llms.txt Demonstrates how to use curl to GET aggregated footfall data from the API. Supports different time intervals for data grouping. The response is a JSON array of time-based statistics. ```bash # Get today's data in 15-minute intervals curl "http://localhost/footfall/upload.php?get=1&interval=900" # Get today's data in 1-hour intervals curl "http://localhost/footfall/upload.php?get=1&interval=3600" # Response format: # [ # { # "timekey": "2025-10-23 09:00:00", # "movement": 5, # "peoplein": 8, # "peopleout": 3, # "total": 5, # "totalin": 8 # }, # { # "timekey": "2025-10-23 09:15:00", # "movement": -2, # "peoplein": 3, # "peopleout": 5, # "total": 3, # "totalin": 11 # } # ] ``` -------------------------------- ### C++ TrackingManager Class for Blob Detection and Tracking Source: https://context7.com/watershedarts/footfall/llms.txt The TrackingManager class in C++ uses OpenCV's contour finding to detect and track people in camera frames. It manages the setup, update, drawing, and closing of the tracking process, and emits events for blobs entering and exiting designated areas. Key dependencies include ofxCv and custom tracking history structures. ```cpp // TrackingManager.h class TrackingManager { public: void setup(Tracking_Configuration _trackingConfig); void update(Mat processedMat); void draw(); void close(); ofEvent blobIn; ofEvent blobOut; private: ofxCv::ContourFinder contourFinder; ofxCv::RectTrackerFollower tracker; ofRectangle centerRect; TrackingHistory trackingHistory; int _oneBlob; // Minimum size for one person int _twoBlob; // Minimum size for two people int _threeBlob; // Minimum size for three people }; ``` -------------------------------- ### Create and Set Permissions for Scripts Source: https://github.com/watershedarts/footfall/blob/master/docs/running.md Commands to create the `startFootfall.sh` and `stopFootfall.sh` files and set execute permissions for them. ```bash touch startFootfall.sh stopFootfall.sh chmod 755 startFootfall.sh stopFootfall.sh ``` -------------------------------- ### Record Test Video (Bash) Source: https://context7.com/watershedarts/footfall/llms.txt Commands to capture test video footage using `raspivid` and convert it to MP4 format using `ffmpeg` for easier playback and analysis on desktop systems. Essential for tuning camera and tracking parameters. ```bash # Record 60 second test video at 320x240, 25fps raspivid -w 320 -h 240 -fps 25 -t 60000 -o testRecording.h264 # Convert to MP4 for desktop testing ffmpeg -i testRecording.h264 -c copy output.mp4 ``` -------------------------------- ### Configure Footfall System Settings (JSON) Source: https://context7.com/watershedarts/footfall/llms.txt The primary configuration file for the Footfall system. It defines parameters for application behavior, camera input, tracking algorithms, and HTTP network communication. Adjust these settings to optimize performance and tailor the system to specific environments. ```json { "Footfall": { "AppConfig": { "usehttp": true, "usecsvlogging": false }, "CameraConfig": { "camerawidth": 160, "cameraheight": 120, "fliphorizontally": false, "flipvertically": false, "trackshadows": true, "threshold": 200, "mogthreshold": 16, "shadowpixelratio": 0.25, "dilate": 5, "erode": 3, "history": 100, "blur": 5, "usemask": true, "showshadowimage": true, "MaskArea": [ {"coordx": 0, "coordy": 0}, {"coordx": 160, "coordy": 0}, {"coordx": 160, "coordy": 120}, {"coordx": 0, "coordy": 120} ] }, "TrackingConfig": { "threshold": 10, "minarea": 10, "maxarea": 90, "flipvertically": false, "startposx": 0, "startposy": 60, "offset": 20, "blobdyingtime": 0.50, "persistance": 1, "maxdistance": 100, "minsizeone": 10, "minsizetwo": 50, "minsizethree": 100 }, "HttpConfig": { "keepbackups": true, "postserver": "http://192.168.1.100", "postextension": "footfall/upload.php", "secretkey": "your_secret_key_here", "maxretries": 1 } } } ``` -------------------------------- ### Resolve ofxCvPiCam Compiler Errors on RPi2 Source: https://github.com/watershedarts/footfall/blob/master/docs/troubleshooting.md This snippet addresses compiler errors with the ofxCvPiCam library on RPi2 by renaming the 'libs' folder to bypass MMAL library changes. This is a quick workaround for updated MMAL libraries. ```bash cd ~/openFrameworks/addons/ofxCvPiCam/ mv libs old-libs ``` -------------------------------- ### Automate Footfall App with Crontab Source: https://github.com/watershedarts/footfall/blob/master/docs/running.md Crontab entries to schedule the automatic execution of startup and shutdown scripts for the Footfall application, as well as a system reboot. ```crontab 00 07 * * * * /home/pi/startFootfall.sh 59 23 * * * * /home/pi/stopFootfall.sh 00 03 * * * * /sbin/reboot ``` -------------------------------- ### PHP MySQL Database Connection Configuration Source: https://context7.com/watershedarts/footfall/llms.txt A PHP script that establishes a PDO connection to the MySQL database. It configures the database name, password, and host, and includes basic error handling for the connection. ```php getMessage(); exit; } ?> ``` -------------------------------- ### Check Server Health API Endpoint Source: https://context7.com/watershedarts/footfall/llms.txt Shows how to use curl to perform a POST request to the server health check endpoint. Requires a secret key for authentication. Expects a 'Server Connection Good!' response on success. ```bash # Check server status curl -X POST http://localhost/footfall/upload.php \ -d "check=1" \ -d "secret=your_secret_key_here" # Response: "Server Connection Good!" ``` -------------------------------- ### Server Health Check Source: https://context7.com/watershedarts/footfall/llms.txt This POST endpoint allows you to verify server connectivity and authentication. It requires a secret key for access. ```APIDOC ## POST /footfall/upload.php ### Description Verifies server connectivity and authentication. ### Method POST ### Endpoint `/footfall/upload.php` ### Parameters #### Request Body - **check** (int) - Required - Set to 1 to perform the check. - **secret** (string) - Required - Your secret key for authentication. ### Request Example ```bash curl -X POST http://localhost/footfall/upload.php \ -d "check=1" \ -d "secret=your_secret_key_here" ``` ### Response #### Success Response (200) - **Response Body**: "Server Connection Good!" ### Response Example ``` Server Connection Good! ``` ``` -------------------------------- ### Record Video with Raspberry Pi Camera Source: https://github.com/watershedarts/footfall/blob/master/docs/configuration.md This command uses `raspivid` to record a 60-second video with a resolution of 320x240 at 25 frames per second. The output is saved in H.264 format. This is the first step in preparing video input for the Footfall application when using a Raspberry Pi camera. ```bash raspivid -w 320 -h 240 -fps 25 -t 60000 -o testRecording.h264 ``` -------------------------------- ### Post Counting Event API Endpoint Source: https://context7.com/watershedarts/footfall/llms.txt Demonstrates submitting a footfall counting event via a POST request using curl. Requires secret key, location ID, count, and a raw timestamp. The response echoes the submitted data. ```bash curl -X POST http://localhost/footfall/upload.php \ -d "submit=1" \ -d "secret=your_secret_key_here" \ -d "location=1" \ -d "count=3" \ -d "rawtimestamp=2025-10-23 14:30:001729691400" # Response: # Count: 3 # Location: 1 # Raw Timestamp: 2025-10-23 14:30:00 ``` -------------------------------- ### Footfall Web Dashboard HTML Structure Source: https://context7.com/watershedarts/footfall/llms.txt The HTML structure for the Footfall web dashboard. It includes placeholders for displaying footfall metrics, a dropdown for selecting time intervals, and canvas elements for charts. ```html Footfall

Today's Footfall

Total

Visitors Today:

0

Number of People Currently in The Building:

0

Traffic

Traffic In:

0

Traffic Out:

0
``` -------------------------------- ### Post Counting Event via HTTP (C++) Source: https://context7.com/watershedarts/footfall/llms.txt A C++ function using the openFrameworks ofxHttpUtils addon to send people counting data to a remote server. It includes logic to skip invalid zero counts and handle network disconnections by backing up data to a CSV file. ```cpp // HTTPManager.cpp - Posting count data void HTTPManager::post(string count) { _timestamp = ofGetTimestampString("%Y-%m-%d %H:%M:%S"); _count = count; if (networkOk) { if (ofIsStringInString(count, "0") || ofIsStringInString(count, "-0")) { // Skip invalid zero counts } else { ofxHttpForm formIn; formIn.action = _postServer + "/" + _postExtension; formIn.method = OFX_HTTP_POST; formIn.addFormField("secret", _secretKey); formIn.addFormField("location", "1"); formIn.addFormField("count", count); formIn.addFormField("rawtimestamp", _timestamp); formIn.addFormField("submit", "1"); postUtils.addForm(formIn); } } else { if (_keepBackups) { // Network down - save to CSV backup backupLogger.addRecord(_count, _timestamp); } } } ``` -------------------------------- ### Run Footfall App Manually Source: https://github.com/watershedarts/footfall/blob/master/docs/running.md Commands to launch the Footfall application in the background via SSH. The `disown` command detaches the process from the terminal session. ```bash DISPLAY=:0 make run & disown ``` ```bash DISPLAY=:0 bin/Footfall & disown ``` -------------------------------- ### Post Counting Event Source: https://context7.com/watershedarts/footfall/llms.txt Submit a footfall counting event from the Footfall application. This endpoint requires a secret key, location ID, count, and a raw timestamp. ```APIDOC ## POST /footfall/upload.php ### Description Submits a counting event from the Footfall application. ### Method POST ### Endpoint `/footfall/upload.php` ### Parameters #### Request Body - **submit** (int) - Required - Set to 1 to submit an event. - **secret** (string) - Required - Your secret key for authentication. - **location** (int) - Required - The ID of the location where the count occurred. - **count** (int) - Required - The number of people counted. - **rawtimestamp** (string) - Required - The timestamp of the event (format: YYYY-MM-DD HH:MM:SS). ### Request Example ```bash curl -X POST http://localhost/footfall/upload.php \ -d "submit=1" \ -d "secret=your_secret_key_here" \ -d "location=1" \ -d "count=3" \ -d "rawtimestamp=2025-10-23 14:30:001729691400" ``` ### Response #### Success Response (200) - **Response Body**: Details of the submitted count. ### Response Example ``` Count: 3 Location: 1 Raw Timestamp: 2025-10-23 14:30:00 ``` ``` -------------------------------- ### Footfall Application Stop Script Source: https://context7.com/watershedarts/footfall/llms.txt A shell script named 'stopFootfall.sh' used to gracefully terminate the Footfall application. It finds the process ID and sends a kill signal. ```bash #!/bin/sh myarr=$(ps -ef | pgrep 'Footfall') for i in $myarr dob kill -9 $i done ``` -------------------------------- ### Convert H.264 Video to MP4 Source: https://github.com/watershedarts/footfall/blob/master/docs/configuration.md This command uses `ffmpeg` to convert a recorded H.264 video file to an MP4 format. It copies the video stream without re-encoding, ensuring a quick conversion. This step is necessary to make the video compatible with the Footfall application after recording with `raspivid`. ```bash ffmpeg -i testRecording.h264 -c copy output.mp4 ``` -------------------------------- ### PHP Secret Key Authentication Source: https://context7.com/watershedarts/footfall/llms.txt This PHP script verifies the secret key sent in POST requests to secure the API endpoint. It checks if the 'secret' parameter is set and matches the predefined secret key. ```php ``` -------------------------------- ### Ingest Counting Data via PHP (PHP) Source: https://context7.com/watershedarts/footfall/llms.txt A server-side PHP script designed to receive POST requests containing people counting data. It validates the input, inserts the data into a MySQL database, and provides feedback on the operation's success or failure. ```php prepare($sqlq); $q->execute(array( ':rawtimestamp' => (substr($rawtimestamp,0,16)) . ":" . (date("s",(substr($rawtimestamp,17,10)))), ':count' => $count, ':location' => $location )); if (!$q) { echo "Error: can't insert into database. " . $q->errorCode(); exit; } else { echo "Count: " . $count . "
"; echo "Location: " . $location . "
"; echo "Raw Timestamp: " . (substr($rawtimestamp,0,16)) . ":" . (date("s",(substr($rawtimestamp,17,10)))); exit; } } ?> ``` -------------------------------- ### Retrieve Footfall Data Source: https://context7.com/watershedarts/footfall/llms.txt This endpoint returns aggregated footfall data grouped by specified time intervals. You can query data for today in intervals of 15 minutes or 1 hour. ```APIDOC ## GET /footfall/upload.php ### Description Retrieves aggregated footfall data grouped by time intervals for the current day. ### Method GET ### Endpoint `/footfall/upload.php` ### Query Parameters - **get** (int) - Required - Set to 1 to retrieve data. - **interval** (int) - Required - The time interval in seconds (e.g., 900 for 15 minutes, 3600 for 1 hour). ### Response #### Success Response (200) - **timekey** (string) - The timestamp for the interval. - **movement** (int) - The net change in footfall during the interval. - **peoplein** (int) - The number of people entering during the interval. - **peopleout** (int) - The number of people exiting during the interval. - **total** (int) - The cumulative total footfall at the end of the interval. - **totalin** (int) - The cumulative total number of people who entered. ### Response Example ```json [ { "timekey": "2025-10-23 09:00:00", "movement": 5, "peoplein": 8, "peopleout": 3, "total": 5, "totalin": 8 }, { "timekey": "2025-10-23 09:15:00", "movement": -2, "peoplein": 3, "peopleout": 5, "total": 3, "totalin": 11 } ] ``` ``` -------------------------------- ### Stop Footfall Application Script Source: https://github.com/watershedarts/footfall/blob/master/docs/running.md A shell script to forcefully stop the Footfall application by finding its process ID (PID) and killing it. It iterates through all found PIDs and terminates the corresponding processes. ```sh #!/bin/sh myarr=$(ps -ef | pgrep 'Footfall') for i in $myarr do kill -9 $i done ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.