Search code examples
pythonrectanglesdlib

Python cant grow dlib rectangle. dlib' has no attribute 'grow_rect'


I have a dlib program that detects a frontal face. Everything works fine. When it finds a face it returns a list of rectangle(s) of faces. I just want to increase the size of the rectangle by a bit (lets say 50%) so it includes not just the face but also hair, neck etc. I tried to use the function from the python dlib docs as shown here, but whne I do i get the error. I tried uninstalling it but the error remains.

Code:

//do some dlib magic above with a cv2 image
//gets a rects list that we go trough
    for rect in rects:
            rect2 =rect
            rect2 =rect2.grow_rect(rect2,100)

I tried every possible cobination of the function but non of them work. What am I missing here? And is there an alternative?

Version: <19.7.0>

Platform: < Win 10 64 bit >

Compiler: <--Python 3.6.4 64 bit visual studio code environment -->


Solution

  • Turns out that the function "grow_rect" has been added in dlib 20.0 and beyond. Anyone who faces this and similar issues should check your dlib version first (especially on windows)