I'm working on a face detection program and I don't understand the following functions:
roi_gray = gray[y:y+h, x:x+w]
roi_color = img[y:y+h, x:x+w]
I'm working on a face detection program and I don't understand the following functions:
roi_gray = gray[y:y+h, x:x+w]
roi_color = img[y:y+h, x:x+w]
as mentioned by @Berriel & @Miki in the comments. ROI stands for region of intrest.
roi_gray = gray[y:y+h, x:x+w]
This slices the gray array. It basically selects row starting with y
till y+h
& column starting with x
till x+w
. This works the same way with roi_color
.
So essentially you are selecting height of gray pixels starting up from y
and going till y+h
(as h denotes height). And selecting width staring from x
pixel and going till x+w
pixels (w denotes width here).
I hope this helps !
Here is the wikipedia link for roi
When you declare the co-ordinates of face by writing
for (x,y,w,h) in faces:
roi_gray=gray[y:y+h,x:x+w] #This particular code will return the cropped face from the image.
roi_color = img[y:y+h, x:x+w] #This particular code will return the details of the image that u will recive after getting the co-ordinates of the image.