Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

I think imaqRake function has some problem

I am machine vision developer using Visual C++
At first I have some problem in 'imaqFindEdge'
but When I debug the function of 'imaqFindEdge' I found that 'imaqRake' fuction has some problem.
The problem is that
return struct of this fuction 'RakeReport *' didn't free exactly well by 'imaqDispose' fuction
When I run my test program, free space of my memory in my computer being reduced more and more...
Please NI develp engineer should answer of my qeustion.
thanks.

reportToProcess = imaqRake( m_pGrabImage, tempROI, IMAQ_LEFT_TO_RIGHT, IMAQ_FIRST, &optionsToUse );

imaqDispose( reportToProcess );
0 Kudos
Message 1 of 7
(5,172 Views)
You might want to post this question on the Vision forum to get the best answer.

- Elton
0 Kudos
Message 2 of 7
(5,172 Views)
Do you have the latests updates from,
http://digital.ni.com/softlib.nsf/webcategories/85256410006C055586256BE60070436D?opendocument&node=132060_US ? The latest service pack for your OS?
0 Kudos
Message 3 of 7
(5,172 Views)
I have the exact same problem.

Updating to 6.0.5 has absolutely no effect.

I have attached a MSVC 7 solution with the reproducable leak.
0 Kudos
Message 4 of 7
(5,173 Views)

Hi,

Actually, I am using the function imaqFindCircularEdge, I found the memory leakage in this function - imaqSpoke. Even I have used the imaqDispose to free the memory of SpokeReport. The problem may similar to the case of http://forums.ni.com/ni/board/message?board.id=200&message.id=1977&query.id=163957#M1977. which is frist posted on 03-31-2003 08:41 PM

I am using the updatest version, 8.2, developing the program under Microsoft Visual studio 6.0

Can anyone help me to solve this problem asap?

Thanks

=========================================================================

void  TestEdge1(Image* image, Annulus searchArea, SpokeDirection direction, const FindEdgeOptions* options, const CoordinateTransform2* transform)

 {

    CircularEdgeReport* reportToReturn = NULL;
    ROI* tempROI;
    ContourID rectID;
    SpokeReport* reportToProcess=NULL;
    SpokeOptions optionsToUse;
   
    // Create an ROI, place the annulus contour inside it and set the contour color
    tempROI = imaqCreateROI();
    if ( tempROI == NULL ) {
        return;
    }
    rectID = imaqAddAnnulusContour (tempROI, searchArea);

 optionsToUse.threshold = options->threshold;
 optionsToUse.width = options->width;
 optionsToUse.steepness = options->steepness;
 optionsToUse.subsamplingRatio = options->subsamplingRatio;
 optionsToUse.subpixelType = IMAQ_CUBIC_SPLINE;
 optionsToUse.subpixelDivisions = DEFAULT_SUBPIXEL_DIVISIONS;

    // Calculate the edge locations
    if ( (reportToProcess = imaqSpoke( image, tempROI, direction, IMAQ_FIRST, &optionsToUse )) == NULL ) {
        imaqPrepareForExit( imaqGetLastError(), imaqFindCircularEdgeErrorString, tempROI, NULL );
        return ;
    }  
 imaqDispose(reportToProcess);
    imaqDispose(tempROI);
}

===================================================================================================

0 Kudos
Message 5 of 7
(4,958 Views)

Hello chris_cb750,

I took a closer look at the IMAQ Rake and IMAQ Spoke functions.  IMAQ Spoke is actually completely separate and doesn’t use IMAQ Rake in any way.  The issue with IMAQ Rake was fixed as of version 8.2 and although this shouldn’t be related, it may be similar.

We would like to recreate the issue you are experiencing here on our end.  In order to make sure we see the exact same behavior, we have two questions that will help us isolate the issue as quickly as possible:


  1. How are you observing the memory leakage?  Are you watching the program’s memory usage in Task Manager, or something else?
  2. Would it be possible for you to post a small program demonstrates the issue so that we can run it on our end and observe the same behavior?

Regards,
Luke H
Applications Engineering
National Instruments

