From 1c6613b206c60af9daec367c88ca54482d617100 Mon Sep 17 00:00:00 2001 From: slashtechno <77907286+slashtechno@users.noreply.github.com> Date: Sat, 17 Dec 2022 15:54:47 -0600 Subject: [PATCH] Initial commit --- .gitignore | 2 + LICENSE | 21 ++++++ environment.yml | Bin 0 -> 4684 bytes main.py | 177 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 200 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 environment.yml create mode 100644 main.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5f81549 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +person.jpg +config.json \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..36eb93f --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 slashtechno + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/environment.yml b/environment.yml new file mode 100644 index 0000000000000000000000000000000000000000..c8725cc9fb9be14fea7fb56eb2a6f00ed17cc066 GIT binary patch literal 4684 zcmb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t z)b8qK9uB8-nilK0uXkUgb>}kI!T+w#dyT_~^Z}x>*wbBoYITZP6W<-***V5MoBih{ zSA4~qdcNwj%6-5Jc72J>3zeaMx#diKge^`T{w5*Tp=Xq}P4c>!yoP-51no@JJ`=v; z=aTCQ9U|?jGY0K^m6*R`-(Mi&6z{pkNk)Iv)!cWQtSM)}H;@e0n~9iJ$LO{LSv`Xm zf*(0^ah{F-Rk2Fse3s%a|s1v2CTwyV>*z3z!quZT-!SPp|`j;GgwVm9~bAx8* ONvqi@xW+ datetime.timedelta(seconds=5): + print(f"{name} has been seen") + # Update the last seen time + config["faces"][name]["last_seen"] = datetime.datetime.now().strftime( + DATETIME_FORMAT + ) + write_config() + face_names.append(name) + + process_this_frame = not process_this_frame + + # Display the results + # Iterate over each face found in the frame to draw a box around it + # Zip is used to iterate over two lists at the same time + for (top, right, bottom, left), name in zip(face_locations, face_names): + # Scale back up face locations since the frame we detected in was scaled to 1/4 size + top = int(top * (VIEW_SCALE / RUN_SCALE)) + right = int(right * (VIEW_SCALE / RUN_SCALE)) + bottom = int(bottom * (VIEW_SCALE / RUN_SCALE)) + left = int(left * (VIEW_SCALE / RUN_SCALE)) + + # Draw a box around the face + cv2.rectangle(view_frame, (left, top), (right, bottom), (0, 0, 255), 2) + + # Draw a label with a name below the face + cv2.rectangle( + view_frame, (left, bottom - 35), (right, bottom), (0, 0, 255), cv2.FILLED + ) + font = cv2.FONT_HERSHEY_DUPLEX + cv2.putText( + view_frame, name, (left + 6, bottom - 6), font, 1.0, (255, 255, 255), 1 + ) + + # Display the resulting image + cv2.imshow("Scaled View", view_frame) + + # Hit 'q' on the keyboard to quit! + if cv2.waitKey(1) & 0xFF == ord("q"): + break + +# Release handle to the webcam +video_capture.release() +cv2.destroyAllWindows()