View Single Post
  #20   Spotlight this post!  
Unread 18-09-2013, 11:28
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Sample Vision Code, ComputeThreshold() exception

Code:
BinaryImage *thresholdImage = image->ThresholdHSV(threshold);
It looks like you're trying to create a pointer and store something in what it points to at the same time. That will write over an undefined area in memory. Or maybe you're just setting it to something that won't fit in a pointer, and thus overwriting memory that way?

Don't do that.

Instead, declare the pointer, then allocate memory and set the pointer to point to the newly allocated memory. Only after that's done can you dereference the pointer. Alternatively, you might want to create thresholdImage as a BinaryImage instead of a pointer to one.
Reply With Quote