drawing text with strokecolor - segmentation fault
Posted: 2010-04-30T01:47:12-07:00
Hi,
I have a strange segmentation fault when I draw text with a set strokecolor.
The segmentation fault occurs when I use ImageMagick code in combination with OpenCV or Qt.
I make it simple. Consider, for instance, your piddle.cpp demo in which I just changed the lines drawing text.
Here it is the changed part:
...
//
// Draw text.
//
drawList.push_back(DrawableFillColor("green"));
drawList.push_back(DrawableStrokeColor(Color("black"))); // SET COLOR!!!
drawList.push_back(DrawableStrokeWidth(1)); // SET WIDTH!!!
drawList.push_back(DrawablePointSize(24));
drawList.push_back(DrawableTranslation(30,140));
drawList.push_back(DrawableRotation(45.0));
drawList.push_back(DrawableText(0,0,"This is a test!"));
...
The code perfectly compiles and runs without other changes.
The segmentation fault occurs when i just add at the top of the main function this single line (OpenCV function):
cvNamedWindow("awindow", CV_WINDOW_AUTOSIZE); // prepare a window where to draw OpenCV stuff
In order to have the code compiled I also add at the top of the program this required include
#include "highgui.h"
This my gdb print:
[Thread debugging using libthread_db enabled]
[New Thread 0xb3e02a00 (LWP 28118)]
[New Thread 0xb3b65b90 (LWP 28121)]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb3e02a00 (LWP 28118)]
TraceBezier (primitive_info=0xb32edd28, number_coordinates=2432)
at magick/draw.c:1673
1673 primitive_info->coordinates=1;
Current language: auto; currently c
For this code, the segmentation fault disappears in any of the following cases:
1) I put the openCV istruction cvNamedWindow() at the end of the 'try' block (after the imagemagick drawing lines).
2) I comment the DrawableStrokeColor line
3) I leave the strokeColor unset.
The same problem also occurs when i use Qt for drawing imagemagick stuff. Even in this case, gdb reports error at the same line of the file magick/draw.c.
The problem seems related to setting a strokeColor for drawing text. Conversely, setting a strokeColor for drawing other objects does not generate errors!
Thanks in advance for your help.
- Xfly
I have a strange segmentation fault when I draw text with a set strokecolor.
The segmentation fault occurs when I use ImageMagick code in combination with OpenCV or Qt.
I make it simple. Consider, for instance, your piddle.cpp demo in which I just changed the lines drawing text.
Here it is the changed part:
...
//
// Draw text.
//
drawList.push_back(DrawableFillColor("green"));
drawList.push_back(DrawableStrokeColor(Color("black"))); // SET COLOR!!!
drawList.push_back(DrawableStrokeWidth(1)); // SET WIDTH!!!
drawList.push_back(DrawablePointSize(24));
drawList.push_back(DrawableTranslation(30,140));
drawList.push_back(DrawableRotation(45.0));
drawList.push_back(DrawableText(0,0,"This is a test!"));
...
The code perfectly compiles and runs without other changes.
The segmentation fault occurs when i just add at the top of the main function this single line (OpenCV function):
cvNamedWindow("awindow", CV_WINDOW_AUTOSIZE); // prepare a window where to draw OpenCV stuff
In order to have the code compiled I also add at the top of the program this required include
#include "highgui.h"
This my gdb print:
[Thread debugging using libthread_db enabled]
[New Thread 0xb3e02a00 (LWP 28118)]
[New Thread 0xb3b65b90 (LWP 28121)]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb3e02a00 (LWP 28118)]
TraceBezier (primitive_info=0xb32edd28, number_coordinates=2432)
at magick/draw.c:1673
1673 primitive_info->coordinates=1;
Current language: auto; currently c
For this code, the segmentation fault disappears in any of the following cases:
1) I put the openCV istruction cvNamedWindow() at the end of the 'try' block (after the imagemagick drawing lines).
2) I comment the DrawableStrokeColor line
3) I leave the strokeColor unset.
The same problem also occurs when i use Qt for drawing imagemagick stuff. Even in this case, gdb reports error at the same line of the file magick/draw.c.
The problem seems related to setting a strokeColor for drawing text. Conversely, setting a strokeColor for drawing other objects does not generate errors!
Thanks in advance for your help.
- Xfly