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 
30 #include <vector>
31 
32 namespace firevision {
33 
34 class CameraArgumentParser;
35 class FuseClient;
36 class FuseImageContent;
37 class FuseNetworkMessage;
38 class JpegImageDecompressor;
39 
40 class NetworkCamera : public Camera, public FuseClientHandler
41 {
42 public:
43  NetworkCamera(const char *host, unsigned short port, bool jpeg = false);
44  NetworkCamera(const char *host, unsigned short port, const char *image_id, bool jpeg = false);
46 
47  virtual ~NetworkCamera();
48 
49  virtual void open();
50  virtual void start();
51  virtual void stop();
52  virtual void close();
53  virtual void flush();
54  virtual void capture();
55  virtual void print_info();
56  virtual bool ready();
57 
58  virtual unsigned char *buffer();
59  virtual unsigned int buffer_size();
60  virtual void dispose_buffer();
61 
62  virtual unsigned int pixel_width();
63  virtual unsigned int pixel_height();
64  virtual colorspace_t colorspace();
65 
66  virtual void set_image_id(const char *image_id);
67  virtual void set_image_number(unsigned int n);
68 
69  virtual fawkes::Time *capture_time();
70 
71  virtual std::vector<FUSE_imageinfo_t> &image_list();
72 
73  virtual void fuse_invalid_server_version(uint32_t local_version, uint32_t remote_version) throw();
74  virtual void fuse_connection_established() throw();
75  virtual void fuse_connection_died() throw();
76  virtual void fuse_inbound_received(FuseNetworkMessage *m) throw();
77 
78 private:
79  bool started_;
80  bool opened_;
81 
82  bool connected_;
83  unsigned int local_version_;
84  unsigned int remote_version_;
85 
86  char * host_;
87  unsigned short port_;
88  char * image_id_;
89 
90  bool get_jpeg_;
91  JpegImageDecompressor *decompressor_;
92  unsigned char * decompressed_buffer_;
93  unsigned int last_width_;
94  unsigned int last_height_;
95 
96  FuseClient * fusec_;
97  FuseImageContent * fuse_image_;
98  FuseNetworkMessage *fuse_message_;
99 
100  FUSE_imageinfo_t *fuse_imageinfo_;
101 
102  std::vector<FUSE_imageinfo_t> image_list_;
103 };
104 
105 } // end namespace firevision
106 
107 #endif
A class for handling time.
Definition: time.h:93
Camera argument parser.
Definition: camargp.h:36
Camera interface for image aquiring devices in FireVision.
Definition: camera.h:33
FUSE Network Message.
Definition: fuse_message.h:40
Decompressor for JPEG images.
Network camera.
Definition: net.h:41
virtual void open()
Open the camera.
Definition: net.cpp:188
virtual unsigned int pixel_height()
Height of image in pixels.
Definition: net.cpp:342
virtual ~NetworkCamera()
Destructor.
Definition: net.cpp:176
virtual void stop()
Stop image transfer from the camera.
Definition: net.cpp:218
virtual bool ready()
Camera is ready for taking pictures.
Definition: net.cpp:370
virtual std::vector< FUSE_imageinfo_t > & image_list()
List the available images.
Definition: net.cpp:417
virtual colorspace_t colorspace()
Colorspace of returned image.
Definition: net.cpp:400
virtual void fuse_connection_died()
Connection died.
Definition: net.cpp:444
virtual void set_image_number(unsigned int n)
Set image number to retrieve.
Definition: net.cpp:394
virtual unsigned char * buffer()
Get access to current image buffer.
Definition: net.cpp:272
virtual void print_info()
Print out camera information.
Definition: net.cpp:224
virtual void fuse_connection_established()
Connection has been established.
Definition: net.cpp:438
virtual unsigned int buffer_size()
Size of buffer.
Definition: net.cpp:286
virtual void start()
Start image transfer from the camera.
Definition: net.cpp:212
virtual void fuse_inbound_received(FuseNetworkMessage *m)
Message received.
Definition: net.cpp:450
virtual void flush()
Flush image queue.
Definition: net.cpp:362
NetworkCamera(const char *host, unsigned short port, bool jpeg=false)
Constructor.
Definition: net.cpp:58
virtual fawkes::Time * capture_time()
Get the Time of the last successfully captured image.
Definition: net.cpp:352
virtual void close()
Close camera.
Definition: net.cpp:302
virtual unsigned int pixel_width()
Width of image in pixels.
Definition: net.cpp:332
virtual void dispose_buffer()
Dispose current buffer.
Definition: net.cpp:321
virtual void set_image_id(const char *image_id)
Select the image that is opened.
Definition: net.cpp:379
virtual void fuse_invalid_server_version(uint32_t local_version, uint32_t remote_version)
Invalid version string received.
Definition: net.cpp:431
virtual void capture()
Capture an image.
Definition: net.cpp:229
Image info message.
Definition: fuse.h:168