怎么运行/opencv/modules/imgproc/test下的test_cvtyuv.cpp

怎么运行/opencv/modules/imgproc/test下的test_cvtyuv.cpp

要运行test_cvtyuv.cpp,你需要按照以下步骤操作:

  1. 获取OpenCV源代码,编译并安装opencv:首先,确保你已经下载并安装了OpenCV。如果没有,请前往OpenCV官方网站下载源代码。安装参考连接:https://blog.csdn.net/shizuguilai/article/details/136406722

  2. 运行测试:在构建build目录中,你可以运行测试程序。使用以下命令:

    ./bin/opencv_test_imgproc --gtest_filter=cvtyuv.*
    # 或者是下面这样?
    ./bin/opencv_test_imgproc --gtest_filter=*ColorYUV* # 运行特定的颜色转换测试
    # 或者试试下面这个?注意!下面是gtestp不是gtest
    ./bin/opencv_test_imgproc --gtestp_filter=Imgproc_ColorYUV.accuracy
    

    这将运行与cvtyuv相关的所有测试用例。因为test_cvtyuv.cpp本身并不包含主函数(main),因为它是设计来被 OpenCV 的测试框架自动发现和执行的。测试框架(基于 Google Test)会自动识别 TEST_P 宏定义的测试用例并执行它们。

请注意,确保你的构建环境已经正确设置,以便能够编译和运行OpenCV。如果你遇到问题,可以查看OpenCV官方文档或在社区寻求帮助。

祝你好运!🚀

test_cvtyuv.cpp源码如下:

