Fawkes API  Fawkes Development Version
net.h
1 
2 /***************************************************************************
3  * net.h - This header defines an fuse network client camera
4  *
5  * Created: Wed Feb 01 12:22:06 2006
6  * Copyright 2005-2007 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef __FIREVISION_CAMS_NET_H_
25 #define __FIREVISION_CAMS_NET_H_
26 
27 #include <fvcams/camera.h>
28 #include <fvutils/net/fuse_client_handler.h>
29 #include <vector>
30 
31 namespace firevision {
32 #if 0 /* just to make Emacs auto-indent happy */
33 }
34 #endif
35 
36 class CameraArgumentParser;
37 class FuseClient;
38 class FuseImageContent;
39 class FuseNetworkMessage;
40 class JpegImageDecompressor;
41 
42 class NetworkCamera : public Camera, public FuseClientHandler
43 {
44 
45  public:
46  NetworkCamera(const char *host, unsigned short port, bool jpeg = false);
47  NetworkCamera(const char *host, unsigned short port, const char *image_id,
48  bool jpeg = false);
50 
51  virtual ~NetworkCamera();
52 
53  virtual void open();
54  virtual void start();
55  virtual void stop();
56  virtual void close();
57  virtual void flush();
58  virtual void capture();
59  virtual void print_info();
60  virtual bool ready();
61 
62  virtual unsigned char* buffer();
63  virtual unsigned int buffer_size();
64  virtual void dispose_buffer();
65 
66  virtual unsigned int pixel_width();
67  virtual unsigned int pixel_height();
68  virtual colorspace_t colorspace();
69 
70  virtual void set_image_id(const char *image_id);
71  virtual void set_image_number(unsigned int n);
72 
73  virtual fawkes::Time * capture_time();
74 
75  virtual std::vector<FUSE_imageinfo_t>& image_list();
76 
77  virtual void fuse_invalid_server_version(uint32_t local_version,
78  uint32_t remote_version) throw();
79  virtual void fuse_connection_established() throw();
80  virtual void fuse_connection_died() throw();
81  virtual void fuse_inbound_received(FuseNetworkMessage *m) throw();
82 
83  private:
84  bool __started;
85  bool __opened;
86 
87  bool __connected;
88  unsigned int __local_version;
89  unsigned int __remote_version;
90 
91  char *__host;
92  unsigned short __port;
93  char *__image_id;
94 
95  bool __get_jpeg;
96  JpegImageDecompressor *__decompressor;
97  unsigned char *__decompressed_buffer;
98  unsigned int __last_width;
99  unsigned int __last_height;
100 
101  FuseClient *__fusec;
102  FuseImageContent *__fuse_image;
103  FuseNetworkMessage *__fuse_message;
104 
105  FUSE_imageinfo_t *__fuse_imageinfo;
106 
107  std::vector<FUSE_imageinfo_t> __image_list;
108 };
109 
110 } // end namespace firevision
111 
112 #endif
virtual unsigned int pixel_height()
Height of image in pixels.
Definition: net.cpp:351
virtual std::vector< FUSE_imageinfo_t > & image_list()
List the available images.
Definition: net.cpp:429
Decompressor for JPEG images.
virtual void flush()
Flush image queue.
Definition: net.cpp:371
virtual void capture()
Capture an image.
Definition: net.cpp:238
virtual colorspace_t colorspace()
Colorspace of returned image.
Definition: net.cpp:411
NetworkCamera(const char *host, unsigned short port, bool jpeg=false)
Constructor.
Definition: net.cpp:63
virtual bool ready()
Camera is ready for taking pictures.
Definition: net.cpp:379
Camera interface for image aquiring devices in FireVision.
Definition: camera.h:35
virtual void set_image_id(const char *image_id)
Select the image that is opened.
Definition: net.cpp:389
virtual ~NetworkCamera()
Destructor.
Definition: net.cpp:184
Image info message.
Definition: fuse.h:165
virtual unsigned int buffer_size()
Size of buffer.
Definition: net.cpp:295
virtual unsigned char * buffer()
Get access to current image buffer.
Definition: net.cpp:281
A class for handling time.
Definition: time.h:91
virtual void open()
Open the camera.
Definition: net.cpp:196
Camera argument parser.
Definition: camargp.h:38
virtual void fuse_connection_established()
Connection has been established.
Definition: net.cpp:453
FUSE Network Message.
Definition: fuse_message.h:41
virtual void start()
Start image transfer from the camera.
Definition: net.cpp:219
virtual void dispose_buffer()
Dispose current buffer.
Definition: net.cpp:330
virtual unsigned int pixel_width()
Width of image in pixels.
Definition: net.cpp:341
virtual fawkes::Time * capture_time()
Get the Time of the last successfully captured image.
Definition: net.cpp:361
virtual void set_image_number(unsigned int n)
Set image number to retrieve.
Definition: net.cpp:404
virtual void fuse_connection_died()
Connection died.
Definition: net.cpp:460
virtual void close()
Close camera.
Definition: net.cpp:311
virtual void fuse_invalid_server_version(uint32_t local_version, uint32_t remote_version)
Invalid version string received.
Definition: net.cpp:444
virtual void stop()
Stop image transfer from the camera.
Definition: net.cpp:225
virtual void fuse_inbound_received(FuseNetworkMessage *m)
Message received.
Definition: net.cpp:467
virtual void print_info()
Print out camera information.
Definition: net.cpp:232
Network camera.
Definition: net.h:42