In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "python fatigue driving sleepiness bow detection function how to achieve", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "python fatigue driving drowsiness bow detection function how to achieve" it!
Python fatigue driving drowsiness bow detection, the code is as follows:
Def get_head_pose (shape): # head pose estimation # (set of pixel coordinates) fill in 2D reference point # 17 upper left eyebrow / 21 right eyebrow right / 22 upper left eyebrow / 26 upper right eyebrow / 36 upper left eye / 39 upper right eye / 42 upper left eye / # 45 upper right eye / 31 upper left nose / 35 upper right nose / 48 upper left / 54 mouth Upper corner / 57 lower central corner / 8 chin angle image_pts = np.float32 ([shape [17]) Shape [21], shape [22], shape [26], shape [36], shape [39], shape [42], shape [45], shape [31], shape [35], shape [48], shape [54], shape [57], shape [8]) # solvePnP calculate posture-solve rotation and translation matrix: # rotation_vec represents rotation matrix Translation_vec stands for translation matrix, cam_matrix corresponds to K matrix, and dist_coeffs corresponds to D matrix. _, rotation_vec, translation_vec = cv2.solvePnP (object_pts, image_pts, cam_matrix, dist_coeffs) # projectPoints reprojection error: the distance between the original 2d point and the reprojection 2d point (input 3D point, camera internal reference, camera distortion, r, t Output reprojection 2d point) reprojectdst, _ = cv2.projectPoints (reprojectsrc, rotation_vec, translation_vec, cam_matrix, dist_coeffs) reprojectdst = tuple (map (tuple, reprojectdst.reshape (8,2) # display in 8 rows and 2 columns # calculate Euler Angle calc euler angle rotation_mat _ = cv2.Rodrigues (rotation_vec) # Rodriguez formula (convert rotation matrix to rotation vector) pose_mat = cv2.hconcat ((rotation_mat, translation_vec)) # horizontal stitching Vconcat vertical stitching # decomposeProjectionMatrix decomposes the projection matrix into rotation matrix and camera matrix _, euler_angle = cv2.decomposeProjectionMatrix (pose_mat) pitch, yaw Roll = [math.radians (_) for _ in euler_angle] pitch = math.degrees (math.asin (math.sin (pitch)) roll =-math.degrees (math.asin (math.sin (roll) yaw = math.degrees (math.asin (math.sin (yaw)) print ('pitch: {}, yaw: {}, roll: {}' .format (pitch, yaw, roll) return reprojectdst, euler_angle # projection error Euler Angle def eye_aspect_ratio (eye): # Vertical Euclid Mark (XQuery Y) coordinate A = dist.euclidean (eye [1], eye [5]) # calculate the Euclidean distance between two sets B = dist.euclidean (eye [2], eye [4]) # calculate the Euclidean distance between the levels # horizontal Euclidean distance (X Y) coordinates C = dist.euclidean (eye [0], eye [3]) # calculation of eye aspect ratio ear = (A + B) / (2.0 * C) # returns the aspect ratio of the eye return eardef mouth_aspect_ratio (mouth): # mouth A = np.linalg.norm (mouth [2]-mouth [9]) # 51 59 B = np.linalg.norm (mouth [4]-mouth [7]) # 53, 57 C = np.linalg.norm (mouth [0]-mouth [6]) # 49, 55 mar = (A + B) / (2.0 * C) return mar
At this point, I believe you have a deeper understanding of "python fatigue driving drowsiness bow detection function", might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.