LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-10-2015, 03:41 PM   #1
savio
LQ Newbie
 
Registered: May 2015
Posts: 29

Rep: Reputation: Disabled
"segmentation fault: 11" with C and OpenCV


I have problems with OpenCV, precisely with the following snippet of code:

Code:
  char* item;
  ...
  ...

  printf("Filter started\n");
  item = ReadingFrom(...);
  printf("The Item: s\n", item);
  printf("strlen(item): lu\n", strlen(item));

  IplImage* img = cvLoadImage(item, CV_LOAD_IMAGE_COLOR);
  printf("img pointer: p\n", img);
  IplImage* outimg = cvCreateImage(cvGetSize(img), IPL_DEPTH_8U, 3);
  printf("outimg pointer: %p\n", outimg);

  cvSmooth(img, outimg, CV_GAUSSIAN, 5, 5, 0, 0);
  cvSaveImage("smoothed.jpg", outimg, 0);

  cvReleaseImage(&img);
  cvReleaseImage(&outimg);
It seems that both cvSmooth and cvSaveImage cause a "Segmentation fault: 11".
I am using a proprietary framework I cannot modify.
The function ReadingFrom() is defined as follows:

Code:
void *ReadingFrom(...) {

  void* item;

  ...
  ...
  return item;
}
The following instructions:
Code:
  printf("The Item: s\n", item);
  printf("strlen(item): %lu\n", strlen(item));
return the value of the item string and its size.
I suppose there is a problem in item I pass to cvLoadImage.
How can I check exactly what is item?

Saverio

Last edited by savio; 07-10-2015 at 03:56 PM.
 
Old 07-10-2015, 10:15 PM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
The '...' part might be wrong, eg: returning free'ed pointer, returning alloca'ed memory, returning local (auto) variable etc.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] The expect -c "spawn ls" check in section 6.12 of the book gives a segmentation fault ezekielrage Linux From Scratch 1 05-18-2011 08:58 AM
"netstat -l" gives "segmentation fault" Earwig Linux - Newbie 2 03-31-2010 04:12 PM
sunbird 0.3 does not start, error: Segmentation fault : "$prog" ${1+"$@"} polemon Ubuntu 8 01-08-2007 04:22 AM
why iam getting problems like "...too many files opened" or "segmentation fault" naren_0101bits Linux - Newbie 2 07-19-2004 12:20 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration