1

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]
Miki
  • 40,887
  • 13
  • 123
  • 202

2 Answers2

2

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

Kaustubh Lohani
  • 635
  • 5
  • 15
0

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.
David Buck
  • 3,752
  • 35
  • 31
  • 35