#include "test_precomp.hpp"namespace opencv_test { namespace {#undef RGB
#undef YUVtypedef Vec3b YUV;
typedef Vec3b RGB;int countOfDifferencies(const Mat& gold, const Mat& result, int maxAllowedDifference = 1)
{Mat diff;absdiff(gold, result, diff);return countNonZero(diff.reshape(1) > maxAllowedDifference);
}class YUVreader
{
public:virtual ~YUVreader() {}virtual YUV read(const Mat& yuv, int row, int col) = 0;virtual int channels() = 0;virtual Size size(Size imgSize) = 0;virtual bool requiresEvenHeight() { return true; }virtual bool requiresEvenWidth() { return true; }static YUVreader* getReader(int code);
};class RGBreader
{
public:virtual ~RGBreader() {}virtual RGB read(const Mat& rgb, int row, int col) = 0;virtual int channels() = 0;static RGBreader* getReader(int code);
};class RGBwriter
{
public:virtual ~RGBwriter() {}virtual void write(Mat& rgb, int row, int col, const RGB& val) = 0;virtual int channels() = 0;static RGBwriter* getWriter(int code);
};class GRAYwriter
{
public:virtual ~GRAYwriter() {}virtual void write(Mat& gray, int row, int col, const uchar& val){gray.at<uchar>(row, col) = val;}virtual int channels() { return 1; }static GRAYwriter* getWriter(int code);
};class YUVwriter
{
public:virtual ~YUVwriter() {}virtual void write(Mat& yuv, int row, int col, const YUV& val) = 0;virtual int channels() = 0;virtual Size size(Size imgSize) = 0;virtual bool requiresEvenHeight() { return true; }virtual bool requiresEvenWidth() { return true; }static YUVwriter* getWriter(int code);
};class RGB888Writer : public RGBwriter
{void write(Mat& rgb, int row, int col, const RGB& val){rgb.at<Vec3b>(row, col) = val;}int channels() { return 3; }
};class BGR888Writer : public RGBwriter
{void write(Mat& rgb, int row, int col, const RGB& val){Vec3b tmp(val[2], val[1], val[0]);rgb.at<Vec3b>(row, col) = tmp;}int channels() { return 3; }
};class RGBA8888Writer : public RGBwriter
{void write(Mat& rgb, int row, int col, const RGB& val){Vec4b tmp(val[0], val[1], val[2], 255);rgb.at<Vec4b>(row, col) = tmp;}int channels() { return 4; }
};class BGRA8888Writer : public RGBwriter
{void write(Mat& rgb, int row, int col, const RGB& val){Vec4b tmp(val[2], val[1], val[0], 255);rgb.at<Vec4b>(row, col) = tmp;}int channels() { return 4; }
};class YUV420pWriter: public YUVwriter
{int channels() { return 1; }Size size(Size imgSize) { return Size(imgSize.width, imgSize.height + imgSize.height/2); }
};class YV12Writer: public YUV420pWriter
{void write(Mat& yuv, int row, int col, const YUV& val){int h = yuv.rows * 2 / 3;yuv.ptr<uchar>(row)[col] = val[0];if( row % 2 == 0 && col % 2 == 0 ){yuv.ptr<uchar>(h + row/4)[col/2 + ((row/2) % 2) * (yuv.cols/2)] = val[2];yuv.ptr<uchar>(h + (row/2 + h/2)/2)[col/2 + ((row/2 + h/2) % 2) * (yuv.cols/2)] = val[1];}}
};class I420Writer: public YUV420pWriter
{void write(Mat& yuv, int row, int col, const YUV& val){int h = yuv.rows * 2 / 3;yuv.ptr<uchar>(row)[col] = val[0];if( row % 2 == 0 && col % 2 == 0 ){yuv.ptr<uchar>(h + row/4)[col/2 + ((row/2) % 2) * (yuv.cols/2)] = val[1];yuv.ptr<uchar>(h + (row/2 + h/2)/2)[col/2 + ((row/2 + h/2) % 2) * (yuv.cols/2)] = val[2];}}
};class YUV420Reader: public YUVreader
{int channels() { return 1; }Size size(Size imgSize) { return Size(imgSize.width, imgSize.height * 3 / 2); }
};class YUV422Reader: public YUVreader
{int channels() { return 2; }Size size(Size imgSize) { return imgSize; }bool requiresEvenHeight() { return false; }
};class NV21Reader: public YUV420Reader
{YUV read(const Mat& yuv, int row, int col){uchar y = yuv.ptr<uchar>(row)[col];uchar u = yuv.ptr<uchar>(yuv.rows * 2 / 3 + row/2)[(col/2)*2 + 1];uchar v = yuv.ptr<uchar>(yuv.rows * 2 / 3 + row/2)[(col/2)*2];return YUV(y, u, v);}
};struct NV12Reader: public YUV420Reader
{YUV read(const Mat& yuv, int row, int col){uchar y = yuv.ptr<uchar>(row)[col];uchar u = yuv.ptr<uchar>(yuv.rows * 2 / 3 + row/2)[(col/2)*2];uchar v = yuv.ptr<uchar>(yuv.rows * 2 / 3 + row/2)[(col/2)*2 + 1];return YUV(y, u, v);}
};class YV12Reader: public YUV420Reader
{YUV read(const Mat& yuv, int row, int col){int h = yuv.rows * 2 / 3;uchar y = yuv.ptr<uchar>(row)[col];uchar u = yuv.ptr<uchar>(h + (row/2 + h/2)/2)[col/2 + ((row/2 + h/2) % 2) * (yuv.cols/2)];uchar v = yuv.ptr<uchar>(h + row/4)[col/2 + ((row/2) % 2) * (yuv.cols/2)];return YUV(y, u, v);}
};class IYUVReader: public YUV420Reader
{YUV read(const Mat& yuv, int row, int col){int h = yuv.rows * 2 / 3;uchar y = yuv.ptr<uchar>(row)[col];uchar u = yuv.ptr<uchar>(h + row/4)[col/2 + ((row/2) % 2) * (yuv.cols/2)];uchar v = yuv.ptr<uchar>(h + (row/2 + h/2)/2)[col/2 + ((row/2 + h/2) % 2) * (yuv.cols/2)];return YUV(y, u, v);}
};class UYVYReader: public YUV422Reader
{YUV read(const Mat& yuv, int row, int col){uchar y = yuv.ptr<Vec2b>(row)[col][1];uchar u = yuv.ptr<Vec2b>(row)[(col/2)*2][0];uchar v = yuv.ptr<Vec2b>(row)[(col/2)*2 + 1][0];return YUV(y, u, v);}
};class YUY2Reader: public YUV422Reader
{YUV read(const Mat& yuv, int row, int col){uchar y = yuv.ptr<Vec2b>(row)[col][0];uchar u = yuv.ptr<Vec2b>(row)[(col/2)*2][1];uchar v = yuv.ptr<Vec2b>(row)[(col/2)*2 + 1][1];return YUV(y, u, v);}
};class YVYUReader: public YUV422Reader
{YUV read(const Mat& yuv, int row, int col){uchar y = yuv.ptr<Vec2b>(row)[col][0];uchar u = yuv.ptr<Vec2b>(row)[(col/2)*2 + 1][1];uchar v = yuv.ptr<Vec2b>(row)[(col/2)*2][1];return YUV(y, u, v);}
};class YUV888Reader : public YUVreader
{YUV read(const Mat& yuv, int row, int col){return yuv.at<YUV>(row, col);}int channels() { return 3; }Size size(Size imgSize) { return imgSize; }bool requiresEvenHeight() { return false; }bool requiresEvenWidth() { return false; }
};class RGB888Reader : public RGBreader
{RGB read(const Mat& rgb, int row, int col){return rgb.at<RGB>(row, col);}int channels() { return 3; }
};class BGR888Reader : public RGBreader
{RGB read(const Mat& rgb, int row, int col){RGB tmp = rgb.at<RGB>(row, col);return RGB(tmp[2], tmp[1], tmp[0]);}int channels() { return 3; }
};class RGBA8888Reader : public RGBreader
{RGB read(const Mat& rgb, int row, int col){Vec4b rgba = rgb.at<Vec4b>(row, col);return RGB(rgba[0], rgba[1], rgba[2]);}int channels() { return 4; }
};class BGRA8888Reader : public RGBreader
{RGB read(const Mat& rgb, int row, int col){Vec4b rgba = rgb.at<Vec4b>(row, col);return RGB(rgba[2], rgba[1], rgba[0]);}int channels() { return 4; }
};class YUV2RGB_Converter
{
public:RGB convert(YUV yuv){int y = std::max(0, yuv[0] - 16);int u = yuv[1] - 128;int v = yuv[2] - 128;uchar r = saturate_cast<uchar>(1.164f * y + 1.596f * v);uchar g = saturate_cast<uchar>(1.164f * y - 0.813f * v - 0.391f * u);uchar b = saturate_cast<uchar>(1.164f * y + 2.018f * u);return RGB(r, g, b);}
};class YUV2GRAY_Converter
{
public:uchar convert(YUV yuv){return yuv[0];}
};class RGB2YUV_Converter
{
public:YUV convert(RGB rgb){int r = rgb[0];int g = rgb[1];int b = rgb[2];uchar y = saturate_cast<uchar>((int)( 0.257f*r + 0.504f*g + 0.098f*b + 0.5f) + 16);uchar u = saturate_cast<uchar>((int)(-0.148f*r - 0.291f*g + 0.439f*b + 0.5f) + 128);uchar v = saturate_cast<uchar>((int)( 0.439f*r - 0.368f*g - 0.071f*b + 0.5f) + 128);return YUV(y, u, v);}
};YUVreader* YUVreader::getReader(int code)
{switch(code){case COLOR_YUV2RGB_NV12:case COLOR_YUV2BGR_NV12:case COLOR_YUV2RGBA_NV12:case COLOR_YUV2BGRA_NV12:return new NV12Reader();case COLOR_YUV2RGB_NV21:case COLOR_YUV2BGR_NV21:case COLOR_YUV2RGBA_NV21:case COLOR_YUV2BGRA_NV21:return new NV21Reader();case COLOR_YUV2RGB_YV12:case COLOR_YUV2BGR_YV12:case COLOR_YUV2RGBA_YV12:case COLOR_YUV2BGRA_YV12:return new YV12Reader();case COLOR_YUV2RGB_IYUV:case COLOR_YUV2BGR_IYUV:case COLOR_YUV2RGBA_IYUV:case COLOR_YUV2BGRA_IYUV:return new IYUVReader();case COLOR_YUV2RGB_UYVY:case COLOR_YUV2BGR_UYVY:case COLOR_YUV2RGBA_UYVY:case COLOR_YUV2BGRA_UYVY:return new UYVYReader();//case COLOR_YUV2RGB_VYUY = 109,//case COLOR_YUV2BGR_VYUY = 110,//case COLOR_YUV2RGBA_VYUY = 113,//case COLOR_YUV2BGRA_VYUY = 114,//    return ??case COLOR_YUV2RGB_YUY2:case COLOR_YUV2BGR_YUY2:case COLOR_YUV2RGBA_YUY2:case COLOR_YUV2BGRA_YUY2:return new YUY2Reader();case COLOR_YUV2RGB_YVYU:case COLOR_YUV2BGR_YVYU:case COLOR_YUV2RGBA_YVYU:case COLOR_YUV2BGRA_YVYU:return new YVYUReader();case COLOR_YUV2GRAY_420:return new NV21Reader();case COLOR_YUV2GRAY_UYVY:return new UYVYReader();case COLOR_YUV2GRAY_YUY2:return new YUY2Reader();case COLOR_YUV2BGR:case COLOR_YUV2RGB:return new YUV888Reader();default:return 0;}
}RGBreader* RGBreader::getReader(int code)
{switch(code){case COLOR_RGB2YUV_YV12:case COLOR_RGB2YUV_I420:return new RGB888Reader();case COLOR_BGR2YUV_YV12:case COLOR_BGR2YUV_I420:return new BGR888Reader();case COLOR_RGBA2YUV_I420:case COLOR_RGBA2YUV_YV12:return new RGBA8888Reader();case COLOR_BGRA2YUV_YV12:case COLOR_BGRA2YUV_I420:return new BGRA8888Reader();default:return 0;};
}RGBwriter* RGBwriter::getWriter(int code)
{switch(code){case COLOR_YUV2RGB_NV12:case COLOR_YUV2RGB_NV21:case COLOR_YUV2RGB_YV12:case COLOR_YUV2RGB_IYUV:case COLOR_YUV2RGB_UYVY://case COLOR_YUV2RGB_VYUY:case COLOR_YUV2RGB_YUY2:case COLOR_YUV2RGB_YVYU:case COLOR_YUV2RGB:return new RGB888Writer();case COLOR_YUV2BGR_NV12:case COLOR_YUV2BGR_NV21:case COLOR_YUV2BGR_YV12:case COLOR_YUV2BGR_IYUV:case COLOR_YUV2BGR_UYVY://case COLOR_YUV2BGR_VYUY:case COLOR_YUV2BGR_YUY2:case COLOR_YUV2BGR_YVYU:case COLOR_YUV2BGR:return new BGR888Writer();case COLOR_YUV2RGBA_NV12:case COLOR_YUV2RGBA_NV21:case COLOR_YUV2RGBA_YV12:case COLOR_YUV2RGBA_IYUV:case COLOR_YUV2RGBA_UYVY://case COLOR_YUV2RGBA_VYUY:case COLOR_YUV2RGBA_YUY2:case COLOR_YUV2RGBA_YVYU:return new RGBA8888Writer();case COLOR_YUV2BGRA_NV12:case COLOR_YUV2BGRA_NV21:case COLOR_YUV2BGRA_YV12:case COLOR_YUV2BGRA_IYUV:case COLOR_YUV2BGRA_UYVY://case COLOR_YUV2BGRA_VYUY:case COLOR_YUV2BGRA_YUY2:case COLOR_YUV2BGRA_YVYU:return new BGRA8888Writer();default:return 0;};
}GRAYwriter* GRAYwriter::getWriter(int code)
{switch(code){case COLOR_YUV2GRAY_420:case COLOR_YUV2GRAY_UYVY:case COLOR_YUV2GRAY_YUY2:return new GRAYwriter();default:return 0;}
}YUVwriter* YUVwriter::getWriter(int code)
{switch(code){case COLOR_RGB2YUV_YV12:case COLOR_BGR2YUV_YV12:case COLOR_RGBA2YUV_YV12:case COLOR_BGRA2YUV_YV12:return new YV12Writer();case COLOR_RGB2YUV_I420:case COLOR_BGR2YUV_I420:case COLOR_RGBA2YUV_I420:case COLOR_BGRA2YUV_I420:return new I420Writer();default:return 0;};
}template<class convertor>
void referenceYUV2RGB(const Mat& yuv, Mat& rgb, YUVreader* yuvReader, RGBwriter* rgbWriter)
{convertor cvt;for(int row = 0; row < rgb.rows; ++row)for(int col = 0; col < rgb.cols; ++col)rgbWriter->write(rgb, row, col, cvt.convert(yuvReader->read(yuv, row, col)));
}template<class convertor>
void referenceYUV2GRAY(const Mat& yuv, Mat& rgb, YUVreader* yuvReader, GRAYwriter* grayWriter)
{convertor cvt;for(int row = 0; row < rgb.rows; ++row)for(int col = 0; col < rgb.cols; ++col)grayWriter->write(rgb, row, col, cvt.convert(yuvReader->read(yuv, row, col)));
}template<class convertor>
void referenceRGB2YUV(const Mat& rgb, Mat& yuv, RGBreader* rgbReader, YUVwriter* yuvWriter)
{convertor cvt;for(int row = 0; row < rgb.rows; ++row)for(int col = 0; col < rgb.cols; ++col)yuvWriter->write(yuv, row, col, cvt.convert(rgbReader->read(rgb, row, col)));
}struct ConversionYUV
{explicit ConversionYUV( const int code ){yuvReader_  = YUVreader :: getReader(code);yuvWriter_  = YUVwriter :: getWriter(code);rgbReader_  = RGBreader :: getReader(code);rgbWriter_  = RGBwriter :: getWriter(code);grayWriter_ = GRAYwriter:: getWriter(code);}~ConversionYUV(){if (yuvReader_)delete yuvReader_;if (yuvWriter_)delete yuvWriter_;if (rgbReader_)delete rgbReader_;if (rgbWriter_)delete rgbWriter_;if (grayWriter_)delete grayWriter_;}int getDcn(){return (rgbWriter_ != 0) ? rgbWriter_->channels() : ((grayWriter_ != 0) ? grayWriter_->channels() : yuvWriter_->channels());}int getScn(){return (yuvReader_ != 0) ? yuvReader_->channels() : rgbReader_->channels();}Size getSrcSize( const Size& imgSize ){return (yuvReader_ != 0) ? yuvReader_->size(imgSize) : imgSize;}Size getDstSize( const Size& imgSize ){return (yuvWriter_ != 0) ? yuvWriter_->size(imgSize) : imgSize;}bool requiresEvenHeight(){return (yuvReader_ != 0) ? yuvReader_->requiresEvenHeight() : ((yuvWriter_ != 0) ? yuvWriter_->requiresEvenHeight() : false);}bool requiresEvenWidth(){return (yuvReader_ != 0) ? yuvReader_->requiresEvenWidth() : ((yuvWriter_ != 0) ? yuvWriter_->requiresEvenWidth() : false);}YUVreader*  yuvReader_;YUVwriter*  yuvWriter_;RGBreader*  rgbReader_;RGBwriter*  rgbWriter_;GRAYwriter* grayWriter_;
};CV_ENUM(YUVCVTS, COLOR_YUV2RGB_NV12, COLOR_YUV2BGR_NV12, COLOR_YUV2RGB_NV21, COLOR_YUV2BGR_NV21,COLOR_YUV2RGBA_NV12, COLOR_YUV2BGRA_NV12, COLOR_YUV2RGBA_NV21, COLOR_YUV2BGRA_NV21,COLOR_YUV2RGB_YV12, COLOR_YUV2BGR_YV12, COLOR_YUV2RGB_IYUV, COLOR_YUV2BGR_IYUV,COLOR_YUV2RGBA_YV12, COLOR_YUV2BGRA_YV12, COLOR_YUV2RGBA_IYUV, COLOR_YUV2BGRA_IYUV,COLOR_YUV2RGB_UYVY, COLOR_YUV2BGR_UYVY, COLOR_YUV2RGBA_UYVY, COLOR_YUV2BGRA_UYVY,COLOR_YUV2RGB_YUY2, COLOR_YUV2BGR_YUY2, COLOR_YUV2RGB_YVYU, COLOR_YUV2BGR_YVYU,COLOR_YUV2RGBA_YUY2, COLOR_YUV2BGRA_YUY2, COLOR_YUV2RGBA_YVYU, COLOR_YUV2BGRA_YVYU,COLOR_YUV2GRAY_420, COLOR_YUV2GRAY_UYVY, COLOR_YUV2GRAY_YUY2,COLOR_YUV2BGR, COLOR_YUV2RGB, COLOR_RGB2YUV_YV12, COLOR_BGR2YUV_YV12, COLOR_RGBA2YUV_YV12,COLOR_BGRA2YUV_YV12, COLOR_RGB2YUV_I420, COLOR_BGR2YUV_I420, COLOR_RGBA2YUV_I420, COLOR_BGRA2YUV_I420)typedef ::testing::TestWithParam<YUVCVTS> Imgproc_ColorYUV;TEST_P(Imgproc_ColorYUV, accuracy)
{int code = GetParam();RNG& random = theRNG();ConversionYUV cvt(code);const int scn = cvt.getScn();const int dcn = cvt.getDcn();for(int iter = 0; iter < 30; ++iter){Size sz(random.uniform(1, 641), random.uniform(1, 481));if(cvt.requiresEvenWidth())  sz.width  += sz.width % 2;if(cvt.requiresEvenHeight()) sz.height += sz.height % 2;Size srcSize = cvt.getSrcSize(sz);Mat src = Mat(srcSize.height, srcSize.width * scn, CV_8UC1).reshape(scn);Size dstSize = cvt.getDstSize(sz);Mat dst = Mat(dstSize.height, dstSize.width * dcn, CV_8UC1).reshape(dcn);Mat gold(dstSize, CV_8UC(dcn));random.fill(src, RNG::UNIFORM, 0, 256);if(cvt.rgbWriter_)referenceYUV2RGB<YUV2RGB_Converter>  (src, gold, cvt.yuvReader_, cvt.rgbWriter_);else if(cvt.grayWriter_)referenceYUV2GRAY<YUV2GRAY_Converter>(src, gold, cvt.yuvReader_, cvt.grayWriter_);else if(cvt.yuvWriter_)referenceRGB2YUV<RGB2YUV_Converter>  (src, gold, cvt.rgbReader_, cvt.yuvWriter_);cv::cvtColor(src, dst, code, -1);EXPECT_EQ(0, countOfDifferencies(gold, dst));}
}TEST_P(Imgproc_ColorYUV, roi_accuracy)
{int code = GetParam();RNG& random = theRNG();ConversionYUV cvt(code);const int scn = cvt.getScn();const int dcn = cvt.getDcn();for(int iter = 0; iter < 30; ++iter){Size sz(random.uniform(1, 641), random.uniform(1, 481));if(cvt.requiresEvenWidth())  sz.width  += sz.width % 2;if(cvt.requiresEvenHeight()) sz.height += sz.height % 2;int roi_offset_top = random.uniform(0, 6);int roi_offset_bottom = random.uniform(0, 6);int roi_offset_left = random.uniform(0, 6);int roi_offset_right = random.uniform(0, 6);Size srcSize = cvt.getSrcSize(sz);Mat src_full(srcSize.height + roi_offset_top + roi_offset_bottom, srcSize.width + roi_offset_left + roi_offset_right, CV_8UC(scn));Size dstSize = cvt.getDstSize(sz);Mat dst_full(dstSize.height  + roi_offset_left + roi_offset_right, dstSize.width + roi_offset_top + roi_offset_bottom, CV_8UC(dcn), Scalar::all(0));Mat gold_full(dst_full.size(), CV_8UC(dcn), Scalar::all(0));random.fill(src_full, RNG::UNIFORM, 0, 256);Mat src = src_full(Range(roi_offset_top, roi_offset_top + srcSize.height), Range(roi_offset_left, roi_offset_left + srcSize.width));Mat dst = dst_full(Range(roi_offset_left, roi_offset_left + dstSize.height), Range(roi_offset_top, roi_offset_top + dstSize.width));Mat gold = gold_full(Range(roi_offset_left, roi_offset_left + dstSize.height), Range(roi_offset_top, roi_offset_top + dstSize.width));if(cvt.rgbWriter_)referenceYUV2RGB<YUV2RGB_Converter>  (src, gold, cvt.yuvReader_, cvt.rgbWriter_);else if(cvt.grayWriter_)referenceYUV2GRAY<YUV2GRAY_Converter>(src, gold, cvt.yuvReader_, cvt.grayWriter_);else if(cvt.yuvWriter_)referenceRGB2YUV<RGB2YUV_Converter>  (src, gold, cvt.rgbReader_, cvt.yuvWriter_);cv::cvtColor(src, dst, code, -1);EXPECT_EQ(0, countOfDifferencies(gold_full, dst_full));}
}INSTANTIATE_TEST_CASE_P(cvt420, Imgproc_ColorYUV,::testing::Values((int)COLOR_YUV2RGB_NV12, (int)COLOR_YUV2BGR_NV12, (int)COLOR_YUV2RGB_NV21, (int)COLOR_YUV2BGR_NV21,(int)COLOR_YUV2RGBA_NV12, (int)COLOR_YUV2BGRA_NV12, (int)COLOR_YUV2RGBA_NV21, (int)COLOR_YUV2BGRA_NV21,(int)COLOR_YUV2RGB_YV12, (int)COLOR_YUV2BGR_YV12, (int)COLOR_YUV2RGB_IYUV, (int)COLOR_YUV2BGR_IYUV,(int)COLOR_YUV2RGBA_YV12, (int)COLOR_YUV2BGRA_YV12, (int)COLOR_YUV2RGBA_IYUV, (int)COLOR_YUV2BGRA_IYUV,(int)COLOR_YUV2GRAY_420, (int)COLOR_RGB2YUV_YV12, (int)COLOR_BGR2YUV_YV12, (int)COLOR_RGBA2YUV_YV12,(int)COLOR_BGRA2YUV_YV12, (int)COLOR_RGB2YUV_I420, (int)COLOR_BGR2YUV_I420, (int)COLOR_RGBA2YUV_I420,(int)COLOR_BGRA2YUV_I420));INSTANTIATE_TEST_CASE_P(cvt422, Imgproc_ColorYUV,::testing::Values((int)COLOR_YUV2RGB_UYVY, (int)COLOR_YUV2BGR_UYVY, (int)COLOR_YUV2RGBA_UYVY, (int)COLOR_YUV2BGRA_UYVY,(int)COLOR_YUV2RGB_YUY2, (int)COLOR_YUV2BGR_YUY2, (int)COLOR_YUV2RGB_YVYU, (int)COLOR_YUV2BGR_YVYU,(int)COLOR_YUV2RGBA_YUY2, (int)COLOR_YUV2BGRA_YUY2, (int)COLOR_YUV2RGBA_YVYU, (int)COLOR_YUV2BGRA_YVYU,(int)COLOR_YUV2GRAY_UYVY, (int)COLOR_YUV2GRAY_YUY2));}TEST(cvtColorUYVY, size_issue_21035)
{Mat input = Mat::zeros(1, 1, CV_8UC2);Mat output;EXPECT_THROW(cv::cvtColor(input, output, cv::COLOR_YUV2BGR_UYVY), cv::Exception);
}} // namespace

