2 # pragma warning (disable: 4251) // STL MAP DLL warning noise (JW)
5 #include "VideoServer.hh"
7 #include <VideoSource/VideoSource_Disk.hh>
10 # include <VideoSource/VideoSource_DCAM.hh>
11 #endif // BIAS_HAVE_DCAM
14 # include <VideoSource/VideoSource_V4L.hh>
15 #endif // BIAS_HAVE_V4L
22 port_ = D_CS_DEFAULT_PORT;
33 compressionColor_=
true;
37 UDPServerThrottle_= 1;
47 if (camera_ != NULL) {
48 if (camera_->IsActive()) {
50 camera_->CloseDevice();
60 cout <<
"Initializing VideoServer on port:"<<port_<<endl;
69 #endif // BIAS_HAVE_DCAM
74 #endif // BIAS_HAVE_V4L
76 BIASERR(
"no camera type selected for input");
82 res = camera_->OpenDevice();
85 res = camera_->PreGrab();
90 if (camParam_[1] > 0) {
93 cout <<
"Shutter: "<<camera_->GetShutter();
97 if (camParam_[2] > 0) {
100 cout <<
"Shutter: "<<camera_->GetGain()<<endl;
104 #endif // BIAS_HAVE_DCAM
106 imgWidth_=camera_->GetWidth();
107 imgHeight_=camera_->GetHeight();
109 #ifdef BIAS_HAVE_LIBJPEG
111 if (Compressor_.Init() < 0) {
112 BIASERR(
"Could not initialize JPEG-compression!!!");
116 #else //BIAS_HAVE_LIBJPEG
118 BIASERR(
"Compression mode not available without LIBJPEG!");
120 #endif //BIAS_HAVE_LIBJPEG
124 server_.WaitForConnections(port_);
126 camera_->InitImage(CamImage_);
127 cout<<
"Grabbing image size: "<< imgWidth_<<
"x"<< imgHeight_<<endl;
136 cout <<
"Initializing VideoServer on port:"<<port_<<endl;
138 if (!camera_->IsActive()) {
140 if (res!=0)
return res;
141 res = camera_->PreGrab();
142 if (res!=0)
return res;
145 imgWidth_=camera_->GetWidth();
146 imgHeight_=camera_->GetHeight();
148 #ifdef BIAS_HAVE_LIBJPEG
150 if (Compressor_.Init() < 0) {
151 BIASERR(
"Could not initialize JPEG-compression!!!");
155 #else //BIAS_HAVE_LIBJPEG
157 BIASERR(
"Compression mode not available without LIBJPEG!");
159 #endif //BIAS_HAVE_LIBJPEG
163 server_.WaitForConnections(port_);
165 camera_->InitImage(CamImage_);
166 cout<<
"Grabbing image size: "<< imgWidth_<<
"x"<< imgHeight_<<endl;
175 if (! Initialized_) {
176 BIASERR(
"VideoServer not initialized");
179 if (server_.GetConnections()<=0)
185 camera_->GrabSingle(CamImage_);
187 if (resizeFactor_ == 1.0)
188 SendImage_=CamImage_;
190 RescaleFilter_.SetFactor(resizeFactor_);
191 RescaleFilter_.Filter(CamImage_, SendImage_);
197 #ifdef BIAS_HAVE_LIBJPEG
199 if (compressionColor_) {
203 Compressor_.Compress(temp,jpeg_);
205 Compressor_.Compress(SendImage_,jpeg_);
211 Compressor_.Compress(temp,jpeg_);
213 Compressor_.Compress(SendImage_,jpeg_);
218 Compressor_.GetCompressedData(data,length);
222 ret = server_.SendMsg(
"JPEG_IMAGE", (
char*)data, length);
224 BIASERR(
"Sending of image data failed");
229 #else //BIAS_HAVE_LIBJPEG
230 BIASERR(
"LIBJPEG not configured --> no compression available !!!");
232 #endif //BIAS_HAVE_LIBJPEG
237 stringstream dataToSend;
238 dataToSend<<SendImage_;
239 msgSize_= dataToSend.str().length();
242 ret = server_.SendMsg(
"BIAS_IMAGE",(
char*)&(dataToSend.str()[0]), msgSize_);
244 BIASERR(
"Sending of image data failed");
Defines a common interface to different devices.
int InitFromExistingSource(VideoSource *theSource, int port=D_CS_DEFAULT_PORT)
This class VideoSource_DCAM implements access to IEEE1394 (Firewire, iLink) cameras following the DCa...
virtual int OpenDevice()
selects the first available device to open (e.g.
int Init(int port=D_CS_DEFAULT_PORT)
color values, 3 channels, order: red,green,blue
This class extends VideoSource for the use of Video4Linux supported devices like framegrabber, USB cameras.
static int ToRGB(const Image< StorageType > &source, Image< StorageType > &dest)
Create a RGB converted copy of source image in this.
static UUID GenerateUUID(const bool &consecutively=DEFAULT_UUID_CONSECUTIVELY)
static function which simply produces a uuid and returns
This class simulates a video device by loading images from disk.
static int ToGrey(const ImageBase &source, ImageBase &dest)
wrapper for the templated function ToGrey