How to crop face from a photo using cv2 in python

0 votes

Hi Guys,

I am working in a project where I need to crop face from a photo for Machine Learning. Can anyone tell me, how can I do that in python?

Thank You

Apr 9, 2020 in Python by akhtar
• 38,260 points
887 views

1 answer to this question.

0 votes

Hi@akhtar,

You can do this task using cv2 module in python. Use the below given code.

import cv2
photo = cv2.imread('img1.png')
photo1 = photo[140:500, 780:1050] 
cv2.imshow('My Photo', photo1)
cv2.waitKey()
cv2.destroyAllWindows()

Before running this code, make sure you change dimensions according to your need.

Hope this will work.

answered Apr 9, 2020 by MD
• 95,460 points

Related Questions In Python

0 votes
1 answer

Shortest path from source to and from a negative cycle using Bellman Ford in Python

class NegativeWeightFinder: def __init__(self, graph: nx.Graph): ...READ MORE

answered Nov 13, 2018 in Python by Nymeria
• 3,560 points
1,323 views
0 votes
3 answers

How to get the return value from a thread using python?

FWIW, the multiprocessing module has a nice interface for ...READ MORE

answered Dec 15, 2020 in Python by Roshni
• 10,480 points
107,695 views
0 votes
1 answer

How to correctly return an a dictionary as an output in zappier code using python?

David here, from the Zapier Platform team. ...READ MORE

answered Dec 3, 2018 in Python by charlie_brown
• 7,720 points
1,638 views
0 votes
0 answers

How to implement multiple try codes in a single block using Python?

Hi all, As per the title, I am ...READ MORE

Jan 14, 2019 in Python by Anirudh
• 2,090 points
661 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,422 views
0 votes
1 answer
0 votes
1 answer

video streaming using cv2 module in python.

Hi@akhtar, Yes, you can use cv2 module for ...READ MORE

answered Apr 15, 2020 in Python by MD
• 95,460 points
823 views
0 votes
1 answer

How to read photo using cv2 module in python?

Hi@akhtar, Yes, you can read your image in ...READ MORE

answered Apr 9, 2020 in Python by MD
• 95,460 points
735 views
0 votes
1 answer

How to transfer multiple lines in a file using python?

Hi@akhtar, I don't know it will help you ...READ MORE

answered Mar 31, 2020 in Python by MD
• 95,460 points
1,132 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP