33 #include <opencv2/core/core.hpp>
34 #include <opencv2/imgproc/imgproc.hpp>
39 CV_Assert(image.depth() == CV_8U);
40 CV_Assert(image.channels() == 3);
42 int nRows = image.rows;
43 int nCols = image.cols;
46 for(
int r = 0; r < nRows; ++r) {
47 for(
int c = 0; c < nCols; ++c) {
48 Vec3b yuv = image.at<Vec3b>(r, c);
49 if((byte_index % 4) == 0) {
50 img[byte_index++] = yuv.val[1];
52 img[byte_index++] = yuv.val[2];
54 img[byte_index++] = yuv.val[0];
62 cvtColor(image, image, COLOR_BGR2YUV);
70 CV_Assert(image.depth() == CV_8U);
71 CV_Assert(image.channels() == 1);
73 int n_rows = image.rows;
74 int n_cols = image.cols;
77 if (image.isContinuous()) {
87 for (i = 0; i < n_rows; ++i) {
88 p = image.ptr<uchar>(i);
89 for (j = 0; j < n_cols; j++) {
90 img[index_img++] = 127;
91 img[index_img++] =
p[j];
void coloryuv_opencv_to_yuv422(Mat image, char *img, int width, int height)
void grayscale_opencv_to_yuv422(Mat image, char *img, int width, int height)
void colorbgr_opencv_to_yuv422(Mat image, char *img, int width, int height)
A small library with functions to convert between the Paparazzi used YUV422 arrays and the opencv ima...