源:

(1) openCV:环境配置和测试代码_opencv配置好了,怎么在studio中测试包含的代码-CSDN博客.
(2) imgproc 模块. 图像处理 — OpenCV 2.3.2 documentation.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/715960.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Leetcode630. 课程表 III

Every day a Leetcode 题目来源&#xff1a;630. 课程表 III 解法1&#xff1a;反悔贪心 经验告诉我们&#xff0c;在准备期末考试的时候&#xff0c;先考的课程先准备。同理&#xff0c;lastDay 越早的课程&#xff0c;应当越早上完。但是&#xff0c;有的课程 duration 比…

2023年09月CCF-GESP编程能力等级认证Scratch图形化编程四级真题解析

一、单选题(共15题,共30分) 第1题 人们所使用的手机上安装的 App 通常指的是( )。 A:一款操作系统 B:一款应用软件 C:一种通话设备 D:以上都不对 答案:B 第2题 下列流程图的输出结果是?( ) A:9 B:7 C:5 D:11 答案:A 第3题 默认小猫角色,执行下列程序…

IO,硬盘与文件

IO与计算机存储空间 IO&#xff08;输入/输出&#xff09;是计算机领域中指的是数据在计算机与外部设备之间的传输过程。存储通常指的是计算机中用来保存数据的介质或设备&#xff0c;硬盘是存储设备的一种&#xff0c;通常是指硬盘驱动器&#xff08;Hard Disk Drive&#xf…

