{ "info": { "author": "Ethan Li", "author_email": "lietk12@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Topic :: Multimedia :: Graphics :: Capture :: Digital Camera" ], "description": "# picamera-mqtt\nMQTT-based control and image capture with local and remote networked Raspberry Pi cameras.\nDeployment scripts needs to be run from a Raspberry Pi. Other scripts can be run from any computer.\n\n## MQTT Broker Server Setup\n\nTo run the MQTT broker server, edit `deploy/config/broker.conf` and then run\n`deploy/mqtt_broker.sh`.\n\n### Broker Autostart\nTo automatically run the MQTT broker when the host Raspberry Pi starts up,\ninstall the `mqtt_broker.service` systemd unit:\n```\ncd ~/Desktop/picamera-mqtt\nsudo cp deploy/systemd/mqtt_broker.service /etc/systemd/system/mqtt_broker.service\nsudo systemctl enable mqtt_broker\n```\nYou can manually start the service with systemd, view the status of the service with systemd,\nview its output logs with journalctl, or kill the script with systemd:\n```\nsudo systemctl start mqtt_broker\nsystemctl status mqtt_broker\njournalctl -u mqtt_broker\nsudo systemctl stop mqtt_broker\n```\n\n## Camera Client Deployment Setup\n\nThese instructions are for setting up a Raspberry Pi to deploy a camera imaging client.\n\n### Preparation\nYou will need to install some packages on the Raspberry Pi, as follows:\n```\nsudo apt-get update\nsudo apt-get upgrade\nsudo apt-get install git python3-pip\nsudo apt-get install vim byobu wicd-curses # optional, but makes your life easier\n```\n\nYou will need to use the `raspi-config` tool to change the password of the pi user,\nset the locale to `en_US UTF-8`, set the keyboard layout to `English (US)`,\nchange the hostname of the Raspberry Pi, and set the Raspberry Pi to wait for an\ninternet connection upon startup.\n\nYou will need to edit the `/etc/wpa_supplicant/wpa_supplicant.conf` configuration\nfile to connect to wi-fi if you are deploying the Raspberry Pi with a Wi-Fi connection.\n\n### Client Hardware Setup\nConnect a Raspberry Pi Camera to the Raspberry Pi.\n\n### Client Software Setup\nClone this repo, for example with:\n```\ncd ~/Desktop\ngit clone https://github.com/ethanjli/picamera-mqtt.git\n```\nInstall required dependencies from `requirements_deployment.txt`, for example with:\n```\ncd ~/Desktop/picamera-mqtt\nsudo pip3 install -r requirements_deployment.txt\n```\nThen confirm that the camera works correctly by running the `capture.py` script,\nas follows:\n```\ncd ~/Desktop/picamera-mqtt\npython3 -m picamera_mqtt.tests.imaging.capture\n```\nThis should cause the appearance of two files, `capture_pil.jpg` and\n`capture_final.jpg`, in your working directory.\n\n### Client Config\nYou will need to edit the `deploy/config/settings.json` config file such that:\n\n- The `hostname` parameter is either `localhost` (if your MQTT broker is running\n on the same computer as your client) or the IP address of the computer running\n your MQTT broker.\n- The `client_name` parameter and the `target_name` parameter both should say\n `camera_n`, where `n` should be replaced with a unique id number of your camera\n client. This id number will be used to uniquely label each camera stream.\n\n\n### Camera Client Software Autostart\nTo automatically run the camera MQTT client when the Raspberry Pi starts up,\ninstall the `mqtt_imaging.service` systemd unit:\n```\ncd ~/Desktop/picamera-mqtt\nsudo cp deploy/systemd/mqtt_imaging.service /etc/systemd/system/mqtt_imaging.service\nsudo systemctl enable mqtt_imaging\n```\nYou can manually start the service with systemd, view the status of the service with systemd,\nview its output logs with journalctl, or kill the script with systemd:\n```\nsudo systemctl start mqtt_imaging\nsystemctl status mqtt_imaging\njournalctl -u mqtt_imaging\nsudo systemctl stop mqtt_imaging\n```\n\n## Ad Hoc Wi-Fi Network Setup\n\nTo acquire images from multiple Raspberry Pi cameras, each camera should be\nconnected to a Raspberry Pi board. A Raspberry Pi 3 B+ should be running the\n`mqtt_broker` service, and it can also run the `mqtt_imaging` service for the\ncamera attached to it. The other Raspberry Pi boards (e.g. Raspberry Pi Zero W)\nshould be running the `mqtt_imaging` service for their respective cameras. Then\nthe Raspberry Pi 3 needs to be configured to host a simple ad hoc wi-fi network.\n\n### Enabling the Ad Hoc Network\nNOTE: This currently doesn't work correctly. Instead of setting up an ad hoc\nnetwork, the Raspberry Pi boards all need to be connected to some wireless\naccess point.\n\nThe details of enabling and disabling the ad hoc network are managed by the\n[simondlevy/RPiAdHocWiFi repo](https://github.com/simondlevy/RPiAdHocWiFi):\n```\ncd ~/Desktop\ngit clone https://github.com/simondlevy/RPiAdHocWiFi.git\n```\n\nTo enable the ad hoc network, run the following and reboot the Raspberry Pi:\n```\ncd ~/Desktop/RPiAdHocWiFi\nsudo ./install.sh\n```\nThis will create an ad hoc network with SSID `Raspberry-Pi-1`, and the Raspberry Pi\nwill be accessible at IP address `192.168.2.2`.\n\n### Connecting to the Ad Hoc Network\nTo configure the other Raspberry Pi boards, copy `deploy/adhoc/rc.local` to\n`/etc/rc.local`:\n```\ncd ~/Desktop/picamera-mqtt\nsudo cp deploy/adhoc/rc.local /etc/rc.local\n```\nand copy `deploy/adhoc/wpa_supplicant.conf` to `/etc/wpa_supplicant/wpa_supplicant.conf`:\n```\ncd ~/Desktop/picamera-mqtt\nsudo cp deploy/adhoc/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.conf\n```\n\n## System Tests\n\nWith an operational camera client connected to the MQTT broker server, you can run\na few tests on the computer running the MQTT broker server to confirm correct image\ntransfer:\n```\ncd ~/Desktop/picamera-mqtt\npython3 -m picamera_mqtt.tests.mqtt_clients.mock_host --interval 8 --config settings_localhost.json\n```\n\nThis will exercise roundtrip communication to and from the camera client with\nclient name `camera_1` by sending image acquisition messages to the camera client\nevery 8 seconds and receiving (and discarding) images captured by the camera client.\n\nTo save these images, run the following test:\n```\ncd ~/Desktop/picamera-mqtt\npython3 -m picamera_mqtt.tools.timelapse_host --interval 15 --number 5\n```\nThis will take a timelapse of 5 images spaced out at 15-second intervals from\nall camera clients connected to the broker with client names `camera_1`, `camera_2`,\nand `camera_3`; the client names queried can be changed by editing the config file.\nBy default, images will be saved to the `data` directory, but you can change this\nwith the `--output_dir` flag to specify a different path.\n\nIf you only want to capture image snapshots at a single time point, run the following test:\n```\ncd ~/Desktop/picamera-mqtt\npython3 -m picamera_mqtt.tools.acquire_host\n```\nBy default, images will be saved to the `data` directory, but you can change this\nwith the `--output_dir` flag to specify a different path. By default, images will\nbe saved with filenames with `acquire` at the start, but you can change this with\nthe `--output_prefix` flag to specify a different filename prefix.\n\n## System Administration\n\nYou can remotely send deployment management commands to the Raspberry Pi client\nby sending messages over the `deployment` topic. The\n`picamera_mqtt/tools/deploy/mqtt_send_deployment` script lets you do this\nfrom the command-line, as follows:\n```\ncd ~/hand-hygiene/intervention\npython3 -m intervention_system.tools.mqtt_send_deployment shutdown --target_name camera_1 # shut down the Raspberry Pi running camera 1\npython3 -m intervention_system.tools.mqtt_send_deployment reboot --target_name camera_1 # reboot the Raspberry Pi running camera 1\npython3 -m intervention_system.tools.mqtt_send_deployment stop --target_name camera_1 # stop the illumination client running camera 1\npython3 -m intervention_system.tools.mqtt_send_deployment restart --target_name camera_1 # restart the illumination client running camera 1\npython3 -m intervention_system.tools.mqtt_send_deployment \"git pull\" --target_name camera_1 # update the repo and restart the illumination client running camera 1\n```\n\n## Camera Parameter Adjustment\n\nYou can remotely send camera parameter update commands to the Raspberry Pi client\nby sending messages over the `control` topic. The\n`picamera_mqtt/tools/deploy/mqtt_send_camera_params` script lets you do this\nfrom the command-line, as follows:\n```\ncd ~/hand-hygiene/intervention\npython3 -m intervention_system.tools.mqtt_send_camera_params --target_name camera_1 # query camera parameters from camera 1\npython3 -m intervention_system.tools.mqtt_send_camera_params --target_name camera_1 --roi_zoom 1.5 # set camera zoom factor to 1.5 on camera 1\npython3 -m intervention_system.tools.mqtt_send_camera_params --target_name camera_1 --shutter_speed 200 # set shutter speed to 200 ms on camera 1\npython3 -m intervention_system.tools.mqtt_send_camera_params --target_name camera_1 --iso 200 # set ISO to 200 on camera 1\npython3 -m intervention_system.tools.mqtt_send_camera_params --target_name camera_1 --resolution_width 1920 --resolution_height 1080 # set the image resolution to 1920x1080 on camera 1\npython3 -m intervention_system.tools.mqtt_send_camera_params --target_name camera_1 --awb_gain_red 2.0 # set AWB red gain to 2.0 on camera 1\npython3 -m intervention_system.tools.mqtt_send_camera_params --target_name camera_1 --awb_gain_blue 2.0 # set AWB blue gain to 2.0 on camera 1\n```\nNote that all camera param flags can be combined into a single command if you wish.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ethanjli/picamera-mqtt", "keywords": "", "license": "BSD 3-Clause License", "maintainer": "", "maintainer_email": "", "name": "picamera-mqtt", "package_url": "https://pypi.org/project/picamera-mqtt/", "platform": "", "project_url": "https://pypi.org/project/picamera-mqtt/", "project_urls": { "Homepage": "https://github.com/ethanjli/picamera-mqtt" }, "release_url": "https://pypi.org/project/picamera-mqtt/0.0.5/", "requires_dist": [ "paho-mqtt", "pillow", "numpy ; extra == 'mock_camera_client'", "picamera ; extra == 'picamera_client'" ], "requires_python": "", "summary": "MQTT-based control and image capture with local and remote networked Raspberry Pi cameras.", "version": "0.0.5" }, "last_serial": 4604878, "releases": { "0.0.4": [ { "comment_text": "", "digests": { "md5": "501bc9866eee32d9e6ab177079f69124", "sha256": "64ae57d25d1473875777b8e13ff91b28fef374ce356e1f6134378ceabbffa0a9" }, "downloads": -1, "filename": "picamera_mqtt-0.0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "501bc9866eee32d9e6ab177079f69124", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 27916, "upload_time": "2018-12-16T09:29:58", "url": "https://files.pythonhosted.org/packages/8f/d1/7636db92f69c3971774ec9d3816f9cdccca083e6c856d962734e81fe1f83/picamera_mqtt-0.0.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a314602c5ac4d92c3650fcae834b84d5", "sha256": "89cb3a7b44a9007cf64d7cbfa90ef0d7099c35f66a48fcba7f734afc3549a45f" }, "downloads": -1, "filename": "picamera-mqtt-0.0.4.tar.gz", "has_sig": false, "md5_digest": "a314602c5ac4d92c3650fcae834b84d5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16132, "upload_time": "2018-12-16T09:30:00", "url": "https://files.pythonhosted.org/packages/4a/39/96e8d2474e7682d78621f002f1365a6c1d799ef1737aac51cc50cbbd1977/picamera-mqtt-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "699da4d18c068a8bc76053241201c45a", "sha256": "892549d79c736e57aac512bfcb67f2ab3def56445a84750cb67ca45472bd5f0b" }, "downloads": -1, "filename": "picamera_mqtt-0.0.5-py3-none-any.whl", "has_sig": false, "md5_digest": "699da4d18c068a8bc76053241201c45a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 29039, "upload_time": "2018-12-16T14:42:58", "url": "https://files.pythonhosted.org/packages/7b/2c/171b7e84c2fcbde98c725a130e8070eff2f93ea4104a298573f377b4948d/picamera_mqtt-0.0.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8b2d4574fb1802cc31e883c0ceccf706", "sha256": "a22d55b5a7b6abbb0609acfb6bbf09ce74348a45f275394233e82f34e86f4a65" }, "downloads": -1, "filename": "picamera-mqtt-0.0.5.tar.gz", "has_sig": false, "md5_digest": "8b2d4574fb1802cc31e883c0ceccf706", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17160, "upload_time": "2018-12-16T14:43:00", "url": "https://files.pythonhosted.org/packages/8f/f9/dabc71ff0ab8437f1d16fa124edb2384379c5d713beb8c66b5d236f9e82b/picamera-mqtt-0.0.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "699da4d18c068a8bc76053241201c45a", "sha256": "892549d79c736e57aac512bfcb67f2ab3def56445a84750cb67ca45472bd5f0b" }, "downloads": -1, "filename": "picamera_mqtt-0.0.5-py3-none-any.whl", "has_sig": false, "md5_digest": "699da4d18c068a8bc76053241201c45a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 29039, "upload_time": "2018-12-16T14:42:58", "url": "https://files.pythonhosted.org/packages/7b/2c/171b7e84c2fcbde98c725a130e8070eff2f93ea4104a298573f377b4948d/picamera_mqtt-0.0.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8b2d4574fb1802cc31e883c0ceccf706", "sha256": "a22d55b5a7b6abbb0609acfb6bbf09ce74348a45f275394233e82f34e86f4a65" }, "downloads": -1, "filename": "picamera-mqtt-0.0.5.tar.gz", "has_sig": false, "md5_digest": "8b2d4574fb1802cc31e883c0ceccf706", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17160, "upload_time": "2018-12-16T14:43:00", "url": "https://files.pythonhosted.org/packages/8f/f9/dabc71ff0ab8437f1d16fa124edb2384379c5d713beb8c66b5d236f9e82b/picamera-mqtt-0.0.5.tar.gz" } ] }