Go to Post I don't hate many things, but time-wasting and false dilemmas are amongst the few. - Manoel [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Spotlight this post!  
Unread 30-01-2012, 03:54
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: GetParticleAnalysisReport causes crash

If you take a look at the source code of GetParticleAnalysisReport:
Code:
/**
 * Get a single particle analysis report.
 * Get one (of possibly many) particle analysis reports for an image.
 * This version could be more efficient when copying many reports.
 * @param particleNumber Which particle analysis report to return.
 * @param par the selected particle analysis report
 */
void BinaryImage::GetParticleAnalysisReport(int particleNumber, ParticleAnalysisReport *par)
{
 int success;
 int numParticles = 0;
 success = imaqGetImageSize(m_imaqImage, &par->imageWidth, &par->imageHeight);
 wpi_setImaqErrorWithContext(success, "Error getting image size");
 if (StatusIsFatal())
  return;
 success = imaqCountParticles(m_imaqImage, 1, &numParticles);
 wpi_setImaqErrorWithContext(success, "Error counting particles");
 if (StatusIsFatal())
  return;
 if (particleNumber >= numParticles)
 {
  wpi_setWPIErrorWithContext(ParameterOutOfRange, "particleNumber");
  return;
 }
 par->particleIndex = particleNumber;
 // Don't bother measuring the rest of the particle if one fails
 bool good = ParticleMeasurement(particleNumber, IMAQ_MT_CENTER_OF_MASS_X, &par->center_mass_x);
 good = good && ParticleMeasurement(particleNumber, IMAQ_MT_CENTER_OF_MASS_Y, &par->center_mass_y);
 good = good && ParticleMeasurement(particleNumber, IMAQ_MT_AREA, &par->particleArea);
 good = good && ParticleMeasurement(particleNumber, IMAQ_MT_BOUNDING_RECT_TOP, &par->boundingRect.top);
 good = good && ParticleMeasurement(particleNumber, IMAQ_MT_BOUNDING_RECT_LEFT, &par->boundingRect.left);
 good = good && ParticleMeasurement(particleNumber, IMAQ_MT_BOUNDING_RECT_HEIGHT, &par->boundingRect.height);
 good = good && ParticleMeasurement(particleNumber, IMAQ_MT_BOUNDING_RECT_WIDTH, &par->boundingRect.width);
 good = good && ParticleMeasurement(particleNumber, IMAQ_MT_AREA_BY_IMAGE_AREA, &par->particleToImagePercent);
 good = good && ParticleMeasurement(particleNumber, IMAQ_MT_AREA_BY_PARTICLE_AND_HOLES_AREA, &par->particleQuality);
 if (good)
 {
  /* normalized position (-1 to 1) */
  par->center_mass_x_normalized = NormalizeFromRange(par->center_mass_x, par->imageWidth);
  par->center_mass_y_normalized = NormalizeFromRange(par->center_mass_y, par->imageHeight);
 }
}
You will see that the parameter par is a pointer to the particle analysis report. The code is expecting the pointer is pointing to something. But the code that called the function passed in an uninitialized ParticleAnalysisReport pointer. That will caused an exception for sure. Where did you copy this code from? It should have a line allocating/initializing the ParticleAnalysisReport before passing it to the function.
__________________
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 15:07.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi