당신은 이미지를 dlib하는 매트에서 변환 할 cv_image을 사용할 수 있으며 dlib::toMat는 매트 dlib 변환 할 수 있습니다.
//Mat to dlib image
cv_image<bgr_pixel> dlib_img(mat);
편집 :
는 지금까지 내가 알고, N 채널 매트에 대한 사용자 정의 pixel_traits
을 제공했습니다. 예를 들어, 5 채널 매트 이미지를 당신이 할 수 있습니다 : 다음
namespace dlib{
struct custom_pixel
{
custom_pixel (
) {}
custom_pixel (
unsigned char c1_,
unsigned char c2_,
unsigned char c3_,
unsigned char c4_,
unsigned char c5_
) : c1(c1_), c2(c2_), c3(c3_), c4(c4_), c5(c5_) {}
unsigned char c1;
unsigned char c2;
unsigned char c3;
unsigned char c4;
unsigned char c5;
};
template <>
struct pixel_traits<custom_pixel>
{
constexpr static bool rgb = false;
constexpr static bool rgb_alpha = false;
constexpr static bool grayscale = false;
constexpr static bool hsi = false;
constexpr static bool lab = false;
enum { num = 5};// provide number of channels here
typedef unsigned char basic_pixel_type; //provide channel depth here
static basic_pixel_type min() { return 0;}
static basic_pixel_type max() { return 255;}
constexpr static bool is_unsigned = true;
constexpr static bool has_alpha = false;
};
}
는 dlib 그 반대에 매트로 변환하는 반대 :
int main(int argc, char** argv)
{
// from opencv to dlib
Mat mat_img = Mat::zeros(3, 3, CV_8UC(5));
cv_image<custom_pixel> dlib_img(mat_img);
//from dlib to opencv
Mat mat_img_new = dlib::toMat(dlib_img);
}
bgr_pixel가 있기 때문에 당신이 적용되지 않습니다 무엇을 쓰기 위 3 채널 이미지, 192 채널로 이미지/매트릭스 변환이 필요합니다. – gulliver
@ gulliver 편집을 참조하십시오. – zindarod
나는 이것과 비슷한 것을 시도했지만, dlib는 다음에 뭔가가 필요하다. 이 위의 cv_image 변환하지만 dlib :: matrix.When 시도 변환 : cv_image cimg (매트), 매트릭스 dm, assign_image (dm, cimg); 다음과 같은 오류가 발생합니다 : '(dlib :: big_pixel & const const dlib :: big_pixel &)'할당에 대한 호출에 일치하는 함수 없음 {assign_pixel_helpers :: assign (dest, src); } –
gulliver