LinuxQuestions.org
Visit Jeremy's Blog.
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 06-13-2013, 08:12 AM   #1
Ericxx
Member
 
Registered: Feb 2010
Posts: 33

Rep: Reputation: 0
Segmentation fault in C++ when logging jpeg images with OpenCV


Hello,

I am using the x86 machine doing embedded development which requires recording the images of the cameras. I am using the library OpenCV 2.4 for image operations. Specifically, the "imwrite()" function is used to save as the jpeg images. The executable program got a segmentation fault error randomly during the capture process. Attached is the debug screenshot when the error happened. Wondering if "Address 0xxxxx out of bounds" is causing the problem. But there are several times the error still happens without this hint. Can please suggest some ways of debugging this problem. Thank you.

Eric
Attached Thumbnails
Click image for larger version

Name:	Screenshot - opencv_imwrite_fault_wDebugInfo.png
Views:	137
Size:	245.4 KB
ID:	12703  
 
Old 06-13-2013, 08:27 AM   #2
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by Ericxx View Post
Wondering if "Address 0xxxxx out of bounds" is causing the problem. But there are several times the error still happens without this hint.
That can be difficult if you aren't an experienced programmer, since apparently this isn't your code.

In the failure you showed, bgra is a pointer that points to an invalid address. You didn't show enough info for me to see why bgra points to an invalid address.

Most likely, the variable i at the point of failure is non zero, from which you could deduce that size.width is too large and the loop has incremented bgra from a valid pointer to an invalid one.

If i were zero then bgra must have been invalid before that section of code started.

It is reasonably to assume the code from opencv is correct and your code contains the error. So there must be something wrong with the InputArray you passed to imwrite().

Last edited by johnsfine; 06-13-2013 at 08:52 AM.
 
Old 06-17-2013, 10:25 PM   #3
Ericxx
Member
 
Registered: Feb 2010
Posts: 33

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by johnsfine View Post
It is reasonably to assume the code from opencv is correct and your code contains the error. So there must be something wrong with the InputArray you passed to imwrite().
Dear John,

Yes, the problem is probably on my side with the images I put into. But I have checked that the input images which has a resolution 640 x 480 data. So could you suggest a way to thoroughly check the InputArray? Thanks a lot.

Regards,
Eric
 
Old 06-26-2013, 01:06 AM   #4
Ericxx
Member
 
Registered: Feb 2010
Posts: 33

Original Poster
Rep: Reputation: 0
The problem is already solved. It is a mutex issue which causes the OpenCV error when accesing the Mat structure.

Thanks,
Eric
 
  


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] Old newspaper images 1847 jpeg's Richard14 Linux - Software 3 03-31-2013 11:44 AM
coloring grey images in opencv . ayush15690 Programming 1 11-08-2011 08:41 AM
yast segmentation fault, system freezing - nvidia driver at fault? BaltikaTroika SUSE / openSUSE 2 12-02-2005 09:34 AM
Parse information from images (jpeg..etc) chrisk5527 Linux - General 4 10-22-2005 11:08 AM
displaying jpeg images Dave31836 Programming 2 01-25-2005 10:28 AM

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

All times are GMT -5. The time now is 09:45 AM.

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