Generate a new image with bounding box and circles
Hello, thanks for sharing your code
How to generate a new image with bounding box and circles?
I tried to code: >>> from mtcnn.mtcnn import MTCNN >>> import cv2 >>> >>> img = cv2.imread("max.jpg") >>> detector = MTCNN() >>> print(detector.detect_faces(img)) >>> image = cv2.imwrite("max_drawn.jpg",img)
(max.jpg is my picture)
thank you
Something like this
image = cv2.imread("max.jpg") result = detector.detect_faces(image)
bounding_box = result[0]['box'] keypoints = result[0]['keypoints']
cv2.rectangle(image, (bounding_box[0], bounding_box[1]), (bounding_box[0]+bounding_box[2], bounding_box[1] + bounding_box[3]), (0,155,255), 2) cv2.circle(image,(keypoints['left_eye']), 2, (0,155,255), 2) cv2.circle(image,(keypoints['right_eye']), 2, (0,155,255), 2) cv2.circle(image,(keypoints['nose']), 2, (0,155,255), 2) cv2.circle(image,(keypoints['mouth_left']), 2, (0,155,255), 2) cv2.circle(image,(keypoints['mouth_right']), 2, (0,155,255), 2)
cv2.imwrite("max_drawn.jpg", image) cv2.namedWindow("image") cv2.imshow("image",image) cv2.waitKey(0)
Hello Yes, thank you, i am using plt plot instead of cv.2 imshow but I have solved the problem. Do you mind if i add you on the wechat? I am chinese, but i have been studying in Canada since 2010. My wechat: wangjianzhou159162 谢谢 Maxwell (汪见舟) On Thursday, November 22, 2018, 12:12:24 PM EST, SpeedOfSpin [email protected] wrote:
Something like this
image = cv2.imread("max.jpg") result = detector.detect_faces(image)
bounding_box = result[0]['box'] keypoints = result[0]['keypoints']
cv2.rectangle(image, (bounding_box[0], bounding_box[1]), (bounding_box[0]+bounding_box[2], bounding_box[1] + bounding_box[3]), (0,155,255), 2) cv2.circle(image,(keypoints['left_eye']), 2, (0,155,255), 2) cv2.circle(image,(keypoints['right_eye']), 2, (0,155,255), 2) cv2.circle(image,(keypoints['nose']), 2, (0,155,255), 2) cv2.circle(image,(keypoints['mouth_left']), 2, (0,155,255), 2) cv2.circle(image,(keypoints['mouth_right']), 2, (0,155,255), 2)
cv2.imwrite("max_drawn.jpg", image) cv2.namedWindow("image") cv2.imshow("image",image) cv2.waitKey(0)
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.