dlib | making real world machine learning and data analysis | Machine Learning library

 by   davisking C++ Version: 19.24.4 License: BSL-1.0

kandi X-RAY | dlib Summary

kandi X-RAY | dlib Summary

dlib is a C++ library typically used in Artificial Intelligence, Machine Learning, Deep Learning, OpenCV applications. dlib has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.

Dlib is a modern C++ toolkit containing machine learning algorithms and tools for creating complex software in C++ to solve real world problems. See for the main project documentation and API reference.

            kandi-support Support

              dlib has a medium active ecosystem.
              It has 11993 star(s) with 3215 fork(s). There are 474 watchers for this library.
              There were 1 major release(s) in the last 6 months.
              There are 35 open issues and 2091 have been closed. On average issues are closed in 42 days. There are 3 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of dlib is 19.24.4

            kandi-Quality Quality

              dlib has 0 bugs and 0 code smells.

            kandi-Security Security

              dlib has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              dlib code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              dlib is licensed under the BSL-1.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              dlib releases are available to install and integrate.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of dlib
            Get all kandi verified functions for this library.

            dlib Key Features

            No Key Features are available at this moment for dlib.

            dlib Examples and Code Snippets

            Why such different answers for the xgboost scikit-learn interface?
            Pythondot img1Lines of Code : 8dot img1License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            cross_val_score(xgbr, X, y, cv=5, scoring = 'neg_root_mean_squared_error')
            from sklearn.model_selection import KFold
            cv_results =  xgb.cv(dtrain=dmatrix, params=params, metrics={'rmse'}, folds = KFold(n_splits=5))
            "ERROR: CMake must be installed to build dlib" when installing face_recognition
            Pythondot img2Lines of Code : 2dot img2License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            ERROR: CMake must be installed to build dlib
            Mediapipe Crop Images
            Pythondot img3Lines of Code : 24dot img3License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import dlib
            from PIL import Image
            from skimage import io
            h, w, c = sample_img.shape
            print('width:  ', w)
            print('height: ', h)
            xleft = data.xmin*w
            xleft = int(xleft)
            xtop = data.ymin*h
            Sorting a tensor list in ascending order
            Pythondot img4Lines of Code : 8dot img4License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            namestodistance = [('Alice', .1), ('Bob', .3), ('Carrie', .2)]
            names_top = sorted(namestodistance, key=lambda x: x[1])
            namestodistance = list(map(lambda x: (x[0], x[1].item()), namestodistance)
            is possible to face recognition with mediapipe in python
            Pythondot img5Lines of Code : 2dot img5License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            locations = face_recognition.face_locations(frame, model="hog")
            Head Pose Estimation Using Facial Landmarks
            Pythondot img6Lines of Code : 18dot img6License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            face3Dmodel = np.array([
                (0.0, 0.0, 0.0),            # Nose tip
                (0.0, -330.0, -65.0),       # Chin
                (-225.0, 170.0, -135.0),    # Left eye left corner
                (225.0, 170.0, -135.0),     # Right eye right corner
                (-150.0, -150.0,
            My server is not responding, it is hanging up, did not returning anything
            Pythondot img7Lines of Code : 2dot img7License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            CMD python3 manage.py migrate && python3 manage.py runserver
            How can I fix Face Recognition operands error?
            Pythondot img8Lines of Code : 2dot img8License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            matches = face_recognition.compare_faces(known_face_encodings, face_encoding)
            TypeError: __init__(): incompatible constructor arguments with face_recognition call
            Pythondot img9Lines of Code : 3dot img9License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            for (top, right, bottom, left), name in zip(faceLocations, faceNames):
               cv2.rectangle(img, int(left)-20, int(top)-20, int(right)+20, int(bottom)+20), (255, 0, 0), cv2.FILLED)
            copy iconCopy
            akaze = cv2.AKAZE_create()

            Community Discussions


            Cannot install face_recognition using pip install face_recognition on Win10
            Asked 2022-Apr-04 at 09:48

            I get the error

            Running setup.py install for dlib ... error error: subprocess-exited-with-error

            × Running setup.py install for dlib did not run successfully. │ exit code: 1 ╰─> [58 lines of output] running install running build running build_py package init file 'tools\python\dlib_init_.py' not found (or not a regular file) running build_ext Building extension for Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)] Invoking CMake setup: 'cmake C:\Users\amade\AppData\Local\Temp\pip-install-_k5e982w\dlib_237006073dfd4b13993bf60b7ecb3629\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\amade\AppData\Local\Temp\pip-install-_k5e982w\dlib_237006073dfd4b13993bf60b7ecb3629\build\lib.win-amd64-3.10 -DPYTHON_EXECUTABLE=C:\Users\amade\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\amade\AppData\Local\Temp\pip-install-_k5e982w\dlib_237006073dfd4b13993bf60b7ecb3629\build\lib.win-amd64-3.10 -A x64' -- Building for: Visual Studio 17 2022 -- Selecting Windows SDK version to target Windows 10.0.19044. -- The C compiler identification is unknown -- The CXX compiler identification is unknown CMake Error at CMakeLists.txt:14 (project): No CMAKE_C_COMPILER could be found.



            Answered 2022-Apr-03 at 09:50

            Follow the steps below to install face_recognition python package on Windows 10.

            The instruction has been tested on Windows 10 64bit, python 3.9.

            Step 1

            Download CMake installation package for your OS from official site

            Step 2

            Install downloaded CMake installation package. Please make sure that Add CMake to system PATH option has been selected during the installation.

            Step 3

            Reboot your OS (restart computer)

            Step 4

            Run pip install dlib It tooks several minutes so be prepared to wait

            Step 5

            If it completes without any errors, you're all set. Run pip install face_recognition to install face_recognition.


            Source https://stackoverflow.com/questions/71717231


            how to extract self-defined ROI with dlib facelandmarks?
            Asked 2022-Mar-29 at 10:31

            I don't know how to extract the irregular area surrounded by green lines. i.e., the left cheek and the right cheek of a face.



            Answered 2022-Mar-29 at 10:31

            You can accomplish this by two simple steps:

            1. Create a mask using the point coordinates you have
            2. Execute bitwise_and operation (crop)


            Source https://stackoverflow.com/questions/71659570


            Why such different answers for the xgboost scikit-learn interface?
            Asked 2022-Mar-21 at 22:59

            I am using xgboost for the first time and trying the two different interfaces. First I get the data:



            Answered 2022-Mar-21 at 22:59

            First of all, you didn't specify the metric in cross_val_score, therefore you are not calculating RMSE, but rather the estimator's default metric, which is usually just its loss function. You need to specify it for comparable results:

            Source https://stackoverflow.com/questions/71562186


            Recreating Global 3D Points, from Local 3D Points and Global 2D Points; SolvePnP
            Asked 2022-Mar-11 at 08:38

            Aloha, i have a list of 2D Keypoints which are located in the global scope/frame (image points), and a list of corresponding 3D Keypoints in the local scope (often called texture or object points). The image points are ranging from x[0-1920]y[0,1080] and the object points are withing the range of x[-1,1]y[-1,1]. I have followed the approach described in this paper on page 6 with the tutorial from here, but the output of my 3D points is not correct at all, the movement of the points is all over the place. Below is my approach using SolvePnP. Am I on the wrong track here, since SolvePnP is normally used for detecting the camera movement (open for other suggestions!) or is my method wrong?



            Answered 2022-Mar-09 at 13:13
            1. yes, solvePnP is okay to use
            2. yes, your math is wrong

            I'll assume that you get your points from a face landmark detector, so they have a fixed order. I'll also assume that your 3D model points are given in the same order and their values are consistent and somewhat similar to the face you look at. You should exclude points that denote flesh and mandible (as opposed to skull bone). You actually want to track the skull, not the position of lips and jaws that move all over the place.

            rvec is an axis-angle encoding. Its length is the amount of rotation (expected between 0 and 3.14=pi) and its direction is the axis of rotation.

            Use cv.Rodrigues to turn the rvec into a 3x3 rotation matrix.

            In fact, just build yourself some functions that take rvec and tvec and build a 4x4 matrix. Extending all points to be (x,y,z,1) is a hassle but only once.

            And make sure you use @ for matrix multiplication (or np.dot, np.matmul, ...) because * is element-wise multiplication.

            Source https://stackoverflow.com/questions/71408443


            "ERROR: CMake must be installed to build dlib" when installing face_recognition
            Asked 2022-Mar-01 at 22:50

            I'm facing this error while installing face_recognition in a virtualenv with Python 3.8.10 on Ubuntu 20.04.



            Answered 2022-Mar-01 at 22:49
            ERROR: CMake must be installed to build dlib

            Source https://stackoverflow.com/questions/71315443


            dlib import failure on M1 pro
            Asked 2022-Jan-26 at 15:04

            after installing dlib successfully on my m1 pro mac (monterey 12.1)

            whenever I try to import dlib, I am receiving the following error:



            Answered 2022-Jan-26 at 15:04

            installing dlib==19.23.0 solves this issue

            Source https://stackoverflow.com/questions/70771196


            Bounding boxes returned without detected face image in dlib python
            Asked 2022-Jan-18 at 13:43

            I'm trying to detect multiple faces in a picture using the deepface library with dlib as the backend detector. I'm using the DlibWrapper.py from the deeepface library and i have the following issue: In some cases, the detector returns the bounding box coordinates but doesn't return the detected face image detected face-box coordinates.

            I was wondering if this bug occurs because of the negative values of some coordinates of the bounding boxes but i figured out that was not the case, as the negative values are features, not bugs. Here is the DlibWrapper from the deepface library.



            Answered 2022-Jan-18 at 13:43

            Solved!There are edge cases where original rectangle is partially outside the image window. That happens with dlib. So, instead of

            • detected_face = img[top:bottom, left:right],

            the detected face should be

            • detected_face = img[max(0, top): min(bottom, img_height), max(0, left): min(right, img_width)]

            Source https://stackoverflow.com/questions/70754730


            Overloading member operator,?
            Asked 2021-Dec-26 at 19:01
            struct Matrix;
            struct literal_assignment_helper
                mutable int r;
                mutable int c;
                Matrix& matrix;
                explicit literal_assignment_helper(Matrix& matrix)
                        : matrix(matrix), r(0), c(1) {}
                const literal_assignment_helper& operator,(int number) const;
            struct Matrix
                int rows;
                int columns;
                std::vector numbers;
                Matrix(int rows, int columns)
                    : rows(rows), columns(columns), numbers(rows * columns) {}
                literal_assignment_helper operator=(int number)
                    numbers[0] = number;
                    return literal_assignment_helper(*this);
                int* operator[](int row) { return &numbers[row * columns]; }
            const literal_assignment_helper& literal_assignment_helper::operator,(int number) const
                matrix[r][c] = number;
                if (c == matrix.columns)
                    r++, c = 0;
                return *this;
            int main()
                int rows = 3, columns = 3;
                Matrix m(rows, columns);
                m = 1, 2, 3,
                    4, 5, 6,
                    7, 8, 9;
                for (int i = 0; i < rows; i++)
                    for (int j = 0; j < columns; j++)
                        std::cout << m[i][j] << ' ';
                    std::cout << std::endl;


            Answered 2021-Dec-26 at 19:01
            const literal_assignment_helper& operator,(int number) const;

            Source https://stackoverflow.com/questions/70489004


            Sorting a tensor list in ascending order
            Asked 2021-Dec-05 at 21:29

            I am working on a facial comparison app that will give me the closest n number of faces to my target face.

            I have done this with dlib/face_recognition as it uses numpy arrays, however i am now trying to do the same thing with facenet/pytorch and running into an issue because it uses tensors.

            I have created a database of embeddings and I am giving the function one picture to compare to them. What i would like is for it to sort the list from lowest distances to highest, and give me the lowest 5 results or so.

            here is the code I am working on that is doing the comparison. at this point i am feeding it a photo and asking it to compare against the embedding database.



            Answered 2021-Dec-05 at 16:43

            Unfortunately I cannot test your code, but to me it seems like you are operation on a python list of tuples. You can sort that by using a key:

            Source https://stackoverflow.com/questions/70232894


            How to shrink/expand facial features using Opencv?
            Asked 2021-Nov-10 at 06:09

            I'm trying write an application make parts of face image bigger or smaller with opencv and dlib. I detect facial landmarks using shape_predictor_68_face_landmarks.dat. In the following function, the tmp variable is supposed to be transformed in such a way that scale nose or left eye on image.



            Answered 2021-Nov-10 at 06:09
            Update #1

            Applying pinch and bulge distortion along facial landmarks in small amounts around eyes and nose could probably provide decent results without moving into another method. Though there is a chance it will also noticeably distort eyeglasses if it affects a larger area. These should help,

            I am not sure how to do this in opencv alone without face looking unnatural. Below is a general explanation based on my own exploration. Feel free to correct me if anything if I made any mistake.

            3D Mesh

            One way I think current face beautification methods such as those on Android cameras work is to align a 3d face mesh or a whole head model on top of original face.

            It extracts face texture using using facial landmarks and aligns them with corresponding 3d mesh with texture applied to it. This way the 3d mesh can be adjusted and texture will follow face geometry. There are probably additional steps such as passing the result to another network, post-processing involved to make it look more natural.

            Mediapipe Face Mesh will probably be helpful also as it provides dense 3d face landmarks with 3D face models, UV visualization, coordinates. This is a discussion for UV unwrapping of face in mediapipe.

            Example from, https://github.com/YadiraF/DECA.

            Example from, https://github.com/sicxu/Deep3DFaceRecon_pytorch.


            Another way is to use GANs to edit facial features, apply lighting, makeup etc.

            Example from, https://github.com/run-youngjoo/SC-FEGAN.

            Another example, https://github.com/genforce/idinvert_pytorch.

            Source https://stackoverflow.com/questions/69887034

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network


            No vulnerabilities reported

            Install dlib

            You can download it from GitHub.


            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
          • PyPI

            pip install dlib

          • CLONE
          • HTTPS


          • CLI

            gh repo clone davisking/dlib

          • sshUrl


          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link