aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorN.N. <sevyves@users.sourceforge.net>2009-08-15 16:15:51 +0000
committerN.N. <sevyves@users.sourceforge.net>2009-08-15 16:15:51 +0000
commit077d78313e35ee7fc8be44800ab6578e366b76d2 (patch)
treed22908eff9bffb11ef82931b4d7b97bc26ba3314
parent3eca5353025abcded8bf8e009945260dcbad677e (diff)
fixed possible segfaultS
svn path=/trunk/externals/pix_opencv/; revision=11927
-rw-r--r--pix_opencv_threshold.cc35
1 files changed, 22 insertions, 13 deletions
diff --git a/pix_opencv_threshold.cc b/pix_opencv_threshold.cc
index bf1af10..93e82b6 100644
--- a/pix_opencv_threshold.cc
+++ b/pix_opencv_threshold.cc
@@ -37,6 +37,7 @@ pix_opencv_threshold :: pix_opencv_threshold()
comp_xsize = 0;
comp_ysize = 0;
orig = NULL;
+ rgb = NULL;
gray = NULL;
}
@@ -66,14 +67,16 @@ void pix_opencv_threshold :: processRGBAImage(imageStruct &image)
this->comp_ysize = image.ysize;
//Destroy cv_images to clean memory
- cvReleaseImage(&orig);
- cvReleaseImage(&gray);
- cvReleaseImage(&rgb);
+ if ( orig )
+ {
+ cvReleaseImage(&orig);
+ cvReleaseImage(&gray);
+ cvReleaseImage(&rgb);
+ }
//create the orig image with new size
orig = cvCreateImage(cvSize(image.xsize,image.ysize), IPL_DEPTH_8U, 4);
-
- // Create the output images with new sizes
+ rgb = cvCreateImage(cvSize(image.xsize,image.ysize), IPL_DEPTH_8U, 3);
gray = cvCreateImage(cvSize(orig->width,orig->height), IPL_DEPTH_8U, 1);
}
// Here we make a copy of the pixel data from image to orig->imageData
@@ -119,14 +122,16 @@ void pix_opencv_threshold :: processRGBImage(imageStruct &image)
this->comp_ysize = image.ysize;
//Destroy cv_images to clean memory
- cvReleaseImage(&orig);
- cvReleaseImage(&gray);
- cvReleaseImage(&rgb);
+ if ( rgb )
+ {
+ cvReleaseImage(&orig);
+ cvReleaseImage(&gray);
+ cvReleaseImage(&rgb);
+ }
//create the orig image with new size
+ orig = cvCreateImage(cvSize(image.xsize,image.ysize), IPL_DEPTH_8U, 4);
rgb = cvCreateImage(cvSize(image.xsize,image.ysize), IPL_DEPTH_8U, 3);
-
- // Create the output images with new sizes
gray = cvCreateImage(cvSize(rgb->width,rgb->height), IPL_DEPTH_8U, 1);
}
@@ -174,11 +179,15 @@ void pix_opencv_threshold :: processGrayImage(imageStruct &image)
this->comp_ysize = image.ysize;
//Destroy cv_images to clean memory
- cvReleaseImage(&orig);
- cvReleaseImage(&gray);
- cvReleaseImage(&rgb);
+ if ( rgb )
+ {
+ cvReleaseImage(&orig);
+ cvReleaseImage(&gray);
+ cvReleaseImage(&rgb);
+ }
//create the orig image with new size
+ orig = cvCreateImage(cvSize(image.xsize,image.ysize), IPL_DEPTH_8U, 4);
rgb = cvCreateImage(cvSize(image.xsize,image.ysize), IPL_DEPTH_8U, 3);
gray = cvCreateImage(cvSize(rgb->width,rgb->height), IPL_DEPTH_8U, 1);