source: UH/SAMGAR/SAMGAR LIB/Trunk/TesterFiles/SamgarSendImage.cpp @ 187

Revision 187, 3.7 KB checked in by KDucasse, 10 years ago (diff)
Line 
1
2/* ************************************************************************************************************
3
4Program : example sending images with SAMGAR
5Date    : 24 Aug 2009
6Author  : K Du Casse
7
8A 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>
18using namespace std;
19
20int main() {
21Network yarp;
22        // Creates a module with a name , catagory , sub catagory , typeofmodule
23        SamgarModule MyFirstTest("CameraSend","behaviour","happy",run); // Cant have spaces or underscores
24
25        // then we setup the image port
26        MyFirstTest.SetupImagePort("VideoOut");
27
28 // OCV get a device
29  CvCapture* capture = cvCaptureFromCAM( CV_CAP_ANY );
30  // OCV make sure its there
31  if( !capture ) {fprintf( stderr, "ERROR: capture is NULL \n" );getchar();return -1;}
32
33 
34  cvNamedWindow( "original", CV_WINDOW_AUTOSIZE );
35
36  while( 1 )
37  {
38    IplImage* frame = cvQueryFrame( capture );
39    if( !frame ){fprintf( stderr, "ERROR: frame is null...\n" );getchar();break;}
40       
41   cvShowImage( "original", frame );
42        // send the frame
43        MyFirstTest.SendPictureOCVNative(frame);
44        MyFirstTest.SucceedFail(true,888);
45    if( (cvWaitKey(10) & 255) == 27 ) break;
46  }
47
48
49  cvReleaseCapture( &capture );
50  cvDestroyWindow( "original" );
51  return 0;
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
108
109
110
111
112
113
114
115/*
116
117#include "cv.h"
118#include "highgui.h"
119
120
121#include <stdio.h>
122#include <SamgarMainClass.h>
123using namespace std;
124
125
126using namespace yarp::sig::draw;
127
128int main()
129{
130SamgarModule MyFirstTest1("Module1","behaviour","happy","Interupt"); // Cant have spaces or underscores
131MyFirstTest1.SetupImagePort("VideoOut");
132
133SamgarModule MyFirstTest2("Module2","behaviour","happy","Interupt"); // Cant have spaces or underscores
134MyFirstTest2.SetupImagePort("VideoIn");
135
136Network::connect("/Port_Module2_VideoIn_OCV","/Port_Module1_VideoOut_OCV","udp");
137Network::connect("/Port_Module1_VideoOut_OCV","/Port_Module2_VideoIn_OCV","udp");
138 ImageOf<PixelBgr> yarpImage;
139                 yarpImage.resize(300,200);
140                 addCircle(yarpImage,PixelBgr(255,0,0),
141         yarpImage.width()/2,yarpImage.height()/2,
142         yarpImage.height()/4);
143
144
145while(1)
146        {
147        //      MyFirstTest1.SendPictureYarpNative
148
149           
150                 MyFirstTest1.SendPictureYarpNative(yarpImage);
151
152        }
153
154}
155
156
157
158/*
159
160#include "cv.h"
161#include "highgui.h"
162#include <stdio.h>
163
164
165
166//#include <SamgarMainClass.h>
167//using namespace std;
168
169int main (void)
170{
171//SamgarModule MyFirstTest("Module1","behaviour","happy","Interupt"); // Cant have spaces or underscores
172//MyFirstTest.AddPort("output1");
173//MyFirstTest.AddPort("output2");
174//MyFirstTest.AddPort("output3");
175//MyFirstTest.AddPort("output4");
176//MyFirstTest.AddPort("output5");
177//MyFirstTest.AddPort("output6");
178//MyFirstTest.AddPort("output7");
179//Network::connect("/Port_Module1_output7","/Port_Module2_output7");
180//Network::connect("/Port_Module2_output7","/Port_Module1_output7");
181
182//static double xx = 1;
183//string yy;
184
185  cvNamedWindow( "mywindow", CV_WINDOW_AUTOSIZE );
186
187  CvCapture* capture = cvCaptureFromCAM( CV_CAP_ANY );
188  if( !capture ) {   fprintf( stderr, "ERROR: capture is NULL \n" ); getchar();return -1;}
189
190 // MyFirstTest.SetupImagePort("VideoOut");
191
192
193 
194
195
196while(1)
197{
198    IplImage* frame = cvQueryFrame( capture );
199    if( !frame ) {fprintf( stderr, "ERROR: frame is null...\n" );getchar();break;}
200        cvShowImage( "mywindow", frame);
201}
202
203
204//sleep(10);
205return 0;
206}*/
Note: See TracBrowser for help on using the repository browser.