简体   繁体   English

退出时,OpenCV程序使linux崩溃(使用cvtColor)

[英]OpenCV program crashes linux when exiting (using cvtColor)

I've made a working application using OpenCV that crashes linux mint, after the program is finished (return 0;). 程序完成后,我使用OpenCV制作了一个可运行的应用程序,该应用程序使linux mint崩溃(返回0;)。

I've narrowed the code down to the snippet below. 我将代码范围缩小到了下面的代码段。 When the function cvtColor is used, the program crashes. 使用函数cvtColor时,程序崩溃。 While the code is running, nothing weird is going on and cvtColor is doing it's job. 在代码运行时,没有任何奇怪的事情发生,而cvtColor正在完成它的工作。

I'm not ac/c++ programmer, I don't even know where to look further to what causes this or how to find something to help me google for a solution. 我不是ac / c ++程序员,我什至不知道在哪里进一步查找导致此问题的原因或如何找到可以帮助我Google寻求解决方案的方法。

Can someone point me in the right direction? 有人可以指出我正确的方向吗?

The version of OpenCV: 3.0 Running on: 3.11.0-12-generic #19-Ubuntu x86_64 x86_64 x86_64 GNU/Linux OpenCV的版本:3.0运行于:3.11.0-12-generic#19-Ubuntu x86_64 x86_64 x86_64 GNU / Linux

#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>

#include <string>

using namespace std;
using namespace cv;


int main( int argc, char** argv )
{
    Mat frame1;
    Mat grayImage1;

    frame1 = imread("lena.jpg");

    cvtColor(frame1, grayImage1, COLOR_RGB2BGR);

    return 0;
}

OpenCV 3.0似乎仍处于Alpha阶段,因此我建议您尝试使用稳定版本进行相同的操作,并检查是否存在相同的问题。

I don't know if this is causing the crash, but a potential problem is the conversion from RGB to BGR. 我不知道这是否导致崩溃,但潜在的问题是从RGB到BGR的转换。

You probably wanted to execute COLOR_BGR2RGB instead, since the data is originally stored as BGR . 您可能想改为执行COLOR_BGR2RGB ,因为数据最初存储为BGR

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM