diff options
author | Jan Schmidt <jan@centricular.com> | 2017-04-14 01:56:50 +1000 |
---|---|---|
committer | Jan Schmidt <jan@centricular.com> | 2017-04-14 01:58:11 +1000 |
commit | b392ab4bcdaa292ac93eab703fb54d519f653ab4 (patch) | |
tree | 60c4334a68544c9f852531b2cb314725108ec3f5 | |
parent | 5b458bf8299566d0f183349756b4bfb8358ec2e3 (diff) | |
download | gstreamer-plugins-bad-b392ab4bcdaa292ac93eab703fb54d519f653ab4.tar.gz |
motioncells: Fix cell string generation
Allow 1 extra char in the tmp buffer where the motion cell
snippets are generated, so that it doesn't leave off a comma
when dealing with cells that have 2 numerals in both indices
-rw-r--r-- | ext/opencv/MotionCells.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/ext/opencv/MotionCells.cpp b/ext/opencv/MotionCells.cpp index 94c4ae58c..f85989e11 100644 --- a/ext/opencv/MotionCells.cpp +++ b/ext/opencv/MotionCells.cpp @@ -199,11 +199,10 @@ MotionCells::performDetectionMotionCells (IplImage * p_frame, cvSetZero (transparencyimg); if (m_motioncellsidxcstr) delete[]m_motioncellsidxcstr; - m_motioncells_idx_count = m_MotionCells.size () * MSGLEN; //one motion cell idx: (lin idx : col idx,) it's 4 character except last motion cell idx + m_motioncells_idx_count = m_MotionCells.size () * MSGLEN; //one motion cell idx: (lin idx : col idx,) it's up to 6 character except last motion cell idx m_motioncellsidxcstr = new char[m_motioncells_idx_count]; - char *tmpstr = new char[MSGLEN]; - for (int i = 0; i < MSGLEN; i++) - tmpstr[i] = ' '; + char *tmpstr = new char[MSGLEN+ 1]; + tmpstr[0] = 0; for (unsigned int i = 0; i < m_MotionCells.size (); i++) { CvPoint pt1, pt2; pt1.x = m_MotionCells.at (i).cell_pt1.x * 2; @@ -227,10 +226,10 @@ MotionCells::performDetectionMotionCells (IplImage * p_frame, } if (i < m_MotionCells.size () - 1) { - snprintf (tmpstr, MSGLEN, "%d:%d,", m_MotionCells.at (i).lineidx, + snprintf (tmpstr, MSGLEN+1, "%d:%d,", m_MotionCells.at (i).lineidx, m_MotionCells.at (i).colidx); } else { - snprintf (tmpstr, MSGLEN, "%d:%d", m_MotionCells.at (i).lineidx, + snprintf (tmpstr, MSGLEN+1, "%d:%d", m_MotionCells.at (i).lineidx, m_MotionCells.at (i).colidx); } if (i == 0) |