1 |
|
---|
2 | /* ************************************************************************************************************
|
---|
3 |
|
---|
4 | Program : example sending images with SAMGAR
|
---|
5 | Date : 24 Aug 2009
|
---|
6 | Author : K Du Casse
|
---|
7 |
|
---|
8 | A simple program that shows how to send images with SAMGAR
|
---|
9 |
|
---|
10 | ************************************************************************************************************ */
|
---|
11 |
|
---|
12 |
|
---|
13 |
|
---|
14 | // To use samgar you only need to attach the SamgarLib and the SamgarMainClass header
|
---|
15 | #include "cv.h"
|
---|
16 | #include "highgui.h"
|
---|
17 | #include <SamgarMainClass.h>
|
---|
18 |
|
---|
19 |
|
---|
20 | int main() {
|
---|
21 | Network yarp;
|
---|
22 | SamgarModule MyFirstTest2("CameraRecive","behaviour","happy",run); // Cant have spaces or underscores
|
---|
23 | MyFirstTest2.SetupImagePort("VideoIn");
|
---|
24 |
|
---|
25 | cvNamedWindow( "copy", CV_WINDOW_AUTOSIZE );
|
---|
26 |
|
---|
27 | while( 1 )
|
---|
28 | {
|
---|
29 | IplImage *frame2 = MyFirstTest2.RecivePictureOCVNative();
|
---|
30 |
|
---|
31 | if(frame2!=false) // if there is no image available (one hasn't been sent) then the image will be false
|
---|
32 | {
|
---|
33 | cvShowImage( "copy", frame2 ); // if its not false then display it.
|
---|
34 | }
|
---|
35 |
|
---|
36 | if( (cvWaitKey(10) & 255) == 27 ) break;
|
---|
37 | }
|
---|
38 |
|
---|
39 |
|
---|
40 | cvDestroyWindow( "copy" );
|
---|
41 | return 0;
|
---|
42 | }
|
---|
43 |
|
---|
44 |
|
---|
45 |
|
---|
46 |
|
---|
47 |
|
---|
48 |
|
---|
49 |
|
---|
50 |
|
---|
51 |
|
---|
52 |
|
---|
53 |
|
---|
54 |
|
---|
55 |
|
---|
56 |
|
---|
57 |
|
---|
58 |
|
---|
59 |
|
---|
60 |
|
---|
61 |
|
---|
62 |
|
---|
63 |
|
---|
64 |
|
---|
65 |
|
---|
66 |
|
---|
67 |
|
---|
68 |
|
---|
69 |
|
---|
70 |
|
---|
71 |
|
---|
72 |
|
---|
73 |
|
---|
74 |
|
---|
75 |
|
---|
76 |
|
---|
77 |
|
---|
78 |
|
---|
79 |
|
---|
80 |
|
---|
81 |
|
---|
82 |
|
---|
83 |
|
---|
84 |
|
---|
85 |
|
---|
86 |
|
---|
87 |
|
---|
88 |
|
---|
89 |
|
---|
90 |
|
---|
91 |
|
---|
92 |
|
---|
93 |
|
---|
94 |
|
---|
95 |
|
---|
96 |
|
---|
97 |
|
---|
98 |
|
---|
99 |
|
---|
100 |
|
---|
101 |
|
---|
102 |
|
---|
103 |
|
---|
104 |
|
---|
105 | /*
|
---|
106 |
|
---|
107 | #include "cv.h"
|
---|
108 | #include "highgui.h"
|
---|
109 |
|
---|
110 |
|
---|
111 | #include <stdio.h>
|
---|
112 | #include <SamgarMainClass.h>
|
---|
113 | using namespace std;
|
---|
114 |
|
---|
115 |
|
---|
116 | using namespace yarp::sig::draw;
|
---|
117 |
|
---|
118 | int main()
|
---|
119 | {
|
---|
120 | SamgarModule MyFirstTest1("Module1","behaviour","happy","Interupt"); // Cant have spaces or underscores
|
---|
121 | MyFirstTest1.SetupImagePort("VideoOut");
|
---|
122 |
|
---|
123 | SamgarModule MyFirstTest2("Module2","behaviour","happy","Interupt"); // Cant have spaces or underscores
|
---|
124 | MyFirstTest2.SetupImagePort("VideoIn");
|
---|
125 |
|
---|
126 | Network::connect("/Port_Module2_VideoIn_OCV","/Port_Module1_VideoOut_OCV","udp");
|
---|
127 | Network::connect("/Port_Module1_VideoOut_OCV","/Port_Module2_VideoIn_OCV","udp");
|
---|
128 | ImageOf<PixelBgr> yarpImage;
|
---|
129 | yarpImage.resize(300,200);
|
---|
130 | addCircle(yarpImage,PixelBgr(255,0,0),
|
---|
131 | yarpImage.width()/2,yarpImage.height()/2,
|
---|
132 | yarpImage.height()/4);
|
---|
133 |
|
---|
134 |
|
---|
135 | while(1)
|
---|
136 | {
|
---|
137 | // MyFirstTest1.SendPictureYarpNative
|
---|
138 |
|
---|
139 |
|
---|
140 | MyFirstTest1.SendPictureYarpNative(yarpImage);
|
---|
141 |
|
---|
142 | }
|
---|
143 |
|
---|
144 | }
|
---|
145 |
|
---|
146 |
|
---|
147 |
|
---|
148 | /*
|
---|
149 |
|
---|
150 | #include "cv.h"
|
---|
151 | #include "highgui.h"
|
---|
152 | #include <stdio.h>
|
---|
153 |
|
---|
154 |
|
---|
155 |
|
---|
156 | //#include <SamgarMainClass.h>
|
---|
157 | //using namespace std;
|
---|
158 |
|
---|
159 | int main (void)
|
---|
160 | {
|
---|
161 | //SamgarModule MyFirstTest("Module1","behaviour","happy","Interupt"); // Cant have spaces or underscores
|
---|
162 | //MyFirstTest.AddPort("output1");
|
---|
163 | //MyFirstTest.AddPort("output2");
|
---|
164 | //MyFirstTest.AddPort("output3");
|
---|
165 | //MyFirstTest.AddPort("output4");
|
---|
166 | //MyFirstTest.AddPort("output5");
|
---|
167 | //MyFirstTest.AddPort("output6");
|
---|
168 | //MyFirstTest.AddPort("output7");
|
---|
169 | //Network::connect("/Port_Module1_output7","/Port_Module2_output7");
|
---|
170 | //Network::connect("/Port_Module2_output7","/Port_Module1_output7");
|
---|
171 |
|
---|
172 | //static double xx = 1;
|
---|
173 | //string yy;
|
---|
174 |
|
---|
175 | cvNamedWindow( "mywindow", CV_WINDOW_AUTOSIZE );
|
---|
176 |
|
---|
177 | CvCapture* capture = cvCaptureFromCAM( CV_CAP_ANY );
|
---|
178 | if( !capture ) { fprintf( stderr, "ERROR: capture is NULL \n" ); getchar();return -1;}
|
---|
179 |
|
---|
180 | // MyFirstTest.SetupImagePort("VideoOut");
|
---|
181 |
|
---|
182 |
|
---|
183 |
|
---|
184 |
|
---|
185 |
|
---|
186 | while(1)
|
---|
187 | {
|
---|
188 | IplImage* frame = cvQueryFrame( capture );
|
---|
189 | if( !frame ) {fprintf( stderr, "ERROR: frame is null...\n" );getchar();break;}
|
---|
190 | cvShowImage( "mywindow", frame);
|
---|
191 | }
|
---|
192 |
|
---|
193 |
|
---|
194 | //sleep(10);
|
---|
195 | return 0;
|
---|
196 | }*/ |
---|