0 Kudos
Message 6 of 7
(4,931 Views)

Hello Luke H.
I found the similar look in 'imaqFindEdge2' function.

Every time I call this function, my pc's memory continues to increase.

I tested the 'imaqrake' and 'imaqrake2', but It had no problems.

I observed the memory in Task Manager.

Below is a simple example and PC specs.

If you continue to call the function in the for loop, memory continues to increase.

Second, If I used the 'imaqMergeOverlay' function, pagefault is increase.

Is there a problem if the page fault is increasing?

I felt the process is slow.

I need a help..

 

<specs>

OS : Window 7 professional SP1 64bit

RAM : 4GB

CPU : Intel Core i7

programming tool : Visual Studio 2008

 

<example>

void test(void)

{

          Image                            *img = NULL;
          ROI                                *roi = NULL;

          FindEdgeReport         *findEdgeReport = NULL;
          EdgeOptions2             edgeOptions;
          FindEdgeOptions2     findEdgeOptions;
          StraightEdgeOptions straightEdgeOptions;

          int                                   err;

 

          img = imaqCreateImage(IMAQ_IMAGE_U8, 7);
          err = imaqReadFile(img, "E:\\tmp\\h4_0.bmp", NULL, NULL);
          if(err < ERR_SUCCESS)
          {

                     imaqDispose(img);
                     return;
          }

               

          edgeOptions.polarity = IMAQ_SEARCH_FOR_ALL_EDGES;
          edgeOptions.kernelSize = 3;
          edgeOptions.width = 5;
          edgeOptions.minThreshold = 50;
          edgeOptions.interpolationType = IMAQ_BILINEAR_FIXED;
          edgeOptions.columnProcessingMode = IMAQ_AVERAGE_COLUMNS;

 

          findEdgeOptions.direction = IMAQ_LEFT_TO_RIGHT;
          findEdgeOptions.showSearchArea = TRUE;
          findEdgeOptions.showSearchLines = TRUE;
          findEdgeOptions.showEdgesFound = TRUE;
          findEdgeOptions.showResult = FALSE;
          findEdgeOptions.searchAreaColor = IMAQ_RGB_GREEN;
          findEdgeOptions.searchLinesColor = IMAQ_RGB_BLUE;
          findEdgeOptions.searchEdgesColor = IMAQ_RGB_RED;
          findEdgeOptions.resultColor = IMAQ_RGB_GREEN;
          findEdgeOptions.overlayGroupName = NULL;
          findEdgeOptions.edgeOptions = edgeOptions;

 

          straightEdgeOptions.numLines = 1;
          straightEdgeOptions.searchMode = IMAQ_USE_FIRST_RAKE_EDGES;
          straightEdgeOptions.minScore = 10;
          straightEdgeOptions.maxScore = 1000;
          straightEdgeOptions.orientation = 0;
          straightEdgeOptions.angleRange = 45;
          straightEdgeOptions.angleTolerance = 1;
          straightEdgeOptions.stepSize = 2;
          straightEdgeOptions.minSignalToNoiseRatio = 0;
          straightEdgeOptions.minCoverage = 25;
          straightEdgeOptions.houghIterations = 5;


          // Creates a new, empty region of interest.
          roi = imaqCreateROI();

 

          // Creates a new rectangle ROI contour and adds the rectangle to the provided ROI.
          err = imaqAddRotatedRectContour(roi, imaqMakeRotatedRectFromRect(rect); // 'rect' is test example
          if(err < ERR_SUCCESS)
          {
                    imaqDispose(img);
                    imaqDispose(roi);
                    return;
          }

          findEdgeReport = imaqFindEdge2(img, roi, NULL, NULL, &findEdgeOptions, &straightEdgeOptions);
          if(findEdgeReport == NULL)
          {
                    printf("Find Edge Fail !!\n");
          }
          else
          {
                    printf("Find Edge Success ..\n");
                    imaqDispose(findEdgeReport);
          }

          imaqDispose(img);
          imaqDispose(roi);

}

0 Kudos
Message 7 of 7
(3,714 Views)