source: libs/SamgarWRUTed/tags/1.0/libSamgar/examples/SamgarReciveImage.cpp @ 447

Revision 447, 3.5 KB checked in by lmalek, 10 years ago (diff)

tree structure reorganization

Line 
1
2//**********************************************************************
3//
4//Program : example reciving images with SAMGAR
5//Date  : 24 Aug 2009
6//Author  : K Du Casse
7//
8//A simple program that shows how to Recive images with SAMGAR
9//
10//**********************************************************************
11
12// To use samgar you only need to attach the SamgarLib and the SamgarMainClass header
13#include "cv.h"
14#include "highgui.h"
15#include <Samgar.h>
16
17int main() {
18  Network yarp;
19  Samgar::SamgarModule CameraRecive("CameraRecive","PersonFinder",
20                                    "Camera",Samgar::ModeRun);
21  // Cant have spaces or underscores
22  CameraRecive.SetupImagePort("VideoIn");
23  cvNamedWindow( "copy", CV_WINDOW_AUTOSIZE );
24  while( 1 )
25  {
26      if (CameraRecive.getCurrentState() == Samgar::StateRunning)
27      {
28          IplImage *frame2 = CameraRecive.RecivePictureOCVNative();
29          if(frame2!=false) {// if there is no image available (one hasn't
30              // been sent) then the image will be false
31              cvShowImage( "copy", frame2 ); // if its not false then display it.
32          }         
33      }
34      if( (cvWaitKey(10) & 255) == 27 ) break;
35      CameraRecive.SucceedFail(true,0);
36  }
37  cvDestroyWindow( "copy" );
38  return 0;
39}
40
41
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#include "cv.h"
105#include "highgui.h"
106
107
108#include <stdio.h>
109#include <SamgarMainClass.h>
110using namespace std;
111
112
113using namespace yarp::sig::draw;
114
115int main()
116{
117SamgarModule MyFirstTest1("Module1","behaviour","happy","Interupt"); // Cant have spaces or underscores
118MyFirstTest1.SetupImagePort("VideoOut");
119
120SamgarModule MyFirstTest2("Module2","behaviour","happy","Interupt"); // Cant have spaces or underscores
121MyFirstTest2.SetupImagePort("VideoIn");
122
123Network::connect("/Port_Module2_VideoIn_OCV","/Port_Module1_VideoOut_OCV","udp");
124Network::connect("/Port_Module1_VideoOut_OCV","/Port_Module2_VideoIn_OCV","udp");
125 ImageOf<PixelBgr> yarpImage;
126                 yarpImage.resize(300,200);
127                 addCircle(yarpImage,PixelBgr(255,0,0),
128         yarpImage.width()/2,yarpImage.height()/2,
129         yarpImage.height()/4);
130
131
132while(1)
133        {
134        //      MyFirstTest1.SendPictureYarpNative
135
136           
137                 MyFirstTest1.SendPictureYarpNative(yarpImage);
138
139        }
140
141}
142
143
144
145/*
146
147#include "cv.h"
148#include "highgui.h"
149#include <stdio.h>
150
151
152
153//#include <SamgarMainClass.h>
154//using namespace std;
155
156int main (void)
157{
158//SamgarModule MyFirstTest("Module1","behaviour","happy","Interupt"); // Cant have spaces or underscores
159//MyFirstTest.AddPort("output1");
160//MyFirstTest.AddPort("output2");
161//MyFirstTest.AddPort("output3");
162//MyFirstTest.AddPort("output4");
163//MyFirstTest.AddPort("output5");
164//MyFirstTest.AddPort("output6");
165//MyFirstTest.AddPort("output7");
166//Network::connect("/Port_Module1_output7","/Port_Module2_output7");
167//Network::connect("/Port_Module2_output7","/Port_Module1_output7");
168
169//static double xx = 1;
170//string yy;
171
172  cvNamedWindow( "mywindow", CV_WINDOW_AUTOSIZE );
173
174  CvCapture* capture = cvCaptureFromCAM( CV_CAP_ANY );
175  if( !capture ) {   fprintf( stderr, "ERROR: capture is NULL \n" ); getchar();return -1;}
176
177 // MyFirstTest.SetupImagePort("VideoOut");
178
179
180 
181
182
183while(1)
184{
185    IplImage* frame = cvQueryFrame( capture );
186    if( !frame ) {fprintf( stderr, "ERROR: frame is null...\n" );getchar();break;}
187        cvShowImage( "mywindow", frame);
188}
189
190
191//sleep(10);
192return 0;
193}*/
194
Note: See TracBrowser for help on using the repository browser.