imagebase.h
1 /*
2  * Player - One Hell of a Robot Server
3  * Copyright (C) 2000 Brian Gerkey et al
4  * gerkey@usc.edu
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  *
20  */
22 //
23 // Desc: base driver for image processing and transform drivers
24 // Author: Toby Collett
25 // Date: 15 Feb 2004
26 // CVS: $Id: imagebase.h 9120 2013-01-07 00:18:52Z jpgr87 $
27 //
29 
30 
58 #include <libplayercore/playercore.h>
59 
60 // Driver for detecting laser retro-reflectors.
61 class ImageBase : public ThreadedDriver
62 {
63  public:
64  // Constructor
65  ImageBase(ConfigFile *cf, int section, bool overwrite_cmds, size_t queue_maxlen, int interf);
66  ImageBase(ConfigFile *cf, int section, bool overwrite_cmds = true, size_t queue_maxlen = PLAYER_MSGQUEUE_DEFAULT_MAXLEN);
67  virtual ~ImageBase()
68  {
69  if (stored_data.image) delete [](stored_data.image);
70  PLAYER_WARN("image deleted from the memory");
71  }
72 
73  // Process incoming messages from clients
74  int ProcessMessage (QueuePointer &resp_queue, player_msghdr * hdr, void * data);
75 
76  private:
77  ImageBase(); // no default constructor
78  ImageBase(const ImageBase &); // no copy constructor
79 
80  protected:
81  virtual int ProcessFrame() = 0;
82  // Main functions for device thread.
83  virtual void Main();
84  virtual int MainSetup();
85  virtual void MainQuit();
86 
87  // Input camera stuff
88  Device *camera_driver;
89  player_devaddr_t camera_addr;
90  player_camera_data_t stored_data;
91  bool HaveData;
92 };
Class for loading configuration file information.
Definition: configfile.h:196
int ProcessMessage(QueuePointer &resp_queue, player_msghdr *hdr, void *data)
Message handler.
Definition: imagebase.cc:112
Generic message header.
Definition: player.h:161
#define PLAYER_MSGQUEUE_DEFAULT_MAXLEN
Default maximum length for a message queue.
Definition: player.h:76
uint8_t * image
Compressed image data (byte-aligned, row major order).
Definition: player_interfaces.h:2972
virtual void MainQuit()
Cleanup method for driver thread (called when main exits)
Definition: imagebase.cc:104
A device address.
Definition: player.h:145
Base class for drivers which oeprate with a thread.
Definition: driver.h:552
Encapsulates a device (i.e., a driver bound to an interface)
Definition: device.h:74
An autopointer for the message queue.
Definition: message.h:73
Definition: imagebase.h:61
#define PLAYER_WARN(msg)
Warning message macros.
Definition: error.h:89
virtual void Main()
Main method for driver thread.
Definition: imagebase.cc:187
Data: state (PLAYER_CAMERA_DATA_STATE)
Definition: player_interfaces.h:2950
virtual int MainSetup()
Sets up the resources needed by the driver thread.
Definition: imagebase.cc:83