文章解读与仿真程序复现思路——电网技术EI\CSCD\北大核心《考虑时空相关性的流域水风光多能互补系统高维不确定性场景生成方法》

本专栏栏目提供文章与程序复现思路&#xff0c;具体已有的论文与论文源程序可翻阅本博主免费的专栏栏目《论文与完整程序》 论文与完整源程序_电网论文源程序的博客-CSDN博客https://blog.csdn.net/liang674027206/category_12531414.html 这篇文章的标题涵盖了以下几个关键方…

C语言编程大题

以下总结编程大题的常考题型 1,输出 100-200 之间所有素数。 要求: (1)编写一个判断一个整数是否为素数的函数 void prime(int n),若是素数则输出,否则不输出 (2)主函数中调用 prime 函数,输出 100-200 之间所有素数 说明:素数是指除了1和该数本身之外,不能被其它任何整…

【C++】用命名空间避免命名冲突

&#x1f338;博主主页&#xff1a;釉色清风&#x1f338;文章专栏&#xff1a;C&#x1f338;今日语录&#xff1a;如果神明还不帮你&#xff0c;说明他相信你。 &#x1fab7;文章简介&#xff1a;这篇文章是结合谭浩强老师的书以及自己的理解&#xff0c;同时加入了一些例子…

NOC2023软件创意编程(学而思赛道)python小高组初赛真题

