• 7294阅读
  • 0回复

『菜鸟求助』在调用图像处理函数是出现Program received signal SIGSEGV, Segmentation fault.问题 [复制链接]

上一主题 下一主题
离线myarmdream
 
只看楼主 倒序阅读 楼主  发表于: 2011-05-11
关键词: 求助QT4界面
本人是一名大四学生,毕业设计选了与嵌入式有关的课题——基于嵌入式的图像处理算法研究。老师让我设计一个在开发板上运行的图像处理软件。我就用Qt进行了设计,在加入并调用 图像锐化 sharp() 子函数是出现了一下问题(该子函数不是自己写的):
Program received signal SIGSEGV, Segmentation fault.
0x0804c048 in ImageProcessing::sharp() ()
sharp()子函数如下:
  1. void ImageProcessing::sharp()
  2. {
  3.     int w = sourceImage.width();
  4.     int h = sourceImage.height();
  5.     if(NULL == sourceImageData)//判断是否需要读取数据
  6.     {
  7.         std::complex<double>*sourceImageData = new std::complex<double>[w*h];
  8.         readImage(sourceImageData,sourceImage);
  9.     }
  10.     //拷贝一份数据便与计算
  11.     std::complex<double>*buffer = new std::complex<double>[w*h];
  12.     memcpy(buffer,sourceImageData,sizeof(std::complex<double>)*w*h);
  13.     //根据模板进行计算
  14.     //为了简化编码忽略了图像边界(i=0 or h,h=0 or w),对于整体效果没有影响
  15.     int i,j;
  16.     std::complex<double>k;
  17.     for(i=1;i<h-1;i++)
  18.     {
  19.         for(j=1;j<w-1;j++)
  20.         {
  21.             k = buffer[i*w+j];
  22.             k = std::complex<double>(k.real()*5,0);
  23.             k -=buffer[(i-1)*w+j];
  24.             k -= buffer[i*w+j-1];
  25.             k -=buffer[i*w+j+1];
  26.             k -=buffer[(i+1)*w+j];
  27.             sourceImageData[i*w+j] = k;
  28.         }
  29.     }
  30.     writeImage(sourceImage,sourceImageData,1);
  31.     destinationlabel->setPixmap(QPixmap::fromImage(sourceImage));    
  32. }

该函数是ImageProcessing的槽函数, sourceImageData在ImageProcessing定义:
       ……
       std::complex <double>*sourceImageData;
自己分析觉得可能是 sourceImageData指针为初始化的问题。
但是如果进行如下初始化后,问题仍然存在:
          sourceImageData = new std::complex <double>(NULL);
问题变为:
          Program received signal SIGSEGV, Segmentation fault.
0x013662d8 in XCreateGC () from /usr/lib/i386-linux-gnu/libX11.so.6

注:程序在加入这段代码前是可以执行的,而且加入后编译没有任何问题,只有在执行中调用该函数时出现错误

跪求各位大侠指点,小弟不胜感激!!!!!!!!!!
快速回复
限100 字节
 
上一个 下一个