-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDrawLocalization.cpp
More file actions
executable file
·44 lines (34 loc) · 1.34 KB
/
DrawLocalization.cpp
File metadata and controls
executable file
·44 lines (34 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* @file DrawLocalization.cpp
* @ingroup Drawing
* @author Dominique Vaufreydaz, Grenoble Alpes University, Inria
* @copyright All right reserved.
*/
#include "DrawLocalization.h"
using namespace cv;
using namespace MobileRGBD;
/** @brief ProcessElement is a callback function called by mother classes when data are ready.
*
* @param RequestTimestamp [in] The timestamp of the data.
* @param UserData [in] User pointer to working data. Here a pointer to a cv:Mat to draw in.
*/
bool DrawLocalization::ProcessElement( const TimeB &RequestTimestamp, void * UserData )
{
cv::Mat& WhereToDraw = *((cv::Mat*)UserData);
float x, y, o;
if ( (sscanf(DataBuffer, "{\"x\":%f,\"y\":%f,\"o\":%f}", &x, &y, &o )) != 3 )
{
return false;
}
char tmpc[512];
sprintf( tmpc, "X=%.3f Y=%.3f O=%.3f", x, y, o );
int baseline = 0;
Size TSize;
baseline = 0;
TSize = getTextSize(tmpc, FONT_HERSHEY_COMPLEX, 0.5, 1, &baseline);
putText( WhereToDraw, tmpc, Point((WhereToDraw.cols)/2-TSize.width/2,TSize.height+5), FONT_HERSHEY_COMPLEX, 0.5, Scalar(0, 0, 0), 1, 8 );
// We render flip images, thus flip it, it will be flap back after global flip on the whole image
// cv::Mat ToFlip( WhereToDraw, Rect((WhereToDraw.cols)/2-TSize.width/2,0,TSize.width,TSize.height+5) );
flip( WhereToDraw, WhereToDraw, 1 );
return true;
}