Skip to content

Commit

Permalink
fix invalid access if we are missing a multi-cam (i.e. we would get a…
Browse files Browse the repository at this point in the history
…n error if we have processed cam0 and cam2 but cam1 has not given any images yet)
  • Loading branch information
goldbattle committed Mar 25, 2020
1 parent d259f61 commit 85987c5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ov_core/src/track/TrackBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@ void TrackBase::display_active(cv::Mat &img_out, int r1, int g1, int b1, int r2,
if(image_new) img_out = cv::Mat(max_height,(int)img_last.size()*max_width,CV_8UC3,cv::Scalar(0,0,0));

// Loop through each image, and draw
int index_cam = 0;
for(auto const& pair : img_last) {
// Lock this image
std::unique_lock<std::mutex> lck(mtx_feeds.at(pair.first));
// select the subset of the image
cv::Mat img_temp;
if(image_new) cv::cvtColor(img_last[pair.first], img_temp, CV_GRAY2RGB);
else img_temp = img_out(cv::Rect(max_width*pair.first,0,max_width,max_height));
else img_temp = img_out(cv::Rect(max_width*index_cam,0,max_width,max_height));
// draw, loop through all keypoints
for(size_t i=0; i<pts_last[pair.first].size(); i++) {
// Get bounding pts for our boxes
Expand All @@ -74,7 +75,8 @@ void TrackBase::display_active(cv::Mat &img_out, int r1, int g1, int b1, int r2,
// Draw what camera this is
cv::putText(img_temp, "CAM:"+std::to_string((int)pair.first), cv::Point(30,60), cv::FONT_HERSHEY_COMPLEX_SMALL, 3.0, cv::Scalar(0,255,0),3);
// Replace the output image
img_temp.copyTo(img_out(cv::Rect(max_width*pair.first,0,img_last[pair.first].cols,img_last[pair.first].rows)));
img_temp.copyTo(img_out(cv::Rect(max_width*index_cam,0,img_last[pair.first].cols,img_last[pair.first].rows)));
index_cam++;
}

}
Expand Down Expand Up @@ -113,13 +115,14 @@ void TrackBase::display_history(cv::Mat &img_out, int r1, int g1, int b1, int r2
size_t maxtracks = (size_t)-1;

// Loop through each image, and draw
int index_cam = 0;
for(auto const& pair : img_last) {
// Lock this image
std::unique_lock<std::mutex> lck(mtx_feeds.at(pair.first));
// select the subset of the image
cv::Mat img_temp;
if(image_new) cv::cvtColor(img_last[pair.first], img_temp, CV_GRAY2RGB);
else img_temp = img_out(cv::Rect(max_width*pair.first,0,max_width,max_height));
else img_temp = img_out(cv::Rect(max_width*index_cam,0,max_width,max_height));
// draw, loop through all keypoints
for(size_t i=0; i<ids_last[pair.first].size(); i++) {
// Get the feature from the database
Expand Down Expand Up @@ -154,7 +157,8 @@ void TrackBase::display_history(cv::Mat &img_out, int r1, int g1, int b1, int r2
// Draw what camera this is
cv::putText(img_temp, "CAM:"+std::to_string((int)pair.first), cv::Point(30,60), cv::FONT_HERSHEY_COMPLEX_SMALL, 3.0, cv::Scalar(0,255,0),3);
// Replace the output image
img_temp.copyTo(img_out(cv::Rect(max_width*pair.first,0,img_last[pair.first].cols,img_last[pair.first].rows)));
img_temp.copyTo(img_out(cv::Rect(max_width*index_cam,0,img_last[pair.first].cols,img_last[pair.first].rows)));
index_cam++;
}

}
Expand Down

0 comments on commit 85987c5

Please # to comment.