{"id":18217257,"url":"https://github.com/windermere-technology/raspycam","last_synced_at":"2025-04-10T11:51:41.984Z","repository":{"id":259447643,"uuid":"875881609","full_name":"Windermere-Technology/RasPyCam","owner":"Windermere-Technology","description":"Back-End System for the RPi Cam Web Interface","archived":false,"fork":false,"pushed_at":"2025-01-01T16:22:55.000Z","size":181,"stargazers_count":10,"open_issues_count":5,"forks_count":2,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-03-24T10:45:35.235Z","etag":null,"topics":["picamera2","python3","raspberry-pi"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Windermere-Technology.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-21T03:04:05.000Z","updated_at":"2025-03-10T16:35:25.000Z","dependencies_parsed_at":"2024-10-25T14:22:08.036Z","dependency_job_id":"88d1b29d-3dea-4502-a5a9-9679eb7a8146","html_url":"https://github.com/Windermere-Technology/RasPyCam","commit_stats":{"total_commits":8,"total_committers":2,"mean_commits":4.0,"dds":0.125,"last_synced_commit":"400e78424f3942bb78028829637c0df793466d6d"},"previous_names":["windermere-technology/raspycam"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Windermere-Technology%2FRasPyCam","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Windermere-Technology%2FRasPyCam/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Windermere-Technology%2FRasPyCam/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Windermere-Technology%2FRasPyCam/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Windermere-Technology","download_url":"https://codeload.github.com/Windermere-Technology/RasPyCam/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248215191,"owners_count":21066621,"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":["picamera2","python3","raspberry-pi"],"created_at":"2024-11-03T17:04:03.185Z","updated_at":"2025-04-10T11:51:41.971Z","avatar_url":"https://github.com/Windermere-Technology.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"https://github.com/user-attachments/assets/68c603cb-b79c-474a-aca6-e18a6acbb23c\" height=\"90px\" alt=\"RasPyCam Logo\"\u003e\u003c/p\u003e\n\n\u003ch1\u003eTable of Contents\u003c/h1\u003e\n\n- [Overview](#overview)\n- [Main Features](#main-features)\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Camera Control](#camera-control)\n  - [Image and Video Capture](#image-and-video-capture)\n  - [Motion Detection](#motion-detection)\n  - [Timelapse Feature](#timelapse-feature)\n  - [Camera Settings](#camera-settings)\n  - [Configuration and Status](#configuration-and-status)\n  - [Filename Creation](#filename-creation)\n  - [Stopping the Program](#stopping-the-program)\n- [Contributing](#contributing)\n  - [Issues](#issues)\n  - [Code Changes](#code-changes)\n  - [Testing Changes](#testing-changes)\n- [Acknowledgements](#acknowledgements)\n\n\u003ch1\u003eOverview\u003c/h1\u003e\n\nRasPyCam is a python-based multi-stream camera system for the Raspberry Pi. This application has been designed as a replacement for the [RasPiCam](https://github.com/silvanmelchior/userland/tree/master/host_applications/linux/apps/raspicam) application developed by [Silvan Melchior](https://github.com/silvanmelchior), [Robert Tidey](https://github.com/roberttidey) and [others](https://github.com/silvanmelchior/RPi_Cam_Web_Interface/graphs/contributors) which is no longer maintained and has compatibility issues with the latest versions of the Raspberry Pi.\n\nThere are two ways of using RasPyCam:\n\n1. **As a standalone program**: The program can be run on a Raspberry Pi with a camera module connected to it. The program will respond to manual command calls and perform the necessary actions. This method will use the source code provided in this repository.\n2. **As a backend service**: The program can be run on a Raspberry Pi with a camera module connected to it alongside the [RPi Cam Web Interface](https://github.com/silvanmelchior/RPi_Cam_Web_Interface) system. The program will respond to the commands sent by the frontend and perform the necessary actions. This method will use the executable file created from the source code provided in this repository. As of version 1, the executable file is shipped with the [RPi Cam Web Interface](https://github.com/silvanmelchior/RPi_Cam_Web_Interface) system. Future updates to this repository will update the executable file in the frontend system.\n\n\u003ch1\u003eMain Features\u003c/h1\u003e\n\n- **Preview**: Retrieve the camera feed in real time.\n- **Image Capture**: Capture images from the connected camera.\n- **Video Recording**: Record videos from the connected camera.\n- **Motion Detection**: Detect motion in the camera feed.\n- **Timelapse Image Capture**: Capture periodic images from the connected camera.\n- **Multi-Stream Support**: Stream multiple camera feeds simultaneously from the connected camera.\n- **Web Interface Support**: Interact with the program using the [RPi Cam Web Interface](https://github.com/silvanmelchior/RPi_Cam_Web_Interface) system.\n\n\u003ch1\u003eRequirements\u003c/h1\u003e\n\nDepending on how you run the program, you may need to install some dependencies, including [PiCamera 2](https://pypi.org/project/picamera2/0.2.2/), [OpenCV](https://pypi.org/project/opencv-python/), and [Pillow](https://pypi.org/project/pillow/).\n\nIf you would like to run the source code, you can install these libraries using the following commands:\n\n```bash\npip install picamera2 opencv-python Pillow\n```\n\n\u003ch1\u003eInstallation\u003c/h1\u003e\n\n1. Clone the repository to your Raspberry Pi:\n\n```bash\ngit clone https://github.com/windermere-technology/raspycam.git\n```\n\n2. Run the installation script to install the program and its dependencies:\n\n\u003e [!NOTE]\n\u003e Depending on your Pi's configuration, you may need to run the program with `sudo` privileges. This is because the program requires read/write access to the tmp and var directories which are restricted to root access.\n\n```bash\nsudo ./install.sh\n```\n\nYou will be prompted if you want the frontend ([RPi Cam Web Interface](https://github.com/silvanmelchior/RPi_Cam_Web_Interface)) to be install alongside the program. Select `y` if you want to install the frontend, otherwise select `n`.\n\nAfter the install script finished, you can run the program standalone by running the following command, or it will run automatically with the frontend:\n\n```bash\nraspimjpeg [--config /path/to/config1 /path/to/config2 ...]\n```\n\n`path/to/config` is the path to the configuration file you want to use. If you don't specify a configuration file, the program will use the default configuration file provided in the repository. Provide 2 config will apply the settings to 2 cameras.\n\n\u003ch1\u003eUsage\u003c/h1\u003e\n\nRasPyCam is a continuously running program that observes the commands sent to the named pipe (by default this is `/var/FIFO`).\n\nTo send commands to the program, you can use the following commands:\n\n```bash\necho '{command} {parameter}' \u003e /var/FIFO\n```\n\n\u003e [!NOTE]\n\u003e While the front end is running, the RasPyCam program will be running under www-data user. This means that the FIFO file will be located in `/var/www/html/FIFO` instead of `/var/FIFO`. And you will need to send commands as www-data user.\n\n```bash\nsudo su -c \"echo '{command} {parameter}' \u003e\u003e /var/www/html/FIFO\" www-data\n```\n\n\u003e [!NOTE]\n\u003e Angled brackets refer to \\\u003coptional parameters\\\u003e.\n\n\u003e [!NOTE]\n\u003e Square brackets are used to send commands to multiple cameras. Command and sets of parameters are separated by commas. Forward slashes escape commas. Leading and trailing whitespaces are not stripped from parameters. Not enclosing parameters within brackets applies the parameters to all bracketed commands.\n\n\u003e Example 1: `[dp,dp] [0,1]` = Switches off preview for Camera 0, switches on preview for Camera 1.\n\n\u003e Example 2: `[im,an] [,Look/, an annotation!]` = Takes a still image with Camera 0, sets the annotation for Camera 1 to \"Look, an annotation!\".\n\n\u003e Example 3: `[,im] ` = Camera 0 is not sent any command. Takes an image with Camera 1.\n\n\u003e Example 4: `[ca,ca] 1` = Starts recording on both Camera 0 and Camera 1.\n\n\u003e [!IMPORTANT]\n\u003e The commands `ix+ix` and `im+im` can only be used within square brackets, even if only sent to 1 camera.\n\nCurrently the program supports the following commands:\n\n\u003ch2\u003eCamera Control\u003c/h2\u003e\n\n| Command | Parameter | Description |\n| --- | --- | --- |\n| `ru` | 1/0 | Starts (1) or stops (0) the camera. The program continues to run while the camera is stopped, but the only accepted command will be `ru 1` to restart. |\n| `cn` | {number} | Changes the main camera to the specified number. The number corresponds to the slot index of Picam2's `all_cameras()` function. |\n| `fl` | 0/1/2/3 | Sets horizontal and vertical flip. The parameters are: no flip (0), horizontal flip (1), vertical flip (2), and both horizontal and vertical flip (3). The default is 0. |\n| `dp` | 1/0 | Enables (1) or disables (0) the camera preview. If multiple cameras have previews enabled and share the same image height, they will be stitched together horizontally. |\n\n\u003ch2\u003eImage and Video Capture\u003c/h2\u003e\n\n| Command | Parameter | Description |\n| --- | --- | --- |\n| `ca` | 1/0 {duration} | Starts (1) or stops (0) video recording. Optionally, you can specify a duration in seconds. |\n| `im` | | Takes a still image at current sensor resolution and image size. |\n| `[im+im]` | \\\u003cv/h\\\u003e | Takes a stitched image from all available cameras at their current resolutions and image sizes. You can either vertically (v) stitch or horizontally (h) stitch the feeds. If no axis is specified, stitching will be done horizontally. |\n| `ix` | | Captures an image at the maximum possible sensor resolution and image size, by switching camera configurations and then switching back. Will restart cameras. |\n| `[ix+ix]` | \\\u003cv/h\\\u003e | Captures a stitched image from all available cameras at the maximum resolution, by switching their configurations and then switching back. You can either vertically (v) stitch or horizontally (h) stitch the feeds. If no axis is specified, stitching will be done horizontally. Will restart cameras. |\n\n\u003ch2\u003eMotion Detection\u003c/h2\u003e\n\n| Command | Parameter | Description |\n| --- | --- | --- |\n| `md` | 1/0 | Starts (1) or stops (0) motion detection. |\n| `mx` | 0/2 | Switches the motion detection mode between internal (0) detection and monitor mode (2). |\n| `mt` | {value} | Sets motion detection parameters for threshold. |\n| `ms` | {value} | Sets motion detection parameters for number of frames to delay just after turning on motion detection. |\n| `mb` | {value} | Sets motion detection parameters for number of frames of detected motion needed to register start of motion. |\n| `me` | {value} | Sets motion detection parameters for number of frames without motion needed to register end of motion. |\n\n\u003ch2\u003eTimelapse Feature\u003c/h2\u003e\n\n| Command | Parameter | Description |\n| --- | --- | --- |\n| `tl` | 1/0 | Starts (1) or stops (0) timelapse. |\n| `tv` | {value} | Sets the timelapse image time interval (in units of .1 seconds) |\n\n\u003ch2\u003eCamera Settings\u003c/h2\u003e\n\n| Command | Parameter | Description |\n| --- | --- | --- |\n| `bi` | {bitrate} | Sets the video bitrate (must be between 0 and 25,000,000). |\n| `sh` | {value} | Sets the sharpness of the camera. |\n| `co` | {value} | Sets the contrast of the camera. |\n| `br` | {value} | Sets the brightness of the camera. |\n| `sa` | {value} | Sets the saturation of the camera. |\n| `wb` | {value} | Sets the white balance mode of the camera. |\n| `ag` | {value} | Sets the analog (colour) gain of the camera. |\n| `ss` | {value} | Sets the shutter speed (exposure time in µs) of the camera. |\n| `an` | {value} | Sets the annotation text on the camera feed. See [Filename Creation](#filename-creation) for more details |\n| `ec` | {value} | Sets exposure compensation. |\n| `is` | {value} | Sets the ISO level. |\n| `qu` | {value} | Sets the JPEG image quality (1-100). |\n| `pv` | {quality} {width} {divider} \\\u003cheight\\\u003e | Adjusts preview settings. Height is optional, if not specified, will automatically set height based on width according to 16:9 aspect ratio. |\n| `px` | {video width} {video height} {video fps} {encoder fps} {image width} {image height} | Adjusts video and image settings in bulk. Will restart cameras. |\n\n\u003ch2\u003eConfiguration and Status\u003c/h2\u003e\n\n| Command | Parameter | Description |\n| --- | --- | --- |\n| `rs` | | Resets the user configuration file as specified in the initially supplied config's `user_config` setting and reloads the camera instance’s settings from the initially supplied config file. Will restart cameras. |\n| `sc` | | Recounts and updates the internal tally of image and video files in the output folders. |\n| `cr` | {width height} | Changes the camera sensor resolution. Will restart cameras. |\n| `cs` | i/v/i+v {width height} {width height} | Changes image (i), video (v), or both (i+v) stream sizes. Specifying the second set of width and height only needs to be done when using i+v. Will restart cameras. |\n| `1s` | 0/1/2 | Switches to solo stream mode (1), optionally sets to the maximum sensor resolution if (2) is provided or switches off solo stream mode (0). Will restart cameras. |\n| `sy` | {script} \u003cargs\u003e | Executes a user-defined macro script located in /var/www/html/macros/. {script} is the script file name (e.g., mktimelapse.sh). | \n\nIf the program is initated without a specified configuration file, the program will utilise the following paths for inputs and outputs:\n| Type | Path |\n| --- | --- |\n| Preview | /tmp/preview/cam*preview.jpg |\n| Videos | /tmp/media/vi_cam%I*%v*%Y%M%D*%h%m%s.mp4 |\n| Stills | /tmp/media/im*cam%I*%i*%Y%M%D*%h%m%s.jpg |\n| Status File | /tmp/status_mjpeg.txt |\n\n\u003e Command names, parameters and paths have been sourced from the [RPi Cam Web Interface](https://github.com/silvanmelchior/RPi_Cam_Web_Interface) system to ensure compatibility. In addition to the existing naming scheme used to interpolate values into filenames, the code %I can be used to refer a camera's index number.\n\n\u003ch2\u003eFilename Creation\u003c/h2\u003e\n\nFilenames can be created with standard text alongside the following naming scheme:\n\n| Code | Description |\n| --- | --- |\n| %Y | Four-digit year (e.g., 2023) |\n| %y | Two-digit year (e.g., 23) |\n| %M | Month (01-12) |\n| %D | Day of the month (01-31) |\n| %h | Hour (00-23) |\n| %m | Minute (00-59) |\n| %s | Second (00-59) |\n| %u | Milliseconds (000-999) |\n| %i | Image index (increments with each image captured) |\n| %v | Video index (increments with each video recorded) |\n| %t | Timelapse fileset index (increments with each new set of timelapse images captured) |\n| %I | Camera index, indicating the camera number if multiple cameras are used |\n| %a | Custom annotation text, provided by the user |\n| %% | Literal % symbol in the filename |\n\n\u003e [!NOTE]\n\u003e The `%a` code will read the text from the `/dev/shm/mjpeg/user_annotate.txt` file by default. This file must be created by the user. You may change this default path in the configuration file by adjusting the `user_annotate` parameter.\n\n\u003ch2\u003eStopping the Program\u003c/h2\u003e\n\nTo stop the program, you can either send SIGINT or SIGTERM signals to the program. This can be done by either pressing `Ctrl+C` in the terminal running the program or by using the `kill` command.\n\nIf you've launched the program using the source code, run the following command:\n\n```bash\nsudo kill -9 $(cat /opt/vc/bin/raspycam/raspy.pid)\n```\n\nOr if you've launched the program using the front-end, navigate to the front-end directory and run the following command, or simply press the stop button in the front-end:\n\n```bash\nsudo ./stop.sh\n```\n\n\u003ch1\u003eContributing\u003c/h1\u003e\n\nContributions to the RasPyCam project are welcome. If you would like to contribute to the project, please follow the steps below:\n\n\u003ch2\u003eIssues\u003c/h2\u003e\n\nIf you encounter any issues with the program, you can create a new issue on the [Issues](https://github.com/Windermere-Technology/RasPyCam/issues) page and use one of the provided templates to report the issue.\n\n\u003ch2\u003eCode Changes\u003c/h2\u003e\n\nTo make changes to the code, you can follow the steps below:\n\n1. Fork the repository and clone it to your local machine\n2. Make your changes, commit and push them to your forked repository\n3. Create a pull request back to the main repository ([Windermere-Technology/RasPyCam](https://github.com/windermere-technology/raspycam))\n4. Wait for the pull request to be reviewed and merged\n\n\u003ch2\u003eTesting Changes\u003c/h2\u003e\n\nTo test your changes and generage a coverage report, you can run the following commands on a Raspberry Pi with a camera module connected to it:\n\n```bash\nsudo apt update\nsudo apt install libcap-dev python3-pytest libopencv-dev python3-pytest-cov -y\n```\n\n```bash\nPYTHONPATH=./app pytest --import-mode=importlib --cov=app --cov-report=term --cov-report=html:coverage_html --cov-config=tests/.coveragerc\n```\n\nThis command will run the testing suite and generate a coverage report. You can view this report by opening the `coverage_html/index.html` file in your browser. If you want to test a specific folder or file, just add the path to the end of the command.\n\n\u003ch1\u003eAcknowledgements\u003c/h1\u003e\n\nThe development of this project was inspired by the [RasPiCam](https://github.com/silvanmelchior/userland/tree/master/host_applications/linux/apps/raspicam) application developed by [Silvan Melchior](https://github.com/silvanmelchior), [Robert Tidey](https://github.com/roberttidey) and [others](https://github.com/silvanmelchior/RPi_Cam_Web_Interface/graphs/contributors).\n\nInitially devleoped as part of a University project overseen by [Cian Byrne](https://github.com/wallarug), the development team consisted of:\n\n- [Kyle Graham](https://github.com/kaihokori)\n- [Harry Le (Lê Thành Nhân)](https://github.com/NhanDotJS)\n- [Chen-Don Loi](https://github.com/Chen-Loi)\n- [Qiuda (Richard) Song](https://github.com/RichardQiudaSong)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwindermere-technology%2Fraspycam","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwindermere-technology%2Fraspycam","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwindermere-technology%2Fraspycam/lists"}