ueye_cam_driver.hpp
Go to the documentation of this file.
00001 /*******************************************************************************
00002 * DO NOT MODIFY - AUTO-GENERATED
00003 *
00004 *
00005 * DISCLAMER:
00006 *
00007 * This project was created within an academic research setting, and thus should
00008 * be considered as EXPERIMENTAL code. There may be bugs and deficiencies in the
00009 * code, so please adjust expectations accordingly. With that said, we are
00010 * intrinsically motivated to ensure its correctness (and often its performance).
00011 * Please use the corresponding web repository tool (e.g. github/bitbucket/etc.)
00012 * to file bugs, suggestions, pull requests; we will do our best to address them
00013 * in a timely manner.
00014 *
00015 *
00016 * SOFTWARE LICENSE AGREEMENT (BSD LICENSE):
00017 *
00018 * Copyright (c) 2013, Anqi Xu
00019 * All rights reserved.
00020 *
00021 * Redistribution and use in source and binary forms, with or without
00022 * modification, are permitted provided that the following conditions
00023 * are met:
00024 *
00025 *  * Redistributions of source code must retain the above copyright
00026 *    notice, this list of conditions and the following disclaimer.
00027 *  * Redistributions in binary form must reproduce the above
00028 *    copyright notice, this list of conditions and the following
00029 *    disclaimer in the documentation and/or other materials provided
00030 *    with the distribution.
00031 *  * Neither the name of the School of Computer Science, McGill University,
00032 *    nor the names of its contributors may be used to endorse or promote
00033 *    products derived from this software without specific prior written
00034 *    permission.
00035 *
00036 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00037 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00038 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00039 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
00040 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00041 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00042 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00043 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00044 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00045 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00046 *******************************************************************************/
00047 
00048 #ifndef UEYE_CAM_DRIVER_HPP_
00049 #define UEYE_CAM_DRIVER_HPP_
00050 
00051 
00052 #include <ueye.h>
00053 #include <string>
00054 #include <thread>
00055 #include "logging_macros.hpp"
00056 
00057 
00058 namespace ueye_cam {
00059 
00060 
00061 #define CAP(val, min, max) \
00062   if (val < min) { \
00063     val = min; \
00064   } else if (val > max) { \
00065     val = max; \
00066   }
00067 
00068 #define IS_SUBSAMPLING_2X (IS_SUBSAMPLING_2X_VERTICAL | IS_SUBSAMPLING_2X_HORIZONTAL)
00069 #define IS_SUBSAMPLING_4X (IS_SUBSAMPLING_4X_VERTICAL | IS_SUBSAMPLING_4X_HORIZONTAL)
00070 #define IS_SUBSAMPLING_8X (IS_SUBSAMPLING_8X_VERTICAL | IS_SUBSAMPLING_8X_HORIZONTAL)
00071 #define IS_SUBSAMPLING_16X (IS_SUBSAMPLING_16X_VERTICAL | IS_SUBSAMPLING_16X_HORIZONTAL)
00072 
00073 #define IS_BINNING_2X (IS_BINNING_2X_VERTICAL | IS_BINNING_2X_HORIZONTAL)
00074 #define IS_BINNING_4X (IS_BINNING_4X_VERTICAL | IS_BINNING_4X_HORIZONTAL)
00075 #define IS_BINNING_8X (IS_BINNING_8X_VERTICAL | IS_BINNING_8X_HORIZONTAL)
00076 #define IS_BINNING_16X (IS_BINNING_16X_VERTICAL | IS_BINNING_16X_HORIZONTAL)
00077 
00078 
00082 class UEyeCamDriver {
00083 public:
00084   constexpr static int ANY_CAMERA = 0;
00085 
00086 
00090   UEyeCamDriver(int cam_ID = ANY_CAMERA, std::string cam_name = "camera");
00091 
00095   virtual ~UEyeCamDriver();
00096 
00104   virtual INT connectCam(int new_cam_ID = -1);
00105 
00111   virtual INT disconnectCam();
00112 
00121   INT loadCamConfig(std::string filename, bool ignore_load_failure = true);
00122 
00136   INT setColorMode(std::string mode, bool reallocate_buffer = true);
00137 
00156   INT setResolution(INT& image_width, INT& image_height, INT& image_left,
00157       INT& image_top, bool reallocate_buffer = true);
00158 
00169   INT setSubsampling(int& rate, bool reallocate_buffer = true);
00170 
00181   INT setBinning(int& rate, bool reallocate_buffer = true);
00182 
00193   INT setSensorScaling(double& rate, bool reallocate_buffer = true);
00194 
00212   INT setGain(bool& auto_gain, INT& master_gain_prc, INT& red_gain_prc,
00213       INT& green_gain_prc, INT& blue_gain_prc, bool& gain_boost);
00214 
00226   INT setExposure(bool& auto_exposure, double& exposure_ms);
00227 
00239   INT setWhiteBalance(bool& auto_white_balance, INT& red_offset, INT& blue_offset);
00240 
00255   INT setFrameRate(bool& auto_frame_rate, double& frame_rate_hz);
00256 
00265   INT setPixelClockRate(INT& clock_rate_mhz);
00266 
00276   INT setFlashParams(INT& delay_us, UINT& duration_us);
00277 
00297   INT setFreeRunMode();
00298 
00313   INT setExtTriggerMode();
00314 
00321   INT setStandbyMode();
00322 
00329   INT setMirrorUpsideDown(bool flip_horizontal);
00330 
00337   INT setMirrorLeftRight(bool flip_vertical);
00338 
00352   const char* processNextFrame(INT timeout_ms);
00353 
00354   inline bool isConnected() { return (cam_handle_ != (HIDS) 0); }
00355 
00356   inline bool freeRunModeActive() {
00357     return ((cam_handle_ != (HIDS) 0) &&
00358         (is_SetExternalTrigger(cam_handle_, IS_GET_EXTERNALTRIGGER) == IS_SET_TRIGGER_OFF) &&
00359         (is_CaptureVideo(cam_handle_, IS_GET_LIVE) == TRUE));
00360   }
00361 
00362   inline bool extTriggerModeActive() {
00363     return ((cam_handle_ != (HIDS) 0) &&
00364         (is_SetExternalTrigger(cam_handle_, IS_GET_EXTERNALTRIGGER) == IS_SET_TRIGGER_HI_LO) &&
00365         (is_CaptureVideo(cam_handle_, IS_GET_LIVE) == TRUE));
00366   }
00367 
00368   inline bool isCapturing() {
00369     return ((cam_handle_ != (HIDS) 0) &&
00370         (is_CaptureVideo(cam_handle_, IS_GET_LIVE) == TRUE));
00371   }
00372 
00376   const static char* err2str(INT error);
00377   
00381   const static char* colormode2str(INT mode);
00382 
00386   bool getTimestamp(UEYETIME *timestamp);
00387 
00388 
00389 protected:
00408   virtual INT syncCamConfig(std::string dft_mode_str = "mono8");
00409 
00410 
00417   INT reallocateCamBuffer();
00418 
00419   HIDS cam_handle_;
00420   SENSORINFO cam_sensor_info_;
00421   char* cam_buffer_;
00422   int cam_buffer_id_;
00423   INT cam_buffer_pitch_;
00424   unsigned int cam_buffer_size_;
00425   std::string cam_name_;
00426   int cam_id_;
00427   IS_RECT cam_aoi_;
00428   unsigned int cam_subsampling_rate_;
00429   unsigned int cam_binning_rate_;
00430   double cam_sensor_scaling_rate_;
00431   INT bits_per_pixel_;
00432 };
00433 
00434 
00435 } // namespace ueye_cam
00436 
00437 
00438 #endif /* UEYE_CAM_DRIVER_HPP_ */


ueye_cam
Author(s): Anqi Xu
autogenerated on Wed Sep 16 2015 07:04:37