软件创意编程 一、参赛范围 1.参赛组别:小学低年级组(1-3 年级)、小学高年级组(4-6 年级)、初中组。 2.参赛人数:1 人。 3.指导教师:1 人(可空缺)。 4.每人限参加 1 个赛项。 组别确定:以地方教育行政主管部门(教委、教育厅、教育局) 认定的选手所属学段为准。 二、…

MATLAB知识点:if条件判断语句的嵌套

​讲解视频&#xff1a;可以在bilibili搜索《MATLAB教程新手入门篇——数学建模清风主讲》。​ MATLAB教程新手入门篇&#xff08;数学建模清风主讲&#xff0c;适合零基础同学观看&#xff09;_哔哩哔哩_bilibili 节选自​第4章&#xff1a;MATLAB程序流程控制 我们通过一个…

基于springboot+vue的教师工作量管理系统

博主主页&#xff1a;猫头鹰源码 博主简介&#xff1a;Java领域优质创作者、CSDN博客专家、阿里云专家博主、公司架构师、全网粉丝5万、专注Java技术领域和毕业设计项目实战&#xff0c;欢迎高校老师\讲师\同行交流合作 ​主要内容&#xff1a;毕业设计(Javaweb项目|小程序|Pyt…

Java集合-Map接口

在Java中&#xff0c;Map接口表示键值对的集合&#xff0c;其中每个键都是唯一的&#xff0c;并且每个键映射到一个值。Map接口是集合框架中的一部分&#xff0c;位于java.util包中。它定义了一系列操作来管理键值对&#xff0c;例如添加键值对、删除键值对、获取键对应的值等。…

