C++/C stbi_image转cv::Mat

#define stbi_image_
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"
#include "opencv2/opencv.h"

void read_image_buf(char* file_name, int* width, int* height, unsigned char** buf)
{
    int channel;
    *buf = stbi_load(file_name, width, height, &channel, 0);
}

cv::Mat Image2cvMat(int width, int height, int band, unsigned char* buf)
{
    cv::Mat CV_Mat = cv::Mat(height,width, CV_8UC3, (unsigned*)buf);
    return CV_Mat;
}

你可能感兴趣的:(c++,c语言,opencv)