【问题标题】:Seg fault when using cv::split使用 cv::split 时出现段错误
【发布时间】:2020-05-11 05:44:18
【问题描述】:

这是我的代码:

    printf("preallocations\n");
    char * addr = (char *) bo_gc320->m_fb_id[gc320_buf_idx];
    cv::Mat src(cvSize(bo_gc320->m_width, bo_gc320->m_height), CV_8UC4, addr);
    cv::Mat alpha(cvSize(bo_gc320->m_width, bo_gc320->m_height), CV_8UC1);
    cv::Mat rgb(cvSize(bo_gc320->m_width, bo_gc320->m_height), CV_8UC3);
    cv::Mat dst(cvSize(bo_gc320->m_width, bo_gc320->m_height), CV_8UC3);
    printf("postallocations\n");

    cv::Mat * out = new cv::Mat[4];// malloc(4*sizeof(cv::Mat *));
    for (int k=0;k<4;k++) {
      out[k] = cv::Mat(cvSize(bo_gc320->m_width, bo_gc320->m_height), CV_8UC1);
      printInfo(out[k]);
    }
    printf("presplit\n");
    printInfo(src);
    cv::split(src, out);
    printf("postsplit\n");

输出是:

preallocations
postallocations
dim(332, 768)unsigned char(1)
dim(332, 768)unsigned char(1)
dim(332, 768)unsigned char(1)
dim(332, 768)unsigned char(1)
presplit
dim(332, 768)unsigned char(4)
Segmentation fault (core dumped)

我正在帮助函数中打印有关数组的信息。 addr 中的数据来自 gc320 GPU 的输出缓冲区。这可能是由于地址不包含有效数据造成的吗?

【问题讨论】:

标签: c++ opencv image-processing gpu


【解决方案1】:

原来 addr 实际上是无效数据并且没有填充整个 CV_8UC4 Mat 结构。一旦我更改了缓冲区,问题就解决了。

【讨论】:

    猜你喜欢
    • 2020-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多