Add draw img data

This commit is contained in:
John Zhao 2018-05-11 10:14:58 +08:00
parent 63105b5ae4
commit c74ebb3cd5
3 changed files with 30 additions and 1 deletions

View File

@ -67,6 +67,32 @@ cv::Rect CVPainter::DrawSize(const cv::Mat &img, const gravity_t &gravity) {
return DrawText(img, ss.str(), gravity, 5);
}
cv::Rect CVPainter::DrawImgData(
const cv::Mat &img, const mynteye::ImgData &data,
const gravity_t &gravity) {
int sign = 1;
if (gravity == BOTTOM_LEFT || gravity == BOTTOM_RIGHT)
sign = -1;
std::ostringstream ss;
ss << "frame_id: " << data.frame_id << ", stamp: " << data.timestamp
<< ", expo: " << data.exposure_time;
cv::Rect rect_i = DrawText(img, ss.str(), gravity, 5);
Clear(ss) << "size: " << img.cols << "x" << img.rows;
cv::Rect rect_s =
DrawText(img, ss.str(), gravity, 5, 0, sign * (5 + rect_i.height));
// rect_i.width is the max one
if (sign > 0) {
return cv::Rect(
rect_i.tl(),
cv::Point(rect_i.x + rect_i.width, rect_s.y + rect_s.height));
} else {
return cv::Rect(rect_s.tl(), rect_i.br());
}
}
cv::Rect CVPainter::DrawImuData(
const cv::Mat &img, const mynteye::ImuData &data,
const gravity_t &gravity) {

View File

@ -34,6 +34,9 @@ class CVPainter {
~CVPainter();
cv::Rect DrawSize(const cv::Mat &img, const gravity_t &gravity = TOP_LEFT);
cv::Rect DrawImgData(
const cv::Mat &img, const mynteye::ImgData &data,
const gravity_t &gravity = TOP_LEFT);
cv::Rect DrawImuData(
const cv::Mat &img, const mynteye::ImuData &data,
const gravity_t &gravity = TOP_RIGHT);

View File

@ -57,7 +57,7 @@ int main(int argc, char *argv[]) {
}
*/
painter.DrawSize(img);
painter.DrawImgData(img, *left_data.img);
if (!motion_datas.empty()) {
painter.DrawImuData(img, *motion_datas[0].imu);
}