View Single Post
  #5   Spotlight this post!  
Unread 30-01-2012, 12:00
bob.wolff68's Avatar
bob.wolff68 bob.wolff68 is offline
Da' Mentor Man
FRC #1967
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2007
Location: United States
Posts: 157
bob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nice
Re: GetParticleAnalysisReport causes crash

The prior post is fine as well, but if you're still wondering the subtlety of why yours didn't work originally, see the // **CHANGE** line here...

Code:
ColorImage* camerain = camera->GetImage();
BinaryImage* binImage = camerain->ThresholdHSL(0,9,0,5,250,255);
int numParticles = binImage->GetNumberParticles();
delete camerain;
ParticleAnalysisReport report; // **CHANGE** - instantiates the real object and not just a pointer to it...(and then below...)
for(int i = 1; i<=numParticles; i++)
{
    binImage->GetParticleAnalysisReport(i,&report);  // **CHANGE** and now pass the address of the real object to the function so it can make modifications to your real object 'report' from above.
    // Other processing stuff
}
delete binImage;
The only other concern is it should be "for (i=0 ; i<numParticles; i++)" or you'll crash at the tail end of the for-loop for going out of bounds. Arrays in C always start with the '0' element ... not '1'.

bob
__________________
~~~~~~~~~~~~~~~~~~~
Bob Wolff - Software from the old-school
Mentor / C / C++ guy
Team 1967 - The Janksters - San Jose, CA
Reply With Quote