7.1.1 selenium介绍及安装chromedriver

目录 1. Selenium的用途 2. 安装Selenium库 3. 安装chromedriver 1. 查看谷歌版本号​编辑 2. 找到最新版本及下载 3. 配置环境变量 4. 检测是否配置成功 5. 用python初始化浏览器对象检测&#xff1a; 6. 参考链接 1. Selenium的用途 在前面我们提到&#xff1a;在我…

Github项目推荐-LightMirrors

项目地址 https://github.com/NoCLin/LightMirrors 项目简述 “LightMirrors是一个开源的缓存镜像站服务&#xff0c;用于加速软件包下载和镜像拉取。目前支持DockerHub、PyPI、PyTorch、NPM等镜像缓存服务。 当前项目仍处于早期阶段。”–来自项目说明。 也就是说&#xff…

爆红提醒:ESLint: Parsing error: Unexpected token. Did you mean `{‘>‘}` or `gt;`?

错误情况&#xff1a;> 会爆红提示&#xff1a;ESLint: Parsing error: Unexpected token. Did you mean {>} or >? function().then((res) > {console.log(res.data); }解决方法&#xff1a;修改.eslintrc或者.eslintrc.js的配置 module.exports {// 其他配置..…

RocketMq——Consume相关源码

摘要 RocketMQ只要有CommitLog文件就可以正常运行了&#xff0c;那为何还要维护ConsumeQueue文件呢&#xff1f; ConsumeQueue是消费队列&#xff0c;引入它的目的是为了提高消费者的消费速度。毕竟RocketMQ是基于Topic主题订阅模式的&#xff0c;消费者往往只关心自己订阅的…

