Skip to content

Commit d96a054

Browse files
authored
[debug] adapt VisualDebug for recent OpenCV (#162)
* [debug] adapt VisualDebug for recent OpenCV * remove error output in Parameters destructor # Conflicts: # src/cctag/Params.cpp * [feature] catch boost xml_iarchive exception: exit instead of crash
1 parent 6f9fa2a commit d96a054

File tree

4 files changed

+29
-9
lines changed

4 files changed

+29
-9
lines changed

src/applications/detection/main.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,16 @@ int main(int argc, char** argv)
236236
// Read the parameter file provided by the user
237237
std::ifstream ifs(cmdline._paramsFilename);
238238
boost::archive::xml_iarchive ia(ifs);
239-
ia >> boost::serialization::make_nvp("CCTagsParams", params);
239+
try
240+
{
241+
ia >> boost::serialization::make_nvp("CCTagsParams", params);
242+
}
243+
catch(boost::archive::archive_exception& e)
244+
{
245+
std::cerr << std::endl << "Exception while reading parameter file: "
246+
<< e.what() << std::endl;
247+
return EXIT_FAILURE;
248+
}
240249
CCTAG_COUT(params._nCrowns);
241250
CCTAG_COUT(nCrowns);
242251
if(nCrowns != params._nCrowns)

src/cctag/Params.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ Parameters::Parameters(std::size_t nCrowns)
7979
}
8080
}
8181

82+
Parameters::~Parameters( )
83+
{
84+
/* the default destructor does not prevent an unknown race condition on delete */
85+
}
86+
8287
void Parameters::setDebugDir(const std::string& debugDir)
8388
{
8489
namespace fs = boost::filesystem;

src/cctag/Params.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ struct Parameters
116116
*/
117117
explicit Parameters(std::size_t nCrowns = kDefaultNCrowns);
118118

119+
~Parameters( );
120+
119121
/// canny low threshold
120122
float _cannyThrLow;
121123
/// canny high threshold

src/cctag/utils/VisualDebug.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,12 @@ void CCTagVisualDebug::drawText(const cctag::Point2d<Eigen::Vector3f> & p, const
134134
CvFont font1;
135135
cvInitFont(&font1, CV_FONT_HERSHEY_SIMPLEX, 0.8, 0.8, 0, 2);
136136

137-
IplImage iplBack = _backImage;
138-
cvPutText( &iplBack, text.c_str(),
139-
cvPoint((int) p.x(), (int) p.y()),
140-
&font1, CV_RGB(color[0] * 255, color[1] * 255, color[2] * 255));
137+
auto clr = CV_RGB(color[0] * 255, color[1] * 255, color[2] * 255);
138+
cv::Mat iplBack = _backImage;
139+
cv::putText( iplBack, text.c_str(),
140+
cvPoint((int) p.x(), (int) p.y()),
141+
font1.font_face, font1.hscale,
142+
clr );
141143
#endif
142144
}
143145

@@ -262,10 +264,12 @@ void CCTagVisualDebug::drawInfos(const cctag::CCTag& marker, bool drawScaledMark
262264
y = int (marker.outerEllipse().center().y());
263265
}
264266

265-
IplImage iplImg = _backImage;
266-
cvPutText( &iplImg, sId.c_str(),
267-
cvPoint(x-10, y+10),
268-
&font1, CV_RGB(255, 140, 0));
267+
auto clr = CV_RGB(255, 140, 0);
268+
cv::Mat iplImg = _backImage;
269+
cv::putText( iplImg, sId.c_str(),
270+
cvPoint(x-10, y+10),
271+
font1.font_face, font1.hscale,
272+
clr );
269273
#endif
270274
}
271275

0 commit comments

Comments
 (0)