c++ - Error while pushing a std::pair in std::vector -
i found doing force in
template < class a, class b > std::vector < std::pair < a, b > >::push_back(...) almost creates segmentation fault.
i looked around bit , found there error beingness raised stl_uninitialized.h (line 269).
the easiest work around found reserve required / big space vector , force back. worked i'm not convinced. why there error
(my initial code not templated. fields
std::pair < float, cv::rotatedrect > i templated here people able give generic answers).
declaration of localdetections :
std::vector < std::vector < std::pair < float, cv::rotatedrect> > > localdetections; localdetections.resize(m_allsizes.size());
where m_allsizes vector of no. of sizes used search , populate . status :
for (int sit down = 0 ; sit down < m_allsizes.size(); sit++) {
place used :
cv::rotatedrect ouprect; cv::point2d src_center(img.cols/2., img.rows/2.); rotaterectinspace(newrect, ouprect, src_center, -(rotatedangle)); std::pair<float, cv::rotatedrect> newpair((float)finval, ouprect); localdetections[sit].push_back(newpair); sit variable in loop goes 0 through size of localdectections.
there potential bug in code sit overflow negative numbers. may want convert sit vector::size_type, or utilize iterators, or push_back vectors onto localdetections part of loop instead of resizing beforehand.
alternatively, bad may going on when trying re-create or assign cv::rotatedrect ouprect.
there lot of unknowns on one. there's nil wrong code posted. debugger going help more stackoverflow.
c++ vector stl std-pair
No comments:
Post a Comment