MhLiao / TextBoxes_plusplus

TextBoxes++: A Single-Shot Oriented Scene Text Detector
Other
953 stars 279 forks source link

Where is the portion of code which detects the coordinates? #86

Closed JohnWnx closed 5 years ago

JohnWnx commented 5 years ago

Hi @MhLiao ,

Can I know where is the section (as mentioned in your paper below) on detecting the bounding box coordinates (x1,y1,x2,y2,x3,y3,x4,y4) in your code?

image

Thank you.

jiachen0212 commented 5 years ago

@JohnWnx maybe you can see the caffe_root/src/caffe/util/bbox_util.cpp
template void ComputeLocLoss(const Blob& loc_pred, const Blob& loc_gt, const vector<map<int, vector > >& all_match_indices, const int num, const int num_priors, const LocLossType loc_loss_type, vector<vector > all_loc_loss) { int loc_count = loc_pred.count(); CHECK_EQ(loc_count, loc_gt.count()); Blob diff; const Dtype diff_data = NULL; if (loc_count != 0) { diff.Reshape(loc_pred.shape()); caffe_sub(loc_count, loc_pred.cpu_data(), loc_gt.cpu_data(), diff.mutable_cpu_data()); diff_data = diff.cpu_data(); } int count = 0; for (int i = 0; i < num; ++i) { vector loc_loss(num_priors, 0.f); for (map<int, vector >::const_iterator it = all_match_indices[i].begin(); it != all_match_indices[i].end(); ++it) { const vector& match_index = it->second; CHECK_EQ(num_priors, match_index.size()); for (int j = 0; j < match_index.size(); ++j) { if (match_index[j] <= -1) { continue; } Dtype loss = 0; for (int k = 0; k < 4; ++k) { Dtype val = diff_data[count 4 + k]; // SmoothL1 funtion if (loc_loss_type == MultiBoxLossParameter_LocLossType_SMOOTH_L1) { Dtype abs_val = fabs(val); if (abs_val < 1.) { loss += 0.5 val val; } else { loss += abs_val - 0.5; } } else if (loc_loss_type == MultiBoxLossParameter_LocLossType_L2) { loss += 0.5 val * val; } else { LOG(FATAL) << "Unknown loc loss type."; } } loc_loss[j] = loss; ++count; } } all_loc_loss->push_back(loc_loss); } }