mtcnn icon indicating copy to clipboard operation
mtcnn copied to clipboard

Generate a new image with bounding box and circles

Open Maxwell2016LeChouchou opened this issue 7 years ago • 2 comments

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

Maxwell2016LeChouchou avatar Oct 31 '18 05:10 Maxwell2016LeChouchou

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)

SpeedOfSpin avatar Nov 22 '18 17:11 SpeedOfSpin

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.

Maxwell2016LeChouchou avatar Nov 22 '18 19:11 Maxwell2016LeChouchou