定制开发一款家政小程序,应知应会

引言 在这个快节奏的现代生活中&#xff0c;人们对高效、便捷的家政服务的需求日益增加。随着社会结构的变化和职业生活的繁忙&#xff0c;许多家庭面临着时间不足、精力不济的挑战。在这种情况下&#xff0c;家政服务成为解决问题的有效途径。然而&#xff0c;传统的家政服务…

Python——桌面摄像头软件(附源码+打包)

目录 一、前言 二、桌面摄像头软件 2.1、下载项目 2.2、功能介绍 三、打包工具&#xff08;nuitka&#xff09; 四、项目文件复制&#xff08;我全部合到一个文件里面了&#xff09; 五、结语 一、前言 看见b站的向军大叔用electron制作了一个桌面摄像头软件 但是&#x…

PPT 批量删除每页相同位置的内容

方法&#xff1a; 选择【视图】&#xff0c;【宏】&#xff0c;设置宏的名称&#xff0c;点创建将下列函数复制到宏中&#xff0c;在ppt中先选择某个要删除的对象&#xff0c;然后运行宏即可 函数内容如下 Sub Delete( ) Dim oSlide As Slide, oShape As Shape Dim myWidt…

如何在jupyter notebook 中下载第三方库

在anconda 中找到&#xff1a; Anaconda Prompt 进入页面后的样式&#xff1a; 在黑色框中输入&#xff1a; 下载第三方库的命令 第三方库&#xff1a; 三种输入方式 标准保证正确 pip instsall 包名 -i 镜像源地址 pip install pip 是 Python 包管理工具&#xff0c;…

新项目,Linux上一键安装MySQL,Redis,Nacos,Minio

大家好&#xff0c;我是 jonssonyan 分享一个我的一个开源项目&#xff0c;这是一个在 Linux 平台上一键安装各种软件的脚本项目&#xff0c;脚本使用 Shell 语言编写&#xff0c;后续还会增加更多软件的一键安装&#xff0c;代码在 GitHub 上全部开源的&#xff0c;开源地址如…

【Python】进阶学习:pandas--如何根据指定条件筛选数据

【Python】进阶学习&#xff1a;pandas–如何根据指定条件筛选数据 &#x1f308; 个人主页&#xff1a;高斯小哥 &#x1f525; 高质量专栏&#xff1a;Matplotlib之旅&#xff1a;零基础精通数据可视化、Python基础【高质量合集】、PyTorch零基础入门教程&#x1f448; 希望…