├── .gitignore ├── Display_Images.xml ├── LICENSE ├── LICENSE_peopleblocker ├── MXRECORD.json ├── MovidiusIngest.xml ├── MovidiusServerAll.xml ├── README.md ├── Store_Images.xml ├── all.py ├── analyze.py ├── buildconfig.sh ├── buildpage.sh ├── classify_image.py ├── config.yml ├── displayimages.xml ├── gluon2.avsc ├── gluon2.py ├── gluoncv.avsc ├── gluoncv_image_processed_20180615202056_8eb9c885-2cf7-4591-8d4a-f0962b2e9cb1.jpg ├── gluoncvexample.json ├── gluoncvflow1.png ├── httpserver.xml ├── images.html ├── index.sh ├── minifimovidius.xml ├── mxclassify.sh ├── mxrecordschemawithopencv.png ├── nifi_gluoncv_sd.py ├── nifigluon2.py ├── pb.py ├── run.sh ├── run2.sh ├── run3.sh ├── rungluon2.sh └── testcv.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | 49 | # Translations 50 | *.mo 51 | *.pot 52 | 53 | # Django stuff: 54 | *.log 55 | local_settings.py 56 | 57 | # Flask stuff: 58 | instance/ 59 | .webassets-cache 60 | 61 | # Scrapy stuff: 62 | .scrapy 63 | 64 | # Sphinx documentation 65 | docs/_build/ 66 | 67 | # PyBuilder 68 | target/ 69 | 70 | # Jupyter Notebook 71 | .ipynb_checkpoints 72 | 73 | # pyenv 74 | .python-version 75 | 76 | # celery beat schedule file 77 | celerybeat-schedule 78 | 79 | # SageMath parsed files 80 | *.sage.py 81 | 82 | # dotenv 83 | .env 84 | 85 | # virtualenv 86 | .venv 87 | venv/ 88 | ENV/ 89 | 90 | # Spyder project settings 91 | .spyderproject 92 | .spyproject 93 | 94 | # Rope project settings 95 | .ropeproject 96 | 97 | # mkdocs documentation 98 | /site 99 | 100 | # mypy 101 | .mypy_cache/ 102 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /LICENSE_peopleblocker: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Max Woolf 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | --- 24 | 25 | Mask R-CNN 26 | 27 | The MIT License (MIT) 28 | 29 | Copyright (c) 2017 Matterport, Inc. 30 | -------------------------------------------------------------------------------- /MXRECORD.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "record", 3 | "name": "MXRECORD", 4 | "fields": [ 5 | { 6 | "name": "filename", 7 | "type": "string", 8 | "doc": "Type inferred from '\"tx1_image_uhh_20180328184728.jpg\"'" 9 | }, 10 | { 11 | "name": "top1pct", 12 | "type": "string", 13 | "doc": "Type inferred from '\"30.0\"'" 14 | }, 15 | { 16 | "name": "top5", 17 | "type": "string", 18 | "doc": "Type inferred from '\"n03126707 crane\"'" 19 | }, 20 | { 21 | "name": "top4", 22 | "type": "string", 23 | "doc": "Type inferred from '\"n03977966 police van, police wagon, paddy wagon, patrol wagon, wagon, black Maria\"'" 24 | }, 25 | { 26 | "name": "top3", 27 | "type": "string", 28 | "doc": "Type inferred from '\"n03417042 garbage truck, dustcart\"'" 29 | }, 30 | { 31 | "name": "top2", 32 | "type": "string", 33 | "doc": "Type inferred from '\"n02930766 cab, hack, taxi, taxicab\"'" 34 | }, 35 | { 36 | "name": "top1", 37 | "type": "string", 38 | "doc": "Type inferred from '\"n02977058 cash machine, cash dispenser, automated teller machine, automatic teller machine, automated teller, automatic teller, ATM\"'" 39 | }, 40 | { 41 | "name": "y", 42 | "type": "string", 43 | "doc": "Type inferred from '\"0\"'" 44 | }, 45 | { 46 | "name": "host", 47 | "type": "string", 48 | "doc": "Type inferred from '\"tegra-ubuntu\"'" 49 | }, 50 | { 51 | "name": "h", 52 | "type": "string", 53 | "doc": "Type inferred from '\"0\"'" 54 | }, 55 | { 56 | "name": "top2pct", 57 | "type": "string", 58 | "doc": "Type inferred from '\"4.8\"'" 59 | }, 60 | { 61 | "name": "cputemp", 62 | "type": "double", 63 | "doc": "Type inferred from '30.0'" 64 | }, 65 | { 66 | "name": "endtime", 67 | "type": "string", 68 | "doc": "Type inferred from '\"2018-03-28 18:47:36\"'" 69 | }, 70 | { 71 | "name": "ipaddress", 72 | "type": "string", 73 | "doc": "Type inferred from '\"192.168.1.190\"'" 74 | }, 75 | { 76 | "name": "imagefilename", 77 | "type": "string", 78 | "doc": "Type inferred from '\"tx1_image_uhh_20180328184728.jpg\"'" 79 | }, 80 | { 81 | "name": "top3pct", 82 | "type": "string", 83 | "doc": "Type inferred from '\"3.7\"'" 84 | }, 85 | { 86 | "name": "uuid", 87 | "type": "string", 88 | "doc": "Type inferred from '\"mxnet_uuid_dcx_20180328184727\"'" 89 | }, 90 | { 91 | "name": "facedetect", 92 | "type": "string", 93 | "doc": "Type inferred from '\"[GIE] layer network time - 28.215418 ms|detectnet-console: finished processing network (1522262852823)|0 bounding boxes detected|detectnet-console: writing 640x480 image to '/media/nvidia/96ed93f9-7c40-4999-85ba-3eb24262d0a5/images/fcout-tx1_image_uhh_20180328184728.jpg'|detectnet-console: successfully wrote 640x480 image to '/media/nvidia/96ed93f9-7c40-4999-85ba-3eb24262d0a5/images/fcout-tx1_image_uhh_20180328184728.jpg'||shutting down...|\"'" 94 | }, 95 | { 96 | "name": "diskfree", 97 | "type": "string", 98 | "doc": "Type inferred from '\"2931.8 MB\"'" 99 | }, 100 | { 101 | "name": "cvfilename", 102 | "type": "string", 103 | "doc": "Type inferred from '\"\"'" 104 | }, 105 | { 106 | "name": "ts", 107 | "type": "string", 108 | "doc": "Type inferred from '\"2018-03-28 18:47:26\"'" 109 | }, 110 | { 111 | "name": "top4pct", 112 | "type": "string", 113 | "doc": "Type inferred from '\"3.5\"'" 114 | }, 115 | { 116 | "name": "gputempf", 117 | "type": "string", 118 | "doc": "Type inferred from '\"73.0\"'" 119 | }, 120 | { 121 | "name": "gputemp", 122 | "type": "string", 123 | "doc": "Type inferred from '\"22.5\"'" 124 | }, 125 | { 126 | "name": "top5pct", 127 | "type": "string", 128 | "doc": "Type inferred from '\"2.5\"'" 129 | }, 130 | { 131 | "name": "w", 132 | "type": "string", 133 | "doc": "Type inferred from '\"0\"'" 134 | }, 135 | { 136 | "name": "memory", 137 | "type": "double", 138 | "doc": "Type inferred from '29.7'" 139 | }, 140 | { 141 | "name": "imagenet", 142 | "type": "string", 143 | "doc": "Type inferred from '\"class 0481 - 0.039276 (cassette)|class 0482 - 0.025558 (cassette player)|class 0492 - 0.028412 (chest)|class 0519 - 0.016373 (crate)|class 0530 - 0.047028 (digital clock)|class 0531 - 0.021957 (digital watch)|class 0579 - 0.018341 (grand piano, grand)|class 0598 - 0.034119 (home theater, home theatre)|class 0613 - 0.015030 (joystick)|class 0620 - 0.012413 (laptop, laptop computer)|class 0632 - 0.021866 (loudspeaker, speaker, speaker unit, loudspeaker system, speaker system)|class 0662 - 0.010910 (modem)|class 0710 - 0.012657 (pencil sharpener)|class 0713 - 0.010574 (photocopier)|class 0732 - 0.043488 (Polaroid camera, Polaroid Land camera)|class 0742 - 0.038239 (printer)|class 0745 - 0.063049 (projector)|class 0754 - 0.014793 (radio, wireless)|class 0761 - 0.013901 (remote control, remote)|class 0848 - 0.031204 (tape player)|class 0851 - 0.045227 (television, television system)|class 0882 - 0.017990 (vacuum, vacuum cleaner)|imagenet-console: '/media/nvidia/96ed93f9-7c40-4999-85ba-3eb24262d0a5/images/tx1_image_uhh_20180328184728.jpg' -> 6.30493% class #745 (projector)|loaded image fontmapA.png (256 x 512) 2097152 bytes|[cuda] cudaAllocMapped 2097152 bytes, CPU 0x101500000 GPU 0x101500000|[cuda] cudaAllocMapped 8192 bytes, CPU 0x100e22000 GPU 0x100e22000|imagenet-console: attempting to save output image to '/media/nvidia/96ed93f9-7c40-4999-85ba-3eb24262d0a5/images/cfout-tx1_image_uhh_20180328184728.jpg'|imagenet-console: completed saving '/media/nvidia/96ed93f9-7c40-4999-85ba-3eb24262d0a5/images/cfout-tx1_image_uhh_20180328184728.jpg'||shutting down...|\"'" 144 | }, 145 | { 146 | "name": "x", 147 | "type": "string", 148 | "doc": "Type inferred from '\"0\"'" 149 | }, 150 | { 151 | "name": "cvface", 152 | "type": "string", 153 | "doc": "Type inferred from '\"\"'" 154 | }, 155 | { 156 | "name": "runtime", 157 | "type": "string", 158 | "doc": "Type inferred from '\"9.0\"'" 159 | }, 160 | { 161 | "name": "cputempf", 162 | "type": "string", 163 | "doc": "Type inferred from '\"78.0\"'" 164 | } 165 | ] 166 | } 167 | -------------------------------------------------------------------------------- /MovidiusIngest.xml: -------------------------------------------------------------------------------- 1 | 2 | 1473 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OpenSourceComputerVision 2 | 3 | Open Source Computer Vision with TensorFlow, MiniFi, Apache NiFi, OpenCV, Apache Tika and Python For processing images from IoT devices like Raspberry Pis, NVidia Jetson TX1, NanoPi Duos and more which are equipped with attached cameras or external USB webcams, we use Python to interface via OpenCV and PiCamera. From there we run image processing at the edge on these IoT device using OpenCV and TensorFlow to determine attributes and image analytics. A pache MiniFi coordinates running these Python scripts and decides when and what to send from that analysis and the image to a remote Apache NiFi server for additional processing. At the Apache NiFi cluster in the cluster it routes the images to one processing path and the JSON encoded metadata to another flow. The JSON data (with it's schema referenced from a central Schema Registry) is routed and routed using Record Processing and SQL, this data in enriched and augment before conversion to AVRO to be send via Apache Kafka to SAM. Streaming Analytics Manager then does deeper processing on this stream and others including weather and twitter to determine what should be done on this data. 4 | 5 | References 6 | 7 | * https://community.hortonworks.com/articles/103863/using-an-asus-tinkerboard-with-tensorflow-and-pyth.html 8 | * https://community.hortonworks.com/articles/118132/minifi-capturing-converting-tensorflow-inception-t.html 9 | * https://github.com/tspannhw/rpi-noir-screen 10 | * https://community.hortonworks.com/articles/77988/ingest-remote-camera-images-from-raspberry-pi-via.html 11 | * https://community.hortonworks.com/articles/107379/minifi-for-image-capture-and-ingestion-from-raspbe.html 12 | * https://community.hortonworks.com/articles/58265/analyzing-images-in-hdf-20-using-tensorflow.html 13 | 14 | 15 | 16 | pb.py 17 | 18 | License 19 | MIT 20 | 21 | Code used from Mask R-CNN by Matterport, Inc. (MIT-Licensed), with minor alterations and copyright notices retained. 22 | 23 | 24 | MIT License 25 | 26 | Copyright (c) 2018 Max Woolf 27 | 28 | Permission is hereby granted, free of charge, to any person obtaining a copy 29 | of this software and associated documentation files (the "Software"), to deal 30 | in the Software without restriction, including without limitation the rights 31 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 32 | copies of the Software, and to permit persons to whom the Software is 33 | furnished to do so, subject to the following conditions: 34 | 35 | The above copyright notice and this permission notice shall be included in all 36 | copies or substantial portions of the Software. 37 | 38 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 39 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 40 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 41 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 42 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 43 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 44 | SOFTWARE. 45 | 46 | --- 47 | 48 | Mask R-CNN 49 | 50 | The MIT License (MIT) 51 | 52 | Copyright (c) 2017 Matterport, Inc. 53 | 54 | -------------------------------------------------------------------------------- /Store_Images.xml: -------------------------------------------------------------------------------- 1 | 2 | 364 | -------------------------------------------------------------------------------- /mxclassify.sh: -------------------------------------------------------------------------------- 1 | cd /media/nvidia/96ed93f9-7c40-4999-85ba-3eb24262d0a5/ 2 | python -W ignore /media/nvidia/96ed93f9-7c40-4999-85ba-3eb24262d0a5/analyze.py 2>/dev/null 3 | -------------------------------------------------------------------------------- /mxrecordschemawithopencv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tspannhw/OpenSourceComputerVision/5c654a9025354257cfbf0b352e5b95e15223b595/mxrecordschemawithopencv.png -------------------------------------------------------------------------------- /nifi_gluoncv_sd.py: -------------------------------------------------------------------------------- 1 | # Based on https://gluon-cv.mxnet.io/build/examples_detection/demo_ssd.html#sphx-glr-build-examples-detection-demo-ssd-py 2 | from gluoncv import model_zoo, data, utils 3 | from matplotlib import pyplot as plt 4 | import numpy 5 | import base64 6 | import uuid 7 | from mxnet import nd, gluon, init, autograd 8 | from mxnet.gluon import nn 9 | from mxnet.gluon.data.vision import datasets, transforms 10 | import matplotlib.pyplot as plt 11 | from time import time 12 | from mxnet.gluon.model_zoo import vision as models 13 | from mxnet.gluon.utils import download 14 | from mxnet import image 15 | import time 16 | import sys 17 | import datetime 18 | import subprocess 19 | import os 20 | from PIL import Image 21 | import datetime 22 | import traceback 23 | import math 24 | import random, string 25 | import base64 26 | import json 27 | from time import gmtime, strftime 28 | import mxnet as mx 29 | import inception_predict 30 | import numpy as np 31 | import cv2 32 | import math 33 | import random, string 34 | import time 35 | import numpy 36 | import random, string 37 | import time 38 | import psutil 39 | import paho.mqtt.client as mqtt 40 | import scipy.misc 41 | from time import gmtime, strftime 42 | start = time.time() 43 | cap = cv2.VideoCapture(1) # 0 - laptop #1 - monitor 44 | ret, frame = cap.read() 45 | uuid = '{0}_{1}'.format(strftime("%Y%m%d%H%M%S",gmtime()),uuid.uuid4()) 46 | filename = 'images/gluoncv_image_{0}.jpg'.format(uuid) 47 | filename2 = 'images/gluoncv_image_processed_{0}.jpg'.format(uuid) 48 | cv2.imwrite(filename, frame) 49 | 50 | # model zoo for SSD 512 RESNET 50 v1 VOC 51 | net = model_zoo.get_model('ssd_512_resnet50_v1_voc', pretrained=True) 52 | 53 | #im_fname = utils.download('https://github.com/dmlc/web-data/blob/master/' + 54 | # 'gluoncv/detection/street_small.jpg?raw=true', 55 | # path='street_small.jpg') 56 | 57 | x, img = data.transforms.presets.ssd.load_test(filename, short=512) 58 | 59 | end = time.time() 60 | row = { } 61 | row['imgname'] = filename 62 | row['host'] = os.uname()[1] 63 | row['shape'] = str(x.shape) 64 | row['end'] = '{0}'.format( str(end )) 65 | row['te'] = '{0}'.format(str(end-start)) 66 | row['battery'] = psutil.sensors_battery()[0] 67 | row['systemtime'] = datetime.datetime.now().strftime('%m/%d/%Y %H:%M:%S') 68 | row['cpu'] = psutil.cpu_percent(interval=1) 69 | usage = psutil.disk_usage("/") 70 | row['diskusage'] = "{:.1f} MB".format(float(usage.free) / 1024 / 1024) 71 | row['memory'] = psutil.virtual_memory().percent 72 | row['id'] = str(uuid) 73 | json_string = json.dumps(row) 74 | # print(json_string) 75 | 76 | # MQTT 77 | client = mqtt.Client() 78 | client.username_pw_set("user","pass") 79 | client.connect("server", 17769, 60) 80 | client.publish("gluoncv", payload=json_string, qos=0, retain=True) 81 | 82 | class_IDs, scores, bounding_boxs = net(x) 83 | 84 | ax = utils.viz.plot_bbox(img, bounding_boxs[0], scores[0], class_IDs[0], class_names=net.classes) 85 | 86 | plt.savefig(filename2) 87 | # plt.show() 88 | -------------------------------------------------------------------------------- /nifigluon2.py: -------------------------------------------------------------------------------- 1 | import numpy 2 | import base64 3 | import uuid 4 | from mxnet import nd, gluon, init, autograd 5 | from mxnet.gluon import nn 6 | from mxnet.gluon.data.vision import datasets, transforms 7 | import matplotlib.pyplot as plt 8 | from time import time 9 | from mxnet.gluon.model_zoo import vision as models 10 | from mxnet.gluon.utils import download 11 | from mxnet import image 12 | import time 13 | import sys 14 | import datetime 15 | import subprocess 16 | import sys 17 | import os 18 | import datetime 19 | import traceback 20 | import math 21 | import random, string 22 | import base64 23 | import json 24 | from time import gmtime, strftime 25 | import mxnet as mx 26 | import inception_predict 27 | import numpy as np 28 | import cv2 29 | import math 30 | import random, string 31 | import time 32 | import numpy 33 | import random, string 34 | import time 35 | import psutil 36 | import paho.mqtt.client as mqtt 37 | from time import gmtime, strftime 38 | start = time.time() 39 | cap = cv2.VideoCapture(1) # 0 - laptop #1 - monitor 40 | 41 | # http://gluon-crash-course.mxnet.io/predict.html 42 | def transform(data): 43 | data = data.transpose((2,0,1)).expand_dims(axis=0) 44 | rgb_mean = nd.array([0.485, 0.456, 0.406]).reshape((1,3,1,1)) 45 | rgb_std = nd.array([0.229, 0.224, 0.225]).reshape((1,3,1,1)) 46 | return (data.astype('float32') / 255 - rgb_mean) / rgb_std 47 | 48 | 49 | net = models.resnet50_v2(pretrained=True) 50 | 51 | 52 | url = 'http://data.mxnet.io/models/imagenet/synset.txt' 53 | fname = download(url) 54 | with open(fname, 'r') as f: 55 | text_labels = [' '.join(l.split()[1:]) for l in f] 56 | 57 | ret, frame = cap.read() 58 | uuid = '{0}_{1}'.format(strftime("%Y%m%d%H%M%S",gmtime()),uuid.uuid4()) 59 | filename = 'images/gluon_image_{0}.jpg'.format(uuid) 60 | cv2.imwrite(filename, frame) 61 | 62 | x = image.imread(filename) 63 | x = image.resize_short(x, 256) 64 | x, _ = image.center_crop(x, (224,224)) 65 | 66 | prob = net(transform(x)).softmax() 67 | idx = prob.topk(k=5)[0] 68 | row = { } 69 | 70 | #for i in idx: 71 | # i = int(i.asscalar()) 72 | # print(i) 73 | # print('prob=%.5f, %s' % ( prob[0,i].asscalar() * 100, text_labels[i])) 74 | try: 75 | end = time.time() 76 | row['top1pct'] = '{:.1f}'.format(prob[0,int(idx[0].asscalar())].asscalar()*100) 77 | row['top2pct'] = '{:.1f}'.format(prob[0,int(idx[1].asscalar())].asscalar()*100) 78 | row['top3pct'] = '{:.1f}'.format(prob[0,int(idx[2].asscalar())].asscalar()*100) 79 | row['top4pct'] = '{:.1f}'.format(prob[0,int(idx[3].asscalar())].asscalar()*100) 80 | row['top5pct'] = '{:.1f}'.format(prob[0,int(idx[4].asscalar())].asscalar()*100) 81 | row['top1'] = str(text_labels[int(idx[0].asscalar())]) 82 | row['top2'] = str(text_labels[int(idx[1].asscalar())]) 83 | row['top3'] = str(text_labels[int(idx[2].asscalar())]) 84 | row['top4'] = str(text_labels[int(idx[3].asscalar())]) 85 | row['top5'] = str(text_labels[int(idx[4].asscalar())]) 86 | row['imgname'] = filename 87 | row['host'] = os.uname()[1] 88 | row['end'] = '{0}'.format( str(end )) 89 | row['te'] = '{0}'.format(str(end-start)) 90 | row['battery'] = psutil.sensors_battery()[0] 91 | row['systemtime'] = datetime.datetime.now().strftime('%m/%d/%Y %H:%M:%S') 92 | row['cpu'] = psutil.cpu_percent(interval=1) 93 | usage = psutil.disk_usage("/") 94 | row['diskusage'] = "{:.1f} MB".format(float(usage.free) / 1024 / 1024) 95 | row['memory'] = psutil.virtual_memory().percent 96 | row['id'] = str(uuid) 97 | json_string = json.dumps(row) 98 | #print(json_string) 99 | # MQTT 100 | client = mqtt.Client() 101 | client.username_pw_set("user","pass") 102 | client.connect("server", 17769, 60) 103 | client.publish("gluon", payload=json_string, qos=0, retain=True) 104 | except: 105 | print("{\"message\": \"Failed to run\"}") 106 | -------------------------------------------------------------------------------- /pb.py: -------------------------------------------------------------------------------- 1 | # Forked From https://github.com/minimaxir/person-blocker 2 | # License 3 | #MIT 4 | # 5 | #Code used from Mask R-CNN by Matterport, Inc. (MIT-Licensed), with minor alterations and copyright notices retained. 6 | #MIT License 7 | # 8 | #Copyright (c) 2018 Max Woolf 9 | # 10 | #Permission is hereby granted, free of charge, to any person obtaining a copy 11 | #of this software and associated documentation files (the "Software"), to deal 12 | #in the Software without restriction, including without limitation the rights 13 | #to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | #copies of the Software, and to permit persons to whom the Software is 15 | #furnished to do so, subject to the following conditions:# 16 | # 17 | #The above copyright notice and this permission notice shall be included in all 18 | #copies or substantial portions of the Software. 19 | # 20 | #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | #IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | #FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | #AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | #LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | #OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | #SOFTWARE. 27 | # 28 | #--- 29 | # 30 | #Mask R-CNN 31 | # 32 | #The MIT License (MIT) 33 | # 34 | #Copyright (c) 2017 Matterport, Inc. 35 | 36 | import os 37 | import sys 38 | import argparse 39 | import numpy as np 40 | import coco 41 | import utils 42 | import model as modellib 43 | from classes import get_class_names, InferenceConfig 44 | from ast import literal_eval as make_tuple 45 | import imageio 46 | import visualize 47 | import os.path 48 | import re 49 | import datetime 50 | import math 51 | import random, string 52 | import base64 53 | import json 54 | import socket 55 | import psutil 56 | import subprocess 57 | import time 58 | import uuid 59 | import cv2 60 | import math 61 | import random, string 62 | import time 63 | from time import gmtime, strftime 64 | 65 | cap = cv2.VideoCapture(1) 66 | packet_size=3000 67 | ret, frame = cap.read() 68 | filename = 'images2/tx1_image_{0}_{1}.jpg'.format(uuid.uuid4(),strftime("%Y%m%d%H%M%S",gmtime())) 69 | cv2.imwrite(filename, frame) 70 | 71 | from time import sleep 72 | from time import gmtime, strftime 73 | start = time.time() 74 | 75 | # minor fork by tim spann for nifi usage 76 | # 2018-april-4 77 | # Creates a color layer and adds Gaussian noise. 78 | # For each pixel, the same noise value is added to each channel 79 | # to mitigate hue shfting. 80 | 81 | external_IP_and_port = ('198.41.0.4', 53) # a.root-servers.net 82 | socket_family = socket.AF_INET 83 | 84 | def IP_address(): 85 | try: 86 | s = socket.socket(socket_family, socket.SOCK_DGRAM) 87 | s.connect(external_IP_and_port) 88 | answer = s.getsockname() 89 | s.close() 90 | return answer[0] if answer else None 91 | except socket.error: 92 | return None 93 | 94 | def create_noisy_color(image, color): 95 | color_mask = np.full(shape=(image.shape[0], image.shape[1], 3), 96 | fill_value=color) 97 | 98 | noise = np.random.normal(0, 25, (image.shape[0], image.shape[1])) 99 | noise = np.repeat(np.expand_dims(noise, axis=2), repeats=3, axis=2) 100 | mask_noise = np.clip(color_mask + noise, 0., 255.) 101 | return mask_noise 102 | 103 | 104 | # Helper function to allow both RGB triplet + hex CL input 105 | 106 | def string_to_rgb_triplet(triplet): 107 | 108 | if '#' in triplet: 109 | # http://stackoverflow.com/a/4296727 110 | triplet = triplet.lstrip('#') 111 | _NUMERALS = '0123456789abcdefABCDEF' 112 | _HEXDEC = {v: int(v, 16) 113 | for v in (x + y for x in _NUMERALS for y in _NUMERALS)} 114 | return (_HEXDEC[triplet[0:2]], _HEXDEC[triplet[2:4]], 115 | _HEXDEC[triplet[4:6]]) 116 | 117 | else: 118 | # https://stackoverflow.com/a/9763133 119 | triplet = make_tuple(triplet) 120 | return triplet 121 | 122 | 123 | def person_blocker(args): 124 | 125 | # Required to load model, but otherwise unused 126 | ROOT_DIR = os.getcwd() 127 | COCO_MODEL_PATH = args.model or os.path.join(ROOT_DIR, "mask_rcnn_coco.h5") 128 | 129 | MODEL_DIR = os.path.join(ROOT_DIR, "logs") # Required to load model 130 | 131 | if not os.path.exists(COCO_MODEL_PATH): 132 | utils.download_trained_weights(COCO_MODEL_PATH) 133 | 134 | # Load model and config 135 | config = InferenceConfig() 136 | model = modellib.MaskRCNN(mode="inference", 137 | model_dir=MODEL_DIR, config=config) 138 | model.load_weights(COCO_MODEL_PATH, by_name=True) 139 | 140 | image = imageio.imread(filename) 141 | 142 | # Create masks for all objects 143 | results = model.detect([image], verbose=0) 144 | r = results[0] 145 | 146 | if args.labeled: 147 | position_ids = ['[{}]'.format(x) 148 | for x in range(r['class_ids'].shape[0])] 149 | visualize.display_instances(image, r['rois'], 150 | r['masks'], r['class_ids'], 151 | get_class_names(), position_ids) 152 | sys.exit() 153 | 154 | # Filter masks to only the selected objects 155 | objects = np.array(args.objects) 156 | 157 | # Object IDs: 158 | if np.all(np.chararray.isnumeric(objects)): 159 | object_indices = objects.astype(int) 160 | # Types of objects: 161 | else: 162 | selected_class_ids = np.flatnonzero(np.in1d(get_class_names(), 163 | objects)) 164 | object_indices = np.flatnonzero( 165 | np.in1d(r['class_ids'], selected_class_ids)) 166 | 167 | mask_selected = np.sum(r['masks'][:, :, object_indices], axis=2) 168 | 169 | # Replace object masks with noise 170 | mask_color = string_to_rgb_triplet(args.color) 171 | image_masked = image.copy() 172 | noisy_color = create_noisy_color(image, mask_color) 173 | image_masked[mask_selected > 0] = noisy_color[mask_selected > 0] 174 | 175 | img_dir = '/Volumes/seagate/projects/person-blocker/images2/' 176 | img_pre = 'person_blocked_{0}'.format(strftime("%Y%m%d%H%M%S",gmtime())) 177 | img_name = img_dir + img_pre + '.png' 178 | gif_name = img_dir + img_pre + '.gif' 179 | 180 | imageio.imwrite(img_name, image_masked) 181 | 182 | # Create GIF. The noise will be random for each frame, 183 | # which creates a "static" effect 184 | # this works great, but takes some time and produces 7+ meg file 185 | #images = [image_masked] 186 | #num_images = 10 # should be a divisor of 30 187 | # 188 | #for _ in range(num_images - 1): 189 | # new_image = image.copy() 190 | # noisy_color = create_noisy_color(image, mask_color) 191 | # new_image[mask_selected > 0] = noisy_color[mask_selected > 0] 192 | # images.append(new_image) 193 | # 194 | #imageio.mimsave(gif_name, images, fps=30., subrectangles=True) 195 | 196 | # print json 197 | try: 198 | # Create unique image name 199 | uniqueid = 'person_uuid_{0}_{1}'.format(strftime("%Y%m%d%H%M%S%f",gmtime()),uuid.uuid4()) 200 | host = os.uname()[1] 201 | currenttime= strftime("%Y-%m-%d %H:%M:%S",gmtime()) 202 | ipaddress = IP_address() 203 | end = time.time() 204 | row = { 'uuid': uniqueid, 'runtime': str(round(end - start)), 'host': host, 'ts': currenttime, 'ipaddress': ipaddress, 'imagefilename': img_pre, 'originalfilename': filename } 205 | print( json.dumps(row) ) 206 | 207 | except: 208 | print("{\"message\": \"Failed to run\"}") 209 | 210 | 211 | if __name__ == '__main__': 212 | parser = argparse.ArgumentParser( 213 | description='Person Blocker - Automatically "block" people ' 214 | 'in images using a neural network.') 215 | parser.add_argument('-i', '--image', help='Image file name.', 216 | required=False) 217 | parser.add_argument( 218 | '-m', '--model', help='path to COCO model', default=None) 219 | parser.add_argument('-o', 220 | '--objects', nargs='+', 221 | help='object(s)/object ID(s) to block. ' + 222 | 'Use the -names flag to print a list of ' + 223 | 'valid objects', 224 | default='person') 225 | parser.add_argument('-c', 226 | '--color', nargs='?', default='(255, 255, 255)', 227 | help='color of the "block"') 228 | parser.add_argument('-l', 229 | '--labeled', dest='labeled', 230 | action='store_true', 231 | help='generate labeled image instead') 232 | parser.add_argument('-n', 233 | '--names', dest='names', 234 | action='store_true', 235 | help='prints class names and exits.') 236 | parser.set_defaults(labeled=False, names=False) 237 | args = parser.parse_args() 238 | 239 | if args.names: 240 | print(get_class_names()) 241 | sys.exit() 242 | 243 | person_blocker(args) 244 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | cd /Volumes/seagate/projects/person-blocker 2 | python3 -W ignore pb.py 2>/dev/null 3 | -------------------------------------------------------------------------------- /run2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DATE=$(date +"%Y-%m-%d_%H%M") 4 | 5 | fswebcam -q -r 1280x720 --no-banner /opt/demo/images/$DATE.jpg 6 | 7 | python3 -W ignore /opt/demo/all.py /opt/demo/images/$DATE.jpg 2>/dev/null 8 | -------------------------------------------------------------------------------- /run3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DATE=$(date +"%Y-%m-%d_%H%M") 4 | 5 | fswebcam -q -r 1280x720 --no-banner /opt/demo/images/$DATE.jpg 6 | 7 | python2 -W ignore /opt/demo/classify_image.py /opt/demo/images/$DATE.jpg 2>/dev/null 8 | -------------------------------------------------------------------------------- /rungluon2.sh: -------------------------------------------------------------------------------- 1 | python3.6 -W ignore /Volumes/seagate/projects/incubator-mxnet/gluon2.py 2>/dev/null 2 | -------------------------------------------------------------------------------- /testcv.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import os 3 | import sys 4 | import json 5 | import socket 6 | import psutil 7 | import subprocess 8 | import time 9 | import datetime 10 | from time import sleep 11 | from time import gmtime, strftime 12 | from string import Template 13 | # forked from https://gist.github.com/dannguyen/cfa2fb49b28c82a1068f 14 | # first argument is the haarcascades path 15 | 16 | currenttime= strftime("%Y-%m-%d %H:%M:%S",gmtime()) 17 | host = os.uname()[1] 18 | #print(os.uname()) 19 | cpu = psutil.cpu_percent(interval=1) 20 | if 1==1: 21 | f = open('/sys/class/thermal/thermal_zone0/temp', 'r') 22 | l = f.readline() 23 | ctemp = 1.0 * float(l)/1000 24 | usage = psutil.disk_usage("/") 25 | mem = psutil.virtual_memory() 26 | diskrootfree = "{:.1f} MB".format(float(usage.free) / 1024 / 1024) 27 | mempercent = mem.percent 28 | external_IP_and_port = ('198.41.0.4', 53) # a.root-servers.net 29 | socket_family = socket.AF_INET 30 | #p = subprocess.Popen(['/opt/vc/bin/vcgencmd','measure_temp'], stdout=subprocess.PIPE, 31 | # stderr=subprocess.PIPE) 32 | #out, err = p.communicate() 33 | def IP_address(): 34 | try: 35 | s = socket.socket(socket_family, socket.SOCK_DGRAM) 36 | s.connect(external_IP_and_port) 37 | answer = s.getsockname() 38 | s.close() 39 | return answer[0] if answer else None 40 | except socket.error: 41 | return None 42 | ipaddress = IP_address() 43 | 44 | face_cascade_path = '/media/nvidia/96ed93f9-7c40-4999-85ba-3eb24262d0a5/haarcascade_frontalface_default.xml' 45 | face_cascade = cv2.CascadeClassifier(os.path.expanduser(face_cascade_path)) 46 | 47 | scale_factor = 1.1 48 | min_neighbors = 3 49 | min_size = (30, 30) 50 | flags = cv2.CASCADE_SCALE_IMAGE 51 | 52 | print('[') 53 | for infname in sys.argv[1:]: 54 | image_path = os.path.expanduser(infname) 55 | image = cv2.imread(image_path) 56 | gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) 57 | faces = face_cascade.detectMultiScale(gray, scaleFactor = scale_factor, minNeighbors = min_neighbors, minSize = min_size, flags = flags) 58 | print('Faces: {0}'.format(len(faces))) 59 | print('Face {0}'.format(faces)) 60 | for( x, y, w, h ) in faces: 61 | cv2.rectangle(image, (x, y), (x + w, y + h), (255, 255, 0), 2) 62 | outfname = "/media/nvidia/96ed93f9-7c40-4999-85ba-3eb24262d0a5/images/%s.faces.jpg" % os.path.basename(infname) 63 | cv2.imwrite(os.path.expanduser(outfname), image) 64 | endtime= strftime("%Y-%m-%d %H:%M:%S",gmtime()) 65 | # row = { 'ts': currenttime, 'endtime': endtime, 'host': host, 'memory': mempercent, 'diskfree': diskrootfree, 'cputemp': round(ctemp,2), 'ipaddress': ipaddress, 'x': x, 'y': y, 'w': w, 'h': h, 'filename': outfname } 66 | row = { 'ts': currenttime, 'endtime': endtime, 'host': host, 'memory': mempercent, 'diskfree': diskrootfree, 'cputemp': round(ctemp,2), 'ipaddress': ipaddress, 'x': str(x), 'y': str(y), 'w': str(w), 'h': str(h), 'filename': outfname } 67 | 68 | json_string = json.dumps(row) 69 | print(json_string) 70 | print(']') 71 | --------------------------------------------------------------------------------