chore: move code to main function

This commit is contained in:
Laureηt 2022-11-25 11:20:04 +01:00
parent 434cea77c1
commit 0ed01b9172
No known key found for this signature in database
GPG key ID: D88C6B294FD40994

View file

@ -1,6 +1,11 @@
import logging
import cv2 import cv2
import mediapipe as mp import mediapipe as mp
def main() -> None:
"""Main function."""
mp_drawing = mp.solutions.drawing_utils # type: ignore mp_drawing = mp.solutions.drawing_utils # type: ignore
mp_drawing_styles = mp.solutions.drawing_styles # type: ignore mp_drawing_styles = mp.solutions.drawing_styles # type: ignore
mp_holistic = mp.solutions.holistic # type: ignore mp_holistic = mp.solutions.holistic # type: ignore
@ -22,6 +27,10 @@ with mp_holistic.Holistic(min_detection_confidence=0.5, min_tracking_confidence=
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
results = holistic.process(image) results = holistic.process(image)
# log landmarks
logging.debug(results.face_landmarks)
logging.debug(results.pose_landmarks)
# draw landmark annotation on the image # draw landmark annotation on the image
image.flags.writeable = True image.flags.writeable = True
image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR) image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
@ -46,3 +55,14 @@ with mp_holistic.Holistic(min_detection_confidence=0.5, min_tracking_confidence=
# close webcam # close webcam
cap.release() cap.release()
if __name__ == "__main__":
# setup logging format
logging.basicConfig(
level=logging.DEBUG,
format="%(asctime)s %(name)s %(levelname)-8s %(message)s",
datefmt="(%F %T)",
)
main()