LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

imaqDetectCircles crashes with "General Protection" fault

I have an older application initially developed and running on the client setup on WinXP and using Vision 8.2, but after switching both my development station and client setup to Win7 and Vision 2010, it always crashes inside the imaqDetectCircles functions with General Protection fault. 

 

I cannot see any difference in the parameter structure or format of the function between Vision module versions, so does anyone know if the function is no longer supported and what alternate to use?

 

Here is a snipet with just the relevant code:

 

Image *pImageU8=NULL; 
CircleDescriptor *pSpotDescriptor=NULL;
CurveOptions *pCurveOptions=NULL;
CircleMatch *pCirclesFound=NULL;
int iCirclesFound=0;

// cast image to 8 bit 
pImageU8 = imaqCreateImage(IMAQ_IMAGE_U8,9);
imaqCast(pImageU8, g_pImage, IMAQ_IMAGE_U8, NULL, g_iImageBitDepth-8);

// prepare & start circles detection
pSpotDescriptor = malloc(sizeof(CircleDescriptor));
pSpotDescriptor->minRadius = g_iCircle_MinRadius;
pSpotDescriptor->maxRadius = g_iCircle_MaxRadius;

pCurveOptions = malloc(sizeof(CurveOptions));
pCurveOptions->extractionMode = g_iCurve_ExtractionMode;
pCurveOptions->threshold = g_iCurve_Threshold;
pCurveOptions->filterSize = g_iCurve_FilterSize;
pCurveOptions->minLength = g_iCurve_MinLength;
pCurveOptions->rowStepSize = g_iCurve_RowStepSize;
pCurveOptions->columnStepSize = g_iCurve_ColumnStepSize;
pCurveOptions->maxEndPointGap = g_iCurve_MaxEndPointGap;
pCurveOptions->onlyClosed = g_iCurve_OnlyClosed;
pCurveOptions->subpixelAccuracy = g_iCurve_SubPixelAccuracy;

pCirclesFound = imaqDetectCircles (pImageU8, pSpotDescriptor, pCurveOptions, NULL, NULL, &iCirclesFound);

 

 

 

0 Kudos
Message 1 of 6
(3,827 Views)

Hi Octavian84,

 

1) What software and version are you using to run this application?

2) What version of IMAQ are you using? This is listed in NI-MAX under Software.

3) Are you acquiring images from our hardware? If so, what framegrabber are you using?

 

4) Do you get an error code for the General Protection Fault? A screenshot of the full error may help to narrow down what is causing this issue.

 

According to the current documentation, I don't see anything wrong with the way you're implementing this function:

 

Searches for circles in an image.

 

Image Types Supported
IMAQ_IMAGE_U8


/*-------------------- Prototype ---------------------*/
CircleMatch *imaqDetectCircles (const Image *Image,
const CircleDescriptor
*Circle_Descriptor,
const CurveOptions
*Curve_Options,
const ShapeDetectionOptions
*Shape_Detection_Options,
const ROI *Roi,
int *Num_Matches_Returned);

 

Please post again with your versions and error code, and I can research what may be causing this behavior.

 

Thanks!

Emily C
Applications Engineer
National Instruments
0 Kudos
Message 2 of 6
(3,804 Views)

Hi Emily,

 

1) Labwindows CVI 2010 v10.0.0.360

2) Ni Vision v10.0.0.49152

3) No, the images are provided by a different setup in tif format. I've attached one. 

4) No specific error code. I can't use imaqGetLastError since it doesn't go past the circle detect function even with Break on Library Error unchecked. 

 

error.png

 

 

 

0 Kudos
Message 3 of 6
(3,790 Views)

Hi Octavian84,

 

It looks like this may be related to a known issue when upgrading from 8.5 to some newer versions. I'm looking into this, but could you please try setting the ROI to a value other than NULL and let me know what happens?

 

Thanks!

Emily C
Applications Engineer
National Instruments
0 Kudos
Message 4 of 6
(3,777 Views)

I didn't consider it, since the function help states to pass NULL to search on full image, but specifying the ROI seems to have fixed the issue.

 

Thanks.

 

 

0 Kudos
Message 5 of 6
(3,766 Views)
I'm sorry if you already know this, but I have found that with the Vision module you have to be VERY careful to ensure that you free memory allocated by Vision functions by calling imaqDispose when you have finished with them. This is because vision is not integrated with the CVI resource tracking system, and provides no other means of tracking memory use. It is very easy to be consuming memory with every new frame received from the camera. I found that keeping an eye on the process in Windows Task Manager was the only way of checking whether my programme was leaking memory through NI-Vision.
0 Kudos
Message 6 of 6
(3,755 Views)