summaryrefslogtreecommitdiff
path: root/ext/opencv
diff options
context:
space:
mode:
authorLuis de Bethencourt <luis.bg@samsung.com>2015-03-05 15:54:55 +0000
committerLuis de Bethencourt <luis.bg@samsung.com>2015-03-05 15:56:44 +0000
commit290508932e64ef1b1e518ad216157e4969810b8e (patch)
tree0ee6bf8a15865e01b45113c9a250364cceb7c0d7 /ext/opencv
parent632854eba3b97f0d52076fa3b9f6c9298fbe0847 (diff)
downloadgstreamer-plugins-bad-290508932e64ef1b1e518ad216157e4969810b8e.tar.gz
motioncells: protect against not found id
If searchIdx() doesn't find the id it returns -1, which breaks motioncelssvector.at (idx). Check for it and return if not found. Changing a few other lines for style consistency.
Diffstat (limited to 'ext/opencv')
-rw-r--r--ext/opencv/motioncells_wrapper.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/ext/opencv/motioncells_wrapper.cpp b/ext/opencv/motioncells_wrapper.cpp
index dc52443ee..e9794cffb 100644
--- a/ext/opencv/motioncells_wrapper.cpp
+++ b/ext/opencv/motioncells_wrapper.cpp
@@ -89,12 +89,15 @@ perform_detection_motion_cells (IplImage * p_image, double p_sensitivity,
{
int idx = 0;
idx = searchIdx (p_id);
- return motioncellsvector.at (idx).mc->performDetectionMotionCells (p_image,
- p_sensitivity, p_framerate, p_gridx, p_gridy, p_timestamp_millisec,
- p_isVisible, p_useAlpha, motionmaskcoord_count, motionmaskcoords,
- motionmaskcells_count, motionmaskcellsidx, motioncellscolor,
- motioncells_count, motioncellsidx, starttime, p_datafile,
- p_changed_datafile, p_thickness);
+ if (idx > -1)
+ return motioncellsvector.at (idx).mc->performDetectionMotionCells (p_image,
+ p_sensitivity, p_framerate, p_gridx, p_gridy, p_timestamp_millisec,
+ p_isVisible, p_useAlpha, motionmaskcoord_count, motionmaskcoords,
+ motionmaskcells_count, motionmaskcellsidx, motioncellscolor,
+ motioncells_count, motioncellsidx, starttime, p_datafile,
+ p_changed_datafile, p_thickness);
+ else
+ return -1;
}
@@ -103,7 +106,8 @@ setPrevFrame (IplImage * p_prevFrame, int p_id)
{
int idx = 0;
idx = searchIdx (p_id);
- motioncellsvector.at (idx).mc->setPrevFrame (p_prevFrame);
+ if (idx > -1)
+ motioncellsvector.at (idx).mc->setPrevFrame (p_prevFrame);
}
char *
@@ -113,10 +117,8 @@ getMotionCellsIdx (int p_id)
idx = searchIdx (p_id);
if (idx > -1)
return motioncellsvector.at (idx).mc->getMotionCellsIdx ();
- else {
+ else
return p_str;
- }
-
}
int
@@ -161,9 +163,8 @@ getInitDataFileFailed (int p_id)
idx = searchIdx (p_id);
if (idx > -1)
return motioncellsvector.at (idx).mc->getDatafileInitFailed ();
- else {
+ else
return p_str;
- }
}
char *
@@ -173,9 +174,8 @@ getSaveDataFileFailed (int p_id)
idx = searchIdx (p_id);
if (idx > -1)
return motioncellsvector.at (idx).mc->getDatafileSaveFailed ();
- else {
+ else
return p_str;
- }
}
int