triclops.h

00001
00002 /***************************************************************************
00003  *  triclops.h - Stereo processor using the TriclopsSDK
00004  *
00005  *  Created: Fri May 18 16:25:26 2007
00006  *  Copyright  2007  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023
00024 #ifndef __FIREVISION_STEREO_TRICLOPS_H_
00025 #define __FIREVISION_STEREO_TRICLOPS_H_
00026 
00027 #include <stereo/stereo_processor.h>
00028 #include <sys/types.h>
00029
00030 class Bumblebee2Camera;
00031 class Camera;
00032 class TriclopsStereoProcessorData;
00033 class RectificationLutInfoBlock;
00034
00035 class TriclopsStereoProcessor : public StereoProcessor
00036 {
00037  public:
00038   TriclopsStereoProcessor(unsigned int width, unsigned int height,
00039                           const char *context_file);
00040   TriclopsStereoProcessor(Camera *camera);
00041   virtual ~TriclopsStereoProcessor();
00042
00043   virtual unsigned int  output_image_width();
00044   virtual unsigned int  output_image_height();
00045   virtual bool          subpixel_interpolation();
00046   virtual bool          edge_correlation();
00047   virtual bool          lowpass();
00048   virtual int           disparity_range_min();
00049   virtual int           disparity_range_max();
00050   virtual unsigned int  edge_masksize();
00051   virtual unsigned int  stereo_masksize();
00052   virtual bool          surface_validation();
00053   virtual bool          texture_validation();
00054   virtual unsigned char disparity_mapping_min();
00055   virtual unsigned char disparity_mapping_max();
00056   virtual bool          disparity_mapping();
00057
00058   virtual void          set_output_image_size(unsigned int width, unsigned int height);
00059   virtual void          set_subpixel_interpolation(bool enabled);
00060   virtual void          set_edge_correlation(bool enabled);
00061   virtual void          set_lowpass(bool enabled);
00062   virtual void          set_disparity_range(int min, int max);
00063   virtual void          set_edge_masksize(unsigned int mask_size); // 3-13
00064   virtual void          set_stereo_masksize(unsigned int mask_size); // 1-15
00065   virtual void          set_surface_validation(bool enabled);
00066   virtual void          set_texture_validation(bool enabled);
00067   virtual void          set_disparity_mapping_range(unsigned char min, unsigned char max);
00068   virtual void          set_disparity_mapping(bool enabled);
00069
00070   virtual bool          get_xyz(unsigned int px, unsigned int py,
00071                                 float *x, float *y, float *z);
00072
00073   virtual bool          get_world_xyz(unsigned int px, unsigned int py,
00074                                       float *x, float *y, float *z);
00075
00076   virtual void             set_raw_buffer(unsigned char *raw16_buffer);
00077   virtual void             preprocess_stereo();
00078   virtual void             calculate_disparity(ROI *roi = 0);
00079   virtual void             calculate_yuv(bool both = false);
00080   virtual unsigned char *  disparity_buffer();
00081   virtual size_t           disparity_buffer_size() const;
00082   virtual unsigned char *  yuv_buffer();
00083   virtual unsigned char *  auxiliary_yuv_buffer();
00084
00085   void    generate_rectification_lut(const char *lut_file);
00086   bool    verify_rectification_lut(const char *lut_file);
00087
00088   virtual void  getall_world_xyz(float ***buffer, int hoff, int voff, int width, int height, float *settings);
00089
00090  private:
00091   void get_triclops_context_from_camera();
00092   void deinterlace_green( unsigned char* src,
00093                           unsigned char* dest,
00094                           unsigned int width,
00095                           unsigned int height);
00096
00097   void create_buffers();
00098   void setup_triclops();
00099
00100
00101  private:
00102   Bumblebee2Camera             *bb2;
00103   TriclopsStereoProcessorData  *data;
00104
00105   unsigned char *buffer_rgb;
00106   unsigned char *buffer_green;
00107   unsigned char *buffer_rgb_left;
00108   unsigned char *buffer_rgb_right;
00109   unsigned char *buffer_rgb_center;
00110   unsigned char *buffer_yuv_left;
00111   unsigned char *buffer_yuv_right;
00112   unsigned char *buffer_yuv_center;
00113   unsigned char *_buffer;
00114   unsigned char *buffer_deinterlaced;
00115   unsigned char *buffer_raw16;
00116
00117   unsigned int _width;
00118   unsigned int _height;
00119
00120   unsigned int _output_image_width;
00121   unsigned int _output_image_height;
00122
00123   char  *_context_file;
00124 };
00125
00126 #endif