00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifdef FARSA_USE_YARP_AND_ICUB
00021
00022 #ifndef WCAMERA_H
00023 #define WCAMERA_H
00024
00025 #include "worldsimconfig.h"
00026 #include "wvector.h"
00027 #include "wmatrix.h"
00028 #include "wquaternion.h"
00029 #include "world.h"
00030 #include "yarpobject.h"
00031 #include "renderworld.h"
00032 #include <QImage>
00033 #include <QMutex>
00034
00035 class QGLPixelBuffer;
00036
00037 namespace farsa {
00038
00039 class WCamera;
00040
00052 class FARSA_WSIM_API RenderCamera : public QObject, public RenderWObjectContainer, public yarp::dev::DeviceDriver, public yarp::dev::IFrameGrabberImage {
00053 Q_OBJECT
00054 public:
00055 RenderCamera( WCamera* wcamera, WObject* attachTo, unsigned int width, unsigned int height );
00056 ~RenderCamera();
00058 void moveRotatePointOfView( const wMatrix& tm );
00060 void initializeGL();
00062 void paintGL();
00066 virtual bool open( yarp::os::Searchable &config );
00068 virtual bool close( );
00070 virtual bool configure( yarp::os::Searchable &config );
00072
00074 virtual bool getImage( yarp::sig::ImageOf<yarp::sig::PixelRgb>& image );
00075 virtual int height() const;
00076 virtual int width() const;
00078 private slots:
00079 void slotRemoveObject( WObject* w );
00080 void slotAddObject( WObject* w );
00081 private:
00082 float aspectRatio;
00083 wVector eyep;
00084 wVector atp;
00085 wVector upv;
00086 int widthv;
00087 int heightv;
00088 WCamera* wcamera;
00090 WObject* attachTo;
00092 QGLPixelBuffer* pbuffer;
00094 unsigned char* frameBuffer;
00096 yarp::sig::ImageOf<yarp::sig::PixelRgb> frameImage;
00097 };
00098
00109 class FARSA_WSIM_API WCamera : public YarpObject {
00110 Q_OBJECT
00111 public:
00120 WCamera( World* world, QString name, WObject* attachTo, unsigned int width=200, unsigned int height=200 );
00129 WCamera( World* world, QString name, unsigned int width=200, unsigned int height=200, const wMatrix& tm = wMatrix::identity() );
00131 ~WCamera();
00133 virtual void preUpdate();
00139 virtual void postUpdate();
00141 WObject* attachedTo() {
00142 return attachTo;
00143 };
00145 yarp::dev::IFrameGrabberImage* getFrameGrabber() {
00146 return images;
00147 }
00148 private:
00150 RenderCamera* images;
00152 WObject* attachTo;
00154 yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelRgb> > porty;
00155 };
00156
00157 }
00158
00159 #endif
00160
00161 #endif // FARSA_USE_YARP_AND_ICUB