helloworld.cpp
1 |
//#include <rsb/Factory.h>
|
---|---|
2 |
//#include <rsb/Handler.h>
|
3 |
//#include <rsb/converter/Repository.h>
|
4 |
//#include <rsb/converter/ProtocolBufferConverter.h>
|
5 |
|
6 |
//#include <rst/vision/SimpleXYZImage.pb.h>
|
7 |
|
8 |
#include <highgui.h> |
9 |
#include <cv.h> |
10 |
|
11 |
#include <rsb/Factory.h> |
12 |
#include <rsb/Handler.h> |
13 |
#include <rsb/converter/Repository.h> |
14 |
#include <rsb/converter/ProtocolBufferConverter.h> |
15 |
|
16 |
#include <rst/vision/SimpleXYZImage.pb.h> |
17 |
|
18 |
using namespace std; |
19 |
using namespace rsb; |
20 |
using namespace rsb::converter; |
21 |
|
22 |
using namespace rst::vision; |
23 |
|
24 |
//using namespace cv;
|
25 |
|
26 |
void printImage(boost::shared_ptr<SimpleXYZImage> image) {
|
27 |
//// float *a = image->mutable_data()->mutable_data();
|
28 |
cout << "received " << image->width() << "x" << image->height() << " image: " |
29 |
//// << a[0] << " " << a[1]
|
30 |
<< endl; |
31 |
//cout << "print" << endl;
|
32 |
} |
33 |
|
34 |
int main ( int argc, char **argv ) |
35 |
{ |
36 |
|
37 |
// Register a specific template instanciation of the
|
38 |
// ProtocolBufferConverter for our SimpleXYZImage protocol buffer
|
39 |
// message.
|
40 |
boost::shared_ptr<ProtocolBufferConverter<SimpleXYZImage> > converter( |
41 |
new ProtocolBufferConverter<SimpleXYZImage> ());
|
42 |
stringConverterRepository()->registerConverter(converter); |
43 |
|
44 |
// Create a listener to receive SimpleImage protocol buffer
|
45 |
// messages.
|
46 |
ListenerPtr listener = Factory::getInstance().createListener( |
47 |
Scope("/bla"));
|
48 |
|
49 |
while(1){ |
50 |
|
51 |
|
52 |
listener->addHandler( |
53 |
HandlerPtr(new DataFunctionHandler<SimpleXYZImage> (&printImage)));
|
54 |
|
55 |
// Mat img(480, 640, CV_8UC3, Scalar(0));
|
56 |
// putText(img, "Hello World!", Point(200, 400),
|
57 |
// FONT_HERSHEY_SIMPLEX, 1.0,
|
58 |
// Scalar(255, 255, 0));
|
59 |
//
|
60 |
// namedWindow("image", CV_WINDOW_AUTOSIZE);
|
61 |
// imshow("image", img);
|
62 |
// cvShowImage( "My Window", img );
|
63 |
|
64 |
// waitKey();
|
65 |
} |
66 |
|
67 |
return 0; |
68 |
|
69 |
} |
70 |
|