简体   繁体   English

断言失败 (scn == 3 || scn == 4) in void cv::cvtColor(cv::InputArray, cv::OutputArray, int, int), file /../Linux/./../src/ color.cpp,第 8000 行

[英]Assertion failed (scn == 3 || scn == 4) in void cv::cvtColor(cv::InputArray, cv::OutputArray, int, int), file /../Linux/./../src/color.cpp, line 8000

I am trying to learn openCv with native code and I am taking reference from here .我正在尝试使用本机代码学习 openCv,我正在从这里获取参考。
I successfully build the project using ndk-build.我使用 ndk-build 成功构建了项目。
Now I want to make change in scan.cpp file which is responsible for getting point for image, crop it, scan it and set color.现在我想在scan.cpp文件中进行更改, 文件负责获取图像点、裁剪、扫描和设置颜色。
I want to give different argument for line 321 in file which is我想为文件中的第 321 行提供不同的参数
cvtColor(mbgra, dst, CV_BGR2GRAY); cvtColor(mbgra, dst, CV_BGR2GRAY);
Can I give any other argument for CV_BGR2GRAY .我可以为CV_BGR2GRAY提供任何其他参数
If yes HOW?如果是,如何? If no WHY?如果没有,为什么?

Please guide me and tell me if I am missing anything.请指导我并告诉我是否遗漏了什么。 Thank you.谢谢你。

Yes, you can give any argument you want.是的,你可以给出任何你想要的论点。 Would you get a reasonable output?你会得到一个合理的输出吗? It depends.这取决于。 CV_BGR2GRAY expects BGR (3 channel) input and will output gray (1 channel). CV_BGR2GRAY 需要 BGR(3 通道)输入并将输出灰色(1 通道)。

If you input is 3 channel BGR (and even if it isn't really BGR, opencv won't care) you can use any 3 channel conversions, for example CV_BGR2HSV which would result in 3 channel HSV output.如果您输入的是 3 通道 BGR(即使它不是真正的 BGR,opencv 也不会关心),您可以使用任何 3 通道转换,例如 CV_BGR2HSV,这将导致 3 通道 HSV 输出。

If your input is 1 channel - than you won't be able to use BGR 2 GRAY obviously.如果您的输入是 1 通道 - 显然您将无法使用 BGR 2 GREY。

Mat bgraImage = imread("BGRA_IMAGE.png", -1);  // 4 channel input image
Mat grayImage = imread("GRAY_IMAGE.png", CV_LOAD_IMAGE_GRAYSCALE);  // 1 channel input image
Mat result;

cvtColor(bgraImage, result, CV_BGRA2GRAY);    // CORRECT, input 4 channel, output will be 1 channel
cvtColor(bgraImage, result, CV_BGR2GRAY);    // ALSO CORRECT
cvtColor(grayImage, result, CV_BGR2GRAY);    // INCORRECT & will crash, input is 1 channel, expecting 3 or 4
cvtColor(grayImage, result, CV_GRAY2BGR);    // CORRECT, input is 1 channel, output is 3 channel

You can see all possible color conversions here and read more about them here你可以看到所有可能的颜色转换这里和阅读更多关于他们在这里

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在void cv :: cvtColor中断言失败(scn == 3 || scn == 4)(cv :: InputArray Android - Assertion failed (scn == 3 || scn == 4) in void cv::cvtColor(cv::InputArray Android 错误:Android Kotlin 中的断言失败 (src.type() == CV_8UC1 || src.type() == CV_8UC3 || src.type() == CV_8UC4) - Error: Assertion failed (src.type() == CV_8UC1 || src.type() == CV_8UC3 || src.type() == CV_8UC4) in Android Kotlin cverror android断言失败(scn == 3)Android - cverror android assertion failed (scn == 3) Android resize.cpp:4052: error: (-215:Assertion failed).ssize:empty() in function 'cv::resize' - resize.cpp:4052: error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize' Android Studio NDK 链接器错误未定义对“cv::_OutputArray::_OutputArray(cv::Mat&)”的引用 - Android Studio NDK linker error undefined reference to 'cv::_OutputArray::_OutputArray(cv::Mat&)' 双向过滤器错误,声明失败((src.type()== CV_8UC1 || src.type()== CV_8UC3)&& src.data!= dst.data) - Bilateral filter error, Assertion failed ((src.type() == CV_8UC1 || src.type() == CV_8UC3) && src.data != dst.data) src.type() == CV_8UC1 图像去歪斜时断言失败 - src.type() == CV_8UC1 assertion failed when deskewing image OpenCV错误:在OpenCV android sdk中使用分水岭时断言失败(scn == 3 || scn == 4) - OpenCV Error: Assertion failed (scn == 3 || scn == 4) while using Watershed in OpenCV android sdk OpenCV 错误:断言失败(channels() == CV_MAT_CN (dtype)) - OpenCV Error: Assertion failed (channels() == CV_MAT_CN (dtype)) 未定义对`cv :: fastFree(void *)'的引用 - undefined reference to `cv::fastFree(void*)'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM