pythonpython-2.xattributeerrordlib

dlib's load_rgb_image() couldn't be found


So I have successfully installed dlib version 18.17.0 that's compatible with Python 2. Classes such as simple_object_detector could be instantiated and returned and instance of the object. But a function called load_rgb_image couldn't be identified and when I called the following code:

import dlib
img = dlib.load_rgb_image(filename)

I got the error:

AttributeError: 'module' object has no attribute 'load_rgb_image'

How to call this function in particular? is it a static function?


Solution

  • dlib 18.17 was released in 2015.

    dlib.load_rgb_image was added in commit e8faced dated April 18, 2018, and shipped in dlib 19.11.

    The diffs for examples in the commit show you the method used before that function was added:

    # Load the image using OpenCV
    bgr_img = cv2.imread(file_path)
    # Convert to RGB since dlib uses RGB images
    img = cv2.cvtColor(bgr_img, cv2.COLOR_BGR2RGB)