http://stackoverflow.com/questions/38180410/image-convert-to-grayscale
Image convert to grayscale
How can I convert a dlib::array2d to gray Image? The gray Image should be array2d or not? I never see a good dlib documentation.
----------------------------------------------
dlib::array2d is an image already, you can use it for any dlib's image functions
load image:
dlib::array2d<dlib::rgb_pixel> img_rgb;
dlib::load_image(img_rgb, "test_image.jpg");
convert to greyscale:
dlib::array2d<unsigned char> img_gray;
dlib::assign_image(img_gray, img_rgb);
converto to OpenCV Image (cv::Mat):
#include <dlib/opencv.h>
#include <opencv2/opencv.hpp>
cv::Mat img = dlib::toMat(img_gray);
get image from OpenCV:
#include <dlib/opencv.h>
#include <opencv2/opencv.hpp>
cv::Mat img = cv::imread("test_image.jpg")
dlib::cv_image<rgb_pixel> dlib_img(img); // only stores pointer, no deep copy
Documentation is here. There are a lot of well-documented examples, you should start from them. Special example about array2d
'C,C++ > DLib' 카테고리의 다른 글
dlib으로 나만의 shape predictor를 만들자 (dlib에서 train_shape_predictor_ex.cpp실행하는 방법) (0) | 2018.06.06 |
---|---|
Shape predictor .dat file for 194 facelandmarks (helen dataset), dlib, 81 points (0) | 2018.05.16 |
DLIB : Training Shape_predictor for 194 landmarks (helen dataset) (0) | 2016.09.28 |
[dlib]Compile dlib on Windows (0) | 2016.09.21 |
dlib to the Windows / Visual Studio environment (0) | 2016.09.12 |