I'm trying to find the cause of a crashing problem I'm having on my program.
This crash happens after some hours of execution. I ran it using gdb, which tells me in which line of code it crashed. Gdb tells me that the program has a floating point exeption segfault on the following line:
(*itCand)->setCandidateObjectData(centroid,
(*itCand)->_toSendCentroid,
bbox,
sumAreaFilled,
sumAreaEdges,
height ,
(*itCand)->_sumAreaMask / (*itCand)->_nTimesAlive,
(*itCand)->_sumAreaEdges / (*itCand)->_nTimesAlive,
(*itCand)->_sumHeight / (*itCand)->_nTimesAlive ,
sumAreaEdges,
height,
maxHeight,
false,
false,
false,
true,
hasChangedPosition);
This function assigns data to an object. The parameters sumAreaFilled, sumAreaEdges and height are incremental parameters that keep increasing every second of the execution, and for that reason they are of type unsigned long long, to avoid any memory issues.
The parameter nTimesAlive is initialized as 1, and keeps incrementing every frame aswell, so it can never be zero.
the rest of the operations are simple assignments, so I am thinking they are not the source of any issue, but I'll paste the function and the data type so that you can all the information necessary to grasp the problem.
class CandidateObject
{
public:
CandidateObject(const cv::Point centroid, const cv::Rect bboxNormal);
~CandidateObject();
void setCandidateObjectData(const cv::Point centroid, const cv::Point toSendCentroid, const cv::Rect bboxNormal,
const unsigned long long sumAreaMask, const unsigned long long sumAreaEdges, const unsigned long long sumHeight,
const double meanAreaMask, const double meanAreaEdges, const double meanHeight, const double instantEdgeArea, const double height,
const double maxHeight, const bool isToDelete, const bool isDuplicate, const bool isBeingDoubleChecked, const bool isMatched,
const bool hasChangedPosition);
cv::Point _centroid; //-- blob centroid
cv::Point _toSendCentroid; //-- blob centroid to send to the conversion function
cv::Rect _bboxNormal; //-- normal bounding box
unsigned long long _sumAreaMask; //-- pixel sum on object bounding box mask
unsigned long long _sumAreaEdges; //-- pixel sum on edge
unsigned long long _sumHeight; //-- sum of height instances
double _meanAreaMask; //-- mean of total instances of object area in bounding box mask
double _meanEdgeAreaMask; //-- mean of total instances of object area in the edge bounding box mask
double _meanHeight; //-- mean of total instances of object height
double _instantEdgeArea; //-- Area of edges that correspond to a certain object
unsigned short _nTimesAlive; //-- number of times blob appears
bool _isToDelete; //-- flag that indicates if candidate object is no longer valid and to be deleted from vector
bool _isDuplicate; //-- indicates if same object is detected multiple times
bool _isBeingDoubleChecked; //-- indicates if object is being double checked after first matching fails
bool _isMatched; //-- indicates if object has already been matched, in order to avoid unnecessary processing
bool _hasChangedPosition; //-- indicates if the object has changed its position significantly
double _height; //-- object height
double _maxHeight; //-- max height
unsigned int _label;
};
And the function:
void CandidateObject::setCandidateObjectData(const cv::Point centroid, const cv::Point toSendCentroid, const cv::Rect bboxNormal,
const unsigned long long sumAreaMask, const unsigned long long sumAreaEdges, const unsigned long long sumHeight,
const double meanAreaMask, const double meanAreaEdges, const double meanHeight, const double instantEdgeArea, const double height,
const double maxHeight, const bool isToDelete, const bool isDuplicate, const bool isBeingDoubleChecked, const bool isMatched, const bool hasChangedPosition)
{
_centroid = centroid;
_toSendCentroid = toSendCentroid;
_bboxNormal = bboxNormal;
_sumAreaMask += sumAreaMask;
_sumAreaEdges += sumAreaEdges;
_sumHeight += sumHeight;
_meanAreaMask = meanAreaMask;
_meanEdgeAreaMask = meanAreaEdges;
_meanHeight = meanHeight;
_instantEdgeArea = instantEdgeArea;
_isToDelete = isToDelete;
_isDuplicate = isDuplicate;
_isBeingDoubleChecked = isBeingDoubleChecked;
_isMatched = isMatched;
_height = height;
_maxHeight = maxHeight;
_hasChangedPosition = hasChangedPosition;
return;
}