it crashes when thickness is more than one (Bug #1274)
Description
The following inpainting demo works if thickness of drawing line is 1 and crashes when it is 2 or more. Version: 2.2 on MinGW
1#include "opencv2/highgui/highgui.hpp"
2#include "opencv2/imgproc/imgproc.hpp"
3#include <iostream>
4using namespace cv;
5using namespace std;
6
7Mat img, inpaintMask;
8Point prevPt(-1,-1);
9
10void onMouse( int event, int x, int y, int flags, void* )
11{
12 if( event == CV_EVENT_LBUTTONUP || !(flags & CV_EVENT_FLAG_LBUTTON) )
13 prevPt = Point(-1,-1);
14 else if( event == CV_EVENT_LBUTTONDOWN )
15 prevPt = Point(x,y);
16 else if( event == CV_EVENT_MOUSEMOVE && (flags & CV_EVENT_FLAG_LBUTTON) )
17 {
18 Point pt(x,y);
19 if( prevPt.x < 0 ) prevPt = pt;
20 line( inpaintMask, prevPt, pt, Scalar::all(255), 1, 8, 0 );
21// line( inpaintMask, prevPt, pt, Scalar::all(255), 2, 8, 0 ); // crashes
22 line( img, prevPt, pt, Scalar::all(255), 1, 8, 0 );
23// line( img, prevPt, pt, Scalar::all(255), 2, 8, 0 ); // crashes
24 prevPt = pt;
25 imshow("image", img);
26 }
27}
28
29int main( int argc, char** argv )
30{
31 char* filename = argc >= 2 ? argvr1 : (char*)"fruits.jpg";
32 Mat img0 = imread(filename, -1);
33 if(img0.empty())
34 {
35 cout << "Couldn't open the image " << filename << ". Usage: inpaint <image_name>\n" << endl;
36 return 0;
37 }
38
39 namedWindow( "image", 1 );
40
41 img = img0.clone();
42 inpaintMask = Mat::zeros(img.size(), CV_8U);
43
44 imshow("image", img);
45 setMouseCallback( "image", onMouse, 0 );
46
47 for(;;)
48 {
49 char c = (char)waitKey();
50
51 if( c == 27 )
52 break;
53
54 if( c == 'r' )
55 {
56 inpaintMask = Scalar::all(0);
57 img0.copyTo(img);
58 imshow("image", img);
59 }
60
61 if( c == 'i' || c == ' ' )
62 {
63 Mat inpainted;
64 inpaint(img, inpaintMask, inpainted, 3, CV_INPAINT_TELEA);
65 imshow("inpainted image", inpainted);
66 }
67 }
68
69 return 0;
70}
History
Updated by Vadim Pisarevsky over 13 years ago
Can you try OpenCV 2.3 and/or compile OpenCV with "-O2" rather than "-O3" optimization. MinGW is known to produce invalid code in some cases when "-O3" optimization is set.
Updated by Andrej Lucny over 13 years ago
Replying to [comment:1 vp153]:
Can you try OpenCV 2.3 and/or compile OpenCV with "-O2" rather than "-O3" optimization. MinGW is known to produce invalid code in some cases when "-O3" optimization is set.
I have tried to use -O2, no change
Btw. I am using OpenCV 2.2
Updated by Alexander Shishkov about 13 years ago
- Category set to highgui-images
Updated by Alexander Shishkov almost 13 years ago
- Description changed from The following inpainting demo works if thickness of drawing line is 1 and cra... to The following inpainting demo works if thickness of drawing line is 1 and cra... More
Updated by Alexander Shishkov almost 13 years ago
- Priority changed from High to Normal
- Target version deleted ()
Updated by Alexander Shishkov almost 13 years ago
- Assignee deleted (
Vadim Pisarevsky)
Updated by Alexander Shishkov almost 13 years ago
Can't reproduce the problem. Tried on the trunk using last MinGW release with 4.6.1 gcc.
- Status changed from Open to Cancelled
- Assignee set to Alexander Shishkov
Updated by Alexander Shishkov almost 13 years ago
- Target version set to 2.4.0
Updated by Andrej Lucny almost 13 years ago
2.3 works fine.
Updated by Andrey Kamaev over 12 years ago
- Category changed from highgui-images to core