diff --git a/modules/videoio/CMakeLists.txt b/modules/videoio/CMakeLists.txt index 9e91a8a60f..e1468641da 100644 --- a/modules/videoio/CMakeLists.txt +++ b/modules/videoio/CMakeLists.txt @@ -126,11 +126,11 @@ if(HAVE_XIMEA) link_directories("${XIMEA_LIBRARY_DIR}") endif() if(WIN32 AND X86_64) - list(APPEND VIDEOIO_LIBRARIES m3apiX64) + list(APPEND VIDEOIO_LIBRARIES xiapi64) elseif(APPLE) list(APPEND VIDEOIO_LIBRARIES "-framework m3api") else() - list(APPEND VIDEOIO_LIBRARIES m3api) + list(APPEND VIDEOIO_LIBRARIES xiapi32) endif() endif(HAVE_XIMEA) diff --git a/modules/videoio/include/opencv2/videoio/videoio_c.h b/modules/videoio/include/opencv2/videoio/videoio_c.h index ae0259fe7a..dac487d4a6 100644 --- a/modules/videoio/include/opencv2/videoio/videoio_c.h +++ b/modules/videoio/include/opencv2/videoio/videoio_c.h @@ -239,28 +239,149 @@ enum CV_CAP_PROP_PVAPI_BINNINGY = 305, // Vertical binning factor CV_CAP_PROP_PVAPI_PIXELFORMAT = 306, // Pixel format - // Properties of cameras available through XIMEA SDK interface - CV_CAP_PROP_XI_DOWNSAMPLING = 400, // Change image resolution by binning or skipping. - CV_CAP_PROP_XI_DATA_FORMAT = 401, // Output data format. - CV_CAP_PROP_XI_OFFSET_X = 402, // Horizontal offset from the origin to the area of interest (in pixels). - CV_CAP_PROP_XI_OFFSET_Y = 403, // Vertical offset from the origin to the area of interest (in pixels). - CV_CAP_PROP_XI_TRG_SOURCE = 404, // Defines source of trigger. - CV_CAP_PROP_XI_TRG_SOFTWARE = 405, // Generates an internal trigger. PRM_TRG_SOURCE must be set to TRG_SOFTWARE. - CV_CAP_PROP_XI_GPI_SELECTOR = 406, // Selects general purpose input - CV_CAP_PROP_XI_GPI_MODE = 407, // Set general purpose input mode - CV_CAP_PROP_XI_GPI_LEVEL = 408, // Get general purpose level - CV_CAP_PROP_XI_GPO_SELECTOR = 409, // Selects general purpose output - CV_CAP_PROP_XI_GPO_MODE = 410, // Set general purpose output mode - CV_CAP_PROP_XI_LED_SELECTOR = 411, // Selects camera signalling LED - CV_CAP_PROP_XI_LED_MODE = 412, // Define camera signalling LED functionality - CV_CAP_PROP_XI_MANUAL_WB = 413, // Calculates White Balance(must be called during acquisition) - CV_CAP_PROP_XI_AUTO_WB = 414, // Automatic white balance - CV_CAP_PROP_XI_AEAG = 415, // Automatic exposure/gain - CV_CAP_PROP_XI_EXP_PRIORITY = 416, // Exposure priority (0.5 - exposure 50%, gain 50%). - CV_CAP_PROP_XI_AE_MAX_LIMIT = 417, // Maximum limit of exposure in AEAG procedure - CV_CAP_PROP_XI_AG_MAX_LIMIT = 418, // Maximum limit of gain in AEAG procedure - CV_CAP_PROP_XI_AEAG_LEVEL = 419, // Average intensity of output signal AEAG should achieve(in %) - CV_CAP_PROP_XI_TIMEOUT = 420, // Image capture timeout in milliseconds + + // Properties of cameras available through XIMEA SDK interface + CV_CAP_PROP_XI_TIMEOUT = 400, // Time interval required to wait for the image (in milliseconds). + CV_CAP_PROP_XI_EXPOSURE = 401, //Exposure time in microseconds + CV_CAP_PROP_XI_EXPOSURE_BURST_COUNT = 402, //Sets the number of times of exposure in one frame. + CV_CAP_PROP_XI_GAIN_SELECTOR = 403, //Gain selector for parameter Gain allows to select different type of gains. + CV_CAP_PROP_XI_GAIN = 404, //Gain in dB + CV_CAP_PROP_XI_DOWNSAMPLING = 405, //Change image resolution by binning or skipping. + CV_CAP_PROP_XI_DOWNSAMPLING_TYPE = 406, //Change image downsampling type. + CV_CAP_PROP_XI_BINNING_SELECTOR = 407, //Binning engine selector. + CV_CAP_PROP_XI_BINNING_VERTICAL = 408, //Vertical Binning - number of vertical photo-sensitive cells to combine together. + CV_CAP_PROP_XI_BINNING_HORIZONTAL = 409, //Horizontal Binning - number of horizontal photo-sensitive cells to combine together. + CV_CAP_PROP_XI_BINNING_PATTERN = 410, //Binning pattern type. + CV_CAP_PROP_XI_DECIMATION_SELECTOR = 411, //Decimation engine selector. + CV_CAP_PROP_XI_DECIMATION_VERTICAL = 412, //Vertical Decimation - vertical sub-sampling of the image - reduces the vertical resolution of the image by the specified vertical decimation factor. + CV_CAP_PROP_XI_DECIMATION_HORIZONTAL = 413, //Horizontal Decimation - horizontal sub-sampling of the image - reduces the horizontal resolution of the image by the specified vertical decimation factor. + CV_CAP_PROP_XI_DECIMATION_PATTERN = 414, //Decimation pattern type. + CV_CAP_PROP_XI_IMAGE_DATA_FORMAT = 415, //Output data format. + CV_CAP_PROP_XI_SHUTTER_TYPE = 416, //Change sensor shutter type(CMOS sensor). + CV_CAP_PROP_XI_SENSOR_TAPS = 417, //Number of taps + CV_CAP_PROP_XI_AEAG = 418, //Automatic exposure/gain + CV_CAP_PROP_XI_AEAG_ROI_OFFSET_X = 419, //Automatic exposure/gain ROI offset X + CV_CAP_PROP_XI_AEAG_ROI_OFFSET_Y = 420, //Automatic exposure/gain ROI offset Y + CV_CAP_PROP_XI_AEAG_ROI_WIDTH = 421, //Automatic exposure/gain ROI Width + CV_CAP_PROP_XI_AEAG_ROI_HEIGHT = 422, //Automatic exposure/gain ROI Height + CV_CAP_PROP_XI_BPC = 425, //Correction of bad pixels + CV_CAP_PROP_XI_AUTO_WB = 426, //Automatic white balance + CV_CAP_PROP_XI_MANUAL_WB = 427, //Calculates White Balance(xiGetImage function must be called) + CV_CAP_PROP_XI_WB_KR = 428, //White balance red coefficient + CV_CAP_PROP_XI_WB_KG = 429, //White balance green coefficient + CV_CAP_PROP_XI_WB_KB = 430, //White balance blue coefficient + CV_CAP_PROP_XI_WIDTH = 431, //Width of the Image provided by the device (in pixels). + CV_CAP_PROP_XI_HEIGHT = 432, //Height of the Image provided by the device (in pixels). + CV_CAP_PROP_XI_OFFSET_X = 433, //Horizontal offset from the origin to the area of interest (in pixels). + CV_CAP_PROP_XI_OFFSET_Y = 434, //Vertical offset from the origin to the area of interest (in pixels). + CV_CAP_PROP_XI_EXP_PRIORITY = 435, //Exposure priority (0.8 - exposure 80%, gain 20%). + CV_CAP_PROP_XI_AG_MAX_LIMIT = 436, //Maximum limit of gain in AEAG procedure + CV_CAP_PROP_XI_AE_MAX_LIMIT = 437, //Maximum time (us) used for exposure in AEAG procedure + CV_CAP_PROP_XI_AEAG_LEVEL = 438, //Average intensity of output signal AEAG should achieve(in %) + CV_CAP_PROP_XI_LIMIT_BANDWIDTH = 439, //Set/get bandwidth(datarate)(in Megabits) + CV_CAP_PROP_XI_SENSOR_DATA_BIT_DEPTH = 440, //Sensor output data bit depth. + CV_CAP_PROP_XI_OUTPUT_DATA_BIT_DEPTH = 441, //Device output data bit depth. + CV_CAP_PROP_XI_IMAGE_DATA_BIT_DEPTH = 442, //bitdepth of data returned by function xiGetImage + CV_CAP_PROP_XI_OUTPUT_DATA_PACKING = 443, //Device output data packing (or grouping) enabled. Packing could be enabled if output_data_bit_depth > 8 and packing capability is available. + CV_CAP_PROP_XI_OUTPUT_DATA_PACKING_TYPE = 444, //Data packing type. Some cameras supports only specific packing type. + CV_CAP_PROP_XI_IS_COOLED = 445, //Returns 1 for cameras that support cooling. + CV_CAP_PROP_XI_COOLING = 446, //Start camera cooling. + CV_CAP_PROP_XI_TARGET_TEMP = 447, //Set sensor target temperature for cooling. + CV_CAP_PROP_XI_CHIP_TEMP = 448, //Camera sensor temperature + CV_CAP_PROP_XI_HOUS_TEMP = 449, //Camera housing tepmerature + CV_CAP_PROP_XI_CMS = 450, //Mode of color management system. + CV_CAP_PROP_XI_APPLY_CMS = 451, //Enable applying of CMS profiles to xiGetImage (see XI_PRM_INPUT_CMS_PROFILE, XI_PRM_OUTPUT_CMS_PROFILE). + CV_CAP_PROP_XI_IMAGE_IS_COLOR = 454, //Returns 1 for color cameras. + CV_CAP_PROP_XI_COLOR_FILTER_ARRAY = 455, //Returns color filter array type of RAW data. + CV_CAP_PROP_XI_GAMMAY = 456, //Luminosity gamma + CV_CAP_PROP_XI_GAMMAC = 457, //Chromaticity gamma + CV_CAP_PROP_XI_SHARPNESS = 458, //Sharpness Strenght + CV_CAP_PROP_XI_CC_MATRIX_00 = 459, //Color Correction Matrix element [0][0] + CV_CAP_PROP_XI_CC_MATRIX_01 = 460, //Color Correction Matrix element [0][1] + CV_CAP_PROP_XI_CC_MATRIX_02 = 461, //Color Correction Matrix element [0][2] + CV_CAP_PROP_XI_CC_MATRIX_03 = 462, //Color Correction Matrix element [0][3] + CV_CAP_PROP_XI_CC_MATRIX_10 = 463, //Color Correction Matrix element [1][0] + CV_CAP_PROP_XI_CC_MATRIX_11 = 464, //Color Correction Matrix element [1][1] + CV_CAP_PROP_XI_CC_MATRIX_12 = 465, //Color Correction Matrix element [1][2] + CV_CAP_PROP_XI_CC_MATRIX_13 = 466, //Color Correction Matrix element [1][3] + CV_CAP_PROP_XI_CC_MATRIX_20 = 467, //Color Correction Matrix element [2][0] + CV_CAP_PROP_XI_CC_MATRIX_21 = 468, //Color Correction Matrix element [2][1] + CV_CAP_PROP_XI_CC_MATRIX_22 = 469, //Color Correction Matrix element [2][2] + CV_CAP_PROP_XI_CC_MATRIX_23 = 470, //Color Correction Matrix element [2][3] + CV_CAP_PROP_XI_CC_MATRIX_30 = 471, //Color Correction Matrix element [3][0] + CV_CAP_PROP_XI_CC_MATRIX_31 = 472, //Color Correction Matrix element [3][1] + CV_CAP_PROP_XI_CC_MATRIX_32 = 473, //Color Correction Matrix element [3][2] + CV_CAP_PROP_XI_CC_MATRIX_33 = 474, //Color Correction Matrix element [3][3] + CV_CAP_PROP_XI_DEFAULT_CC_MATRIX = 475, //Set default Color Correction Matrix + CV_CAP_PROP_XI_TRG_SOURCE = 476, //Defines source of trigger. + CV_CAP_PROP_XI_TRG_SOFTWARE = 477, //Generates an internal trigger. XI_PRM_TRG_SOURCE must be set to TRG_SOFTWARE. + CV_CAP_PROP_XI_TRG_SELECTOR = 478, //Selects the type of trigger. + CV_CAP_PROP_XI_ACQ_FRAME_BURST_COUNT = 479, //Sets number of frames acquired by burst. This burst is used only if trigger is set to FrameBurstStart + CV_CAP_PROP_XI_GPI_SELECTOR = 480, //Selects GPI + CV_CAP_PROP_XI_GPI_MODE = 481, //Defines GPI functionality + CV_CAP_PROP_XI_GPI_LEVEL = 482, //GPI level + CV_CAP_PROP_XI_GPO_SELECTOR = 483, //Selects GPO + CV_CAP_PROP_XI_GPO_MODE = 484, //Defines GPO functionality + CV_CAP_PROP_XI_LED_SELECTOR = 485, //Selects LED + CV_CAP_PROP_XI_LED_MODE = 486, //Defines LED functionality + CV_CAP_PROP_XI_DEBOUNCE_EN = 487, //Enable/Disable debounce to selected GPI + CV_CAP_PROP_XI_DEBOUNCE_T0 = 488, //Debounce time (x * 10us) + CV_CAP_PROP_XI_DEBOUNCE_T1 = 489, //Debounce time (x * 10us) + CV_CAP_PROP_XI_DEBOUNCE_POL = 490, //Debounce polarity (pol = 1 t0 - falling edge, t1 - rising edge) + CV_CAP_PROP_XI_LENS_MODE = 491, //Status of lens control interface. This shall be set to XI_ON before any Lens operations. + CV_CAP_PROP_XI_LENS_APERTURE_VALUE = 492, //Current lens aperture value in stops. Examples: 2.8, 4, 5.6, 8, 11 + CV_CAP_PROP_XI_LENS_FOCUS_MOVEMENT_VALUE = 493, //Lens current focus movement value to be used by XI_PRM_LENS_FOCUS_MOVE in motor steps. + CV_CAP_PROP_XI_LENS_FOCUS_MOVE = 494, //Moves lens focus motor by steps set in XI_PRM_LENS_FOCUS_MOVEMENT_VALUE. + CV_CAP_PROP_XI_LENS_FOCUS_DISTANCE = 495, //Lens focus distance in cm. + CV_CAP_PROP_XI_LENS_FOCAL_LENGTH = 496, //Lens focal distance in mm. + CV_CAP_PROP_XI_LENS_FEATURE_SELECTOR = 497, //Selects the current feature which is accessible by XI_PRM_LENS_FEATURE. + CV_CAP_PROP_XI_LENS_FEATURE = 498, //Allows access to lens feature value currently selected by XI_PRM_LENS_FEATURE_SELECTOR. + CV_CAP_PROP_XI_DEVICE_MODEL_ID = 501, //Return device model id + CV_CAP_PROP_XI_DEVICE_SN = 502, //Return device serial number + CV_CAP_PROP_XI_IMAGE_DATA_FORMAT_RGB32_ALPHA = 509, //The alpha channel of RGB32 output image format. + CV_CAP_PROP_XI_IMAGE_PAYLOAD_SIZE = 510, //Buffer size in bytes sufficient for output image returned by xiGetImage + CV_CAP_PROP_XI_TRANSPORT_PIXEL_FORMAT = 511, //Current format of pixels on transport layer. + CV_CAP_PROP_XI_SENSOR_CLOCK_FREQ_HZ = 512, //Sensor clock frequency in Hz. + CV_CAP_PROP_XI_SENSOR_CLOCK_FREQ_INDEX = 513, //Sensor clock frequency index. Sensor with selected frequencies have possibility to set the frequency only by this index. + CV_CAP_PROP_XI_SENSOR_OUTPUT_CHANNEL_COUNT = 514, //Number of output channels from sensor used for data transfer. + CV_CAP_PROP_XI_FRAMERATE = 515, //Define framerate in Hz + CV_CAP_PROP_XI_COUNTER_SELECTOR = 516, //Select counter + CV_CAP_PROP_XI_COUNTER_VALUE = 517, //Counter status + CV_CAP_PROP_XI_ACQ_TIMING_MODE = 518, //Type of sensor frames timing. + CV_CAP_PROP_XI_AVAILABLE_BANDWIDTH = 519, //Calculate and return available interface bandwidth(int Megabits) + CV_CAP_PROP_XI_BUFFER_POLICY = 520, //Data move policy + CV_CAP_PROP_XI_LUT_EN = 521, //Activates LUT. + CV_CAP_PROP_XI_LUT_INDEX = 522, //Control the index (offset) of the coefficient to access in the LUT. + CV_CAP_PROP_XI_LUT_VALUE = 523, //Value at entry LUTIndex of the LUT + CV_CAP_PROP_XI_TRG_DELAY = 524, //Specifies the delay in microseconds (us) to apply after the trigger reception before activating it. + CV_CAP_PROP_XI_TS_RST_MODE = 525, //Defines how time stamp reset engine will be armed + CV_CAP_PROP_XI_TS_RST_SOURCE = 526, //Defines which source will be used for timestamp reset. Writing this parameter will trigger settings of engine (arming) + CV_CAP_PROP_XI_IS_DEVICE_EXIST = 527, //Returns 1 if camera connected and works properly. + CV_CAP_PROP_XI_ACQ_BUFFER_SIZE = 528, //Acquisition buffer size in buffer_size_unit. Default bytes. + CV_CAP_PROP_XI_ACQ_BUFFER_SIZE_UNIT = 529, //Acquisition buffer size unit in bytes. Default 1. E.g. Value 1024 means that buffer_size is in KiBytes + CV_CAP_PROP_XI_ACQ_TRANSPORT_BUFFER_SIZE = 530, //Acquisition transport buffer size in bytes + CV_CAP_PROP_XI_BUFFERS_QUEUE_SIZE = 531, //Queue of field/frame buffers + CV_CAP_PROP_XI_ACQ_TRANSPORT_BUFFER_COMMIT = 532, //Number of buffers to commit to low level + CV_CAP_PROP_XI_RECENT_FRAME = 533, //GetImage returns most recent frame + CV_CAP_PROP_XI_DEVICE_RESET = 534, //Resets the camera to default state. + CV_CAP_PROP_XI_COLUMN_FPN_CORRECTION = 535, //Correction of column FPN + CV_CAP_PROP_XI_SENSOR_MODE = 538, //Current sensor mode. Allows to select sensor mode by one integer. Setting of this parameter affects: image dimensions and downsampling. + CV_CAP_PROP_XI_HDR = 539, //Enable High Dynamic Range feature. + CV_CAP_PROP_XI_HDR_KNEEPOINT_COUNT = 540, //The number of kneepoints in the PWLR. + CV_CAP_PROP_XI_HDR_T1 = 541, //position of first kneepoint(in % of XI_PRM_EXPOSURE) + CV_CAP_PROP_XI_HDR_T2 = 542, //position of second kneepoint (in % of XI_PRM_EXPOSURE) + CV_CAP_PROP_XI_KNEEPOINT1 = 543, //value of first kneepoint (% of sensor saturation) + CV_CAP_PROP_XI_KNEEPOINT2 = 544, //value of second kneepoint (% of sensor saturation) + CV_CAP_PROP_XI_IMAGE_BLACK_LEVEL = 545, //Last image black level counts. Can be used for Offline processing to recall it. + CV_CAP_PROP_XI_HW_REVISION = 551, //Returns hardware revision number. + CV_CAP_PROP_XI_DEBUG_LEVEL = 552, //Set debug level + CV_CAP_PROP_XI_AUTO_BANDWIDTH_CALCULATION = 553, //Automatic bandwidth calculation, + CV_CAP_PROP_XI_FREE_FFS_SIZE = 561, //Size of free camera FFS. + CV_CAP_PROP_XI_USED_FFS_SIZE = 562, //Size of used camera FFS. + CV_CAP_PROP_XI_FFS_ACCESS_KEY = 563, //Setting of key enables file operations on some cameras. + CV_CAP_PROP_XI_SENSOR_FEATURE_SELECTOR = 565, //Selects the current feature which is accessible by XI_PRM_SENSOR_FEATURE_VALUE. + CV_CAP_PROP_XI_SENSOR_FEATURE_VALUE = 566, //Allows access to sensor feature value currently selected by XI_PRM_SENSOR_FEATURE_SELECTOR. + // Properties for Android cameras CV_CAP_PROP_ANDROID_FLASH_MODE = 8001, diff --git a/modules/videoio/src/cap_ximea.cpp b/modules/videoio/src/cap_ximea.cpp index 82e1def7d4..bc58358811 100644 --- a/modules/videoio/src/cap_ximea.cpp +++ b/modules/videoio/src/cap_ximea.cpp @@ -1,3 +1,4 @@ + #include "precomp.hpp" #ifdef WIN32 @@ -6,6 +7,8 @@ #include #endif +using namespace std; + /**********************************************************************************/ class CvCaptureCAM_XIMEA : public CvCapture @@ -16,7 +19,7 @@ public: virtual bool open( int index ); virtual void close(); - virtual double getProperty(int) const; + virtual double getProperty(int); virtual bool setProperty(int, double); virtual bool grabFrame(); virtual IplImage* retrieveFrame(int); @@ -26,7 +29,7 @@ private: void init(); void errMsg(const char* msg, int errNum); void resetCvImage(); - int getBpp(); + int ocvParamtoXimeaParam(int value); IplImage* frame; HANDLE hmv; @@ -216,12 +219,48 @@ IplImage* CvCaptureCAM_XIMEA::retrieveFrame(int) void CvCaptureCAM_XIMEA::resetCvImage() { - int width = 0, height = 0, format = 0; - xiGetParamInt( hmv, XI_PRM_WIDTH, &width); - xiGetParamInt( hmv, XI_PRM_HEIGHT, &height); - xiGetParamInt( hmv, XI_PRM_IMAGE_DATA_FORMAT, &format); + bool do_reset = false; + + // first check basic image resolution + if((int)image.width != frame->width || (int)image.height != frame->height) + do_reset = true; + + // afterwards check image format + switch( image.frm) + { + case XI_MONO8 : + case XI_RAW8 : + { + if(frame->depth != IPL_DEPTH_8U || frame->nChannels != 1) + do_reset = true; + } + break; + case XI_MONO16 : + case XI_RAW16 : + { + if(frame->depth != IPL_DEPTH_16U || frame->nChannels != 1) + do_reset = true; + } + break; + case XI_RGB24 : + case XI_RGB_PLANAR : + { + if(frame->depth != IPL_DEPTH_8U || frame->nChannels != 3) + do_reset = true; + } + break; + case XI_RGB32 : + { + if(frame->depth != IPL_DEPTH_8U || frame->nChannels != 4) + do_reset = true; + } + break; + default: + errMsg("CvCaptureCAM_XIMEA::resetCvImage ERROR: Unknown format.", XI_NOT_SUPPORTED_DATA_FORMAT); + return; + } - if( (int)image.width != frame->width || (int)image.height != frame->height || image.frm != (XI_IMG_FORMAT)format) + if(do_reset) { if(frame) cvReleaseImage(&frame); frame = NULL; @@ -236,136 +275,1400 @@ void CvCaptureCAM_XIMEA::resetCvImage() case XI_RGB_PLANAR : frame = cvCreateImage(cvSize( image.width, image.height), IPL_DEPTH_8U, 3); break; case XI_RGB32 : frame = cvCreateImage(cvSize( image.width, image.height), IPL_DEPTH_8U, 4); break; default : + errMsg("CvCaptureCAM_XIMEA::resetCvImage ERROR: Unknown format.", XI_NOT_SUPPORTED_DATA_FORMAT); return; } } cvZero(frame); } + /**********************************************************************************/ -double CvCaptureCAM_XIMEA::getProperty( int property_id ) const +int CvCaptureCAM_XIMEA::ocvParamtoXimeaParam(int property_id) { - if(hmv == NULL) - return 0; - - int ival = 0; - float fval = 0; - - switch( property_id ) - { - // OCV parameters - case CV_CAP_PROP_POS_FRAMES : return (double) image.nframe; - case CV_CAP_PROP_FRAME_WIDTH : xiGetParamInt( hmv, XI_PRM_WIDTH, &ival); return ival; - case CV_CAP_PROP_FRAME_HEIGHT : xiGetParamInt( hmv, XI_PRM_HEIGHT, &ival); return ival; - case CV_CAP_PROP_FPS : xiGetParamFloat( hmv, XI_PRM_FRAMERATE, &fval); return fval; - case CV_CAP_PROP_GAIN : xiGetParamFloat( hmv, XI_PRM_GAIN, &fval); return fval; - case CV_CAP_PROP_EXPOSURE : xiGetParamInt( hmv, XI_PRM_EXPOSURE, &ival); return ival; - - // XIMEA camera properties - case CV_CAP_PROP_XI_DOWNSAMPLING : xiGetParamInt( hmv, XI_PRM_DOWNSAMPLING, &ival); return ival; - case CV_CAP_PROP_XI_DATA_FORMAT : xiGetParamInt( hmv, XI_PRM_IMAGE_DATA_FORMAT, &ival); return ival; - case CV_CAP_PROP_XI_OFFSET_X : xiGetParamInt( hmv, XI_PRM_OFFSET_X, &ival); return ival; - case CV_CAP_PROP_XI_OFFSET_Y : xiGetParamInt( hmv, XI_PRM_OFFSET_Y, &ival); return ival; - case CV_CAP_PROP_XI_TRG_SOURCE : xiGetParamInt( hmv, XI_PRM_TRG_SOURCE, &ival); return ival; - case CV_CAP_PROP_XI_GPI_SELECTOR : xiGetParamInt( hmv, XI_PRM_GPI_SELECTOR, &ival); return ival; - case CV_CAP_PROP_XI_GPI_MODE : xiGetParamInt( hmv, XI_PRM_GPI_MODE, &ival); return ival; - case CV_CAP_PROP_XI_GPI_LEVEL : xiGetParamInt( hmv, XI_PRM_GPI_LEVEL, &ival); return ival; - case CV_CAP_PROP_XI_GPO_SELECTOR : xiGetParamInt( hmv, XI_PRM_GPO_SELECTOR, &ival); return ival; - case CV_CAP_PROP_XI_GPO_MODE : xiGetParamInt( hmv, XI_PRM_GPO_MODE, &ival); return ival; - case CV_CAP_PROP_XI_LED_SELECTOR : xiGetParamInt( hmv, XI_PRM_LED_SELECTOR, &ival); return ival; - case CV_CAP_PROP_XI_LED_MODE : xiGetParamInt( hmv, XI_PRM_LED_MODE, &ival); return ival; - case CV_CAP_PROP_XI_AUTO_WB : xiGetParamInt( hmv, XI_PRM_AUTO_WB, &ival); return ival; - case CV_CAP_PROP_XI_AEAG : xiGetParamInt( hmv, XI_PRM_AEAG, &ival); return ival; - case CV_CAP_PROP_XI_EXP_PRIORITY : xiGetParamFloat( hmv, XI_PRM_EXP_PRIORITY, &fval); return fval; - case CV_CAP_PROP_XI_AE_MAX_LIMIT : xiGetParamInt( hmv, XI_PRM_AE_MAX_LIMIT, &ival); return ival; - case CV_CAP_PROP_XI_AG_MAX_LIMIT : xiGetParamFloat( hmv, XI_PRM_AG_MAX_LIMIT, &fval); return fval; - case CV_CAP_PROP_XI_AEAG_LEVEL : xiGetParamInt( hmv, XI_PRM_AEAG_LEVEL, &ival); return ival; - case CV_CAP_PROP_XI_TIMEOUT : return timeout; - - } - return 0; + XI_RETURN stat = XI_OK; + switch (property_id) + { + // OCV parameters + case CV_CAP_PROP_POS_FRAMES: + // Number of successfully transferred frames on transport layer. + stat = xiSetParamInt(hmv, XI_PRM_COUNTER_SELECTOR, XI_CNT_SEL_TRANSPORT_TRANSFERRED_FRAMES); + if (stat) errMsg("xiSetParamInt(XI_PRM_COUNTER_SELECTOR)", stat); + return CV_CAP_PROP_XI_COUNTER_VALUE; + case CV_CAP_PROP_FRAME_WIDTH: return CV_CAP_PROP_XI_WIDTH; + case CV_CAP_PROP_FRAME_HEIGHT: return CV_CAP_PROP_XI_HEIGHT; + case CV_CAP_PROP_FPS: return CV_CAP_PROP_XI_FRAMERATE; + case CV_CAP_PROP_GAIN: return CV_CAP_PROP_XI_GAIN; + case CV_CAP_PROP_EXPOSURE: return CV_CAP_PROP_XI_EXPOSURE; + default: + return property_id; + } } - + /**********************************************************************************/ - + bool CvCaptureCAM_XIMEA::setProperty( int property_id, double value ) { - int ival = (int) value; - float fval = (float) value; - - int mvret = XI_OK; + bool setProp_result = true; + bool doAcqReset = false; + string ximea_param = ""; + int ival = (int) value; + float fval = (float) value; + XI_PRM_TYPE value_type = xiTypeInteger; + XI_RETURN stat = XI_OK; + + if(hmv == NULL) + { + errMsg("CvCaptureCAM_XIMEA::setProperty", XI_INVALID_HANDLE); + return false; + } + + // convert OCV property id to XIMEA id if necessary + property_id = ocvParamtoXimeaParam(property_id); + + // decode OpenCV parameter to xiAPI parameter + switch( property_id ) + { + case CV_CAP_PROP_XI_TIMEOUT: + timeout = (int) value; + return true; + + case CV_CAP_PROP_XI_EXPOSURE: + ximea_param = "exposure"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_EXPOSURE_BURST_COUNT: + ximea_param = "exposure_burst_count"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_GAIN_SELECTOR: + ximea_param = "gain_selector"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_GAIN: + ximea_param = "gain"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_DOWNSAMPLING: + ximea_param = "downsampling"; + value_type = xiTypeEnum; + doAcqReset = true; + break; + case CV_CAP_PROP_XI_DOWNSAMPLING_TYPE: + ximea_param = "downsampling_type"; + value_type = xiTypeEnum; + doAcqReset = true; + break; + case CV_CAP_PROP_XI_BINNING_SELECTOR: + ximea_param = "binning_selector"; + value_type = xiTypeEnum; + doAcqReset = true; + break; + case CV_CAP_PROP_XI_BINNING_VERTICAL: + ximea_param = "binning_vertical"; + value_type = xiTypeInteger; + doAcqReset = true; + break; + case CV_CAP_PROP_XI_BINNING_HORIZONTAL: + ximea_param = "binning_horizontal"; + value_type = xiTypeInteger; + doAcqReset = true; + break; + case CV_CAP_PROP_XI_BINNING_PATTERN: + ximea_param = "binning_pattern"; + value_type = xiTypeEnum; + doAcqReset = true; + break; + case CV_CAP_PROP_XI_DECIMATION_SELECTOR: + ximea_param = "decimation_selector"; + value_type = xiTypeEnum; + doAcqReset = true; + break; + case CV_CAP_PROP_XI_DECIMATION_VERTICAL: + ximea_param = "decimation_vertical"; + value_type = xiTypeInteger; + doAcqReset = true; + break; + case CV_CAP_PROP_XI_DECIMATION_HORIZONTAL: + ximea_param = "decimation_horizontal"; + value_type = xiTypeInteger; + doAcqReset = true; + break; + case CV_CAP_PROP_XI_DECIMATION_PATTERN: + ximea_param = "decimation_pattern"; + value_type = xiTypeEnum; + doAcqReset = true; + break; + case CV_CAP_PROP_XI_IMAGE_DATA_FORMAT: + ximea_param = "imgdataformat"; + value_type = xiTypeEnum; + doAcqReset = true; + break; + case CV_CAP_PROP_XI_SHUTTER_TYPE: + ximea_param = "shutter_type"; + value_type = xiTypeEnum; + doAcqReset = true; + break; + case CV_CAP_PROP_XI_SENSOR_TAPS: + ximea_param = "sensor_taps"; + value_type = xiTypeEnum; + doAcqReset = true; + break; + case CV_CAP_PROP_XI_AEAG: + ximea_param = "aeag"; + value_type = xiTypeBoolean; + break; + case CV_CAP_PROP_XI_AEAG_ROI_OFFSET_X: + ximea_param = "aeag_roi_offset_x"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_AEAG_ROI_OFFSET_Y: + ximea_param = "aeag_roi_offset_y"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_AEAG_ROI_WIDTH: + ximea_param = "aeag_roi_width"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_AEAG_ROI_HEIGHT: + ximea_param = "aeag_roi_height"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_BPC: + ximea_param = "bpc"; + value_type = xiTypeBoolean; + break; + case CV_CAP_PROP_XI_AUTO_WB: + ximea_param = "auto_wb"; + value_type = xiTypeBoolean; + break; + case CV_CAP_PROP_XI_MANUAL_WB: + ximea_param = "manual_wb"; + value_type = xiTypeCommand; + break; + case CV_CAP_PROP_XI_WB_KR: + ximea_param = "wb_kr"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_WB_KG: + ximea_param = "wb_kg"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_WB_KB: + ximea_param = "wb_kb"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_WIDTH: + ximea_param = "width"; + value_type = xiTypeInteger; + doAcqReset = true; + break; + case CV_CAP_PROP_XI_HEIGHT: + ximea_param = "height"; + value_type = xiTypeInteger; + doAcqReset = true; + break; + case CV_CAP_PROP_XI_OFFSET_X: + ximea_param = "offsetX"; + value_type = xiTypeInteger; + doAcqReset = true; + break; + case CV_CAP_PROP_XI_OFFSET_Y: + ximea_param = "offsetY"; + value_type = xiTypeInteger; + doAcqReset = true; + break; + case CV_CAP_PROP_XI_EXP_PRIORITY: + ximea_param = "exp_priority"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_AG_MAX_LIMIT: + ximea_param = "ag_max_limit"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_AE_MAX_LIMIT: + ximea_param = "ae_max_limit"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_AEAG_LEVEL: + ximea_param = "aeag_level"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_LIMIT_BANDWIDTH: + ximea_param = "limit_bandwidth"; + value_type = xiTypeInteger; + doAcqReset = true; + break; + case CV_CAP_PROP_XI_SENSOR_DATA_BIT_DEPTH: + ximea_param = "sensor_bit_depth"; + value_type = xiTypeEnum; + doAcqReset = true; + break; + case CV_CAP_PROP_XI_OUTPUT_DATA_BIT_DEPTH: + ximea_param = "output_bit_depth"; + value_type = xiTypeEnum; + doAcqReset = true; + break; + case CV_CAP_PROP_XI_IMAGE_DATA_BIT_DEPTH: + ximea_param = "image_data_bit_depth"; + value_type = xiTypeEnum; + doAcqReset = true; + break; + case CV_CAP_PROP_XI_OUTPUT_DATA_PACKING: + ximea_param = "output_bit_packing"; + value_type = xiTypeBoolean; + doAcqReset = true; + break; + case CV_CAP_PROP_XI_OUTPUT_DATA_PACKING_TYPE: + ximea_param = "output_bit_packing_type"; + value_type = xiTypeEnum; + doAcqReset = true; + break; + case CV_CAP_PROP_XI_IS_COOLED: + ximea_param = "iscooled"; + value_type = xiTypeBoolean; + break; + case CV_CAP_PROP_XI_COOLING: + ximea_param = "cooling"; + value_type = xiTypeBoolean; + break; + case CV_CAP_PROP_XI_TARGET_TEMP: + ximea_param = "target_temp"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CHIP_TEMP: + ximea_param = "chip_temp"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_HOUS_TEMP: + ximea_param = "hous_temp"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CMS: + ximea_param = "cms"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_APPLY_CMS: + ximea_param = "apply_cms"; + value_type = xiTypeBoolean; + break; + case CV_CAP_PROP_XI_IMAGE_IS_COLOR: + ximea_param = "iscolor"; + value_type = xiTypeBoolean; + break; + case CV_CAP_PROP_XI_COLOR_FILTER_ARRAY: + ximea_param = "cfa"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_GAMMAY: + ximea_param = "gammaY"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_GAMMAC: + ximea_param = "gammaC"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_SHARPNESS: + ximea_param = "sharpness"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_00: + ximea_param = "ccMTX00"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_01: + ximea_param = "ccMTX01"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_02: + ximea_param = "ccMTX02"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_03: + ximea_param = "ccMTX03"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_10: + ximea_param = "ccMTX10"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_11: + ximea_param = "ccMTX11"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_12: + ximea_param = "ccMTX12"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_13: + ximea_param = "ccMTX13"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_20: + ximea_param = "ccMTX20"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_21: + ximea_param = "ccMTX21"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_22: + ximea_param = "ccMTX22"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_23: + ximea_param = "ccMTX23"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_30: + ximea_param = "ccMTX30"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_31: + ximea_param = "ccMTX31"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_32: + ximea_param = "ccMTX32"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_33: + ximea_param = "ccMTX33"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_DEFAULT_CC_MATRIX: + ximea_param = "defccMTX"; + value_type = xiTypeCommand; + break; + case CV_CAP_PROP_XI_TRG_SOURCE: + ximea_param = "trigger_source"; + value_type = xiTypeEnum; + doAcqReset = true; + break; + case CV_CAP_PROP_XI_TRG_SOFTWARE: + ximea_param = "trigger_software"; + value_type = xiTypeCommand; + break; + case CV_CAP_PROP_XI_TRG_SELECTOR: + ximea_param = "trigger_selector"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_ACQ_FRAME_BURST_COUNT: + ximea_param = "acq_frame_burst_count"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_GPI_SELECTOR: + ximea_param = "gpi_selector"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_GPI_MODE: + ximea_param = "gpi_mode"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_GPI_LEVEL: + ximea_param = "gpi_level"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_GPO_SELECTOR: + ximea_param = "gpo_selector"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_GPO_MODE: + ximea_param = "gpo_mode"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_LED_SELECTOR: + ximea_param = "led_selector"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_LED_MODE: + ximea_param = "led_mode"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_DEBOUNCE_EN: + ximea_param = "dbnc_en"; + value_type = xiTypeBoolean; + break; + case CV_CAP_PROP_XI_DEBOUNCE_T0: + ximea_param = "dbnc_t0"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_DEBOUNCE_T1: + ximea_param = "dbnc_t1"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_DEBOUNCE_POL: + ximea_param = "dbnc_pol"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_LENS_MODE: + ximea_param = "lens_mode"; + value_type = xiTypeBoolean; + break; + case CV_CAP_PROP_XI_LENS_APERTURE_VALUE: + ximea_param = "lens_aperture_value"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_LENS_FOCUS_MOVEMENT_VALUE: + ximea_param = "lens_focus_movement_value"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_LENS_FOCUS_MOVE: + ximea_param = "lens_focus_move"; + value_type = xiTypeCommand; + break; + case CV_CAP_PROP_XI_LENS_FOCUS_DISTANCE: + ximea_param = "lens_focus_distance"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_LENS_FOCAL_LENGTH: + ximea_param = "lens_focal_length"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_LENS_FEATURE_SELECTOR: + ximea_param = "lens_feature_selector"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_LENS_FEATURE: + ximea_param = "lens_feature"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_DEVICE_MODEL_ID: + ximea_param = "device_model_id"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_DEVICE_SN: + ximea_param = "device_sn"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_IMAGE_DATA_FORMAT_RGB32_ALPHA: + ximea_param = "imgdataformatrgb32alpha"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_IMAGE_PAYLOAD_SIZE: + ximea_param = "imgpayloadsize"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_TRANSPORT_PIXEL_FORMAT: + ximea_param = "transport_pixel_format"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_SENSOR_CLOCK_FREQ_HZ: + ximea_param = "sensor_clock_freq_hz"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_SENSOR_CLOCK_FREQ_INDEX: + ximea_param = "sensor_clock_freq_index"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_SENSOR_OUTPUT_CHANNEL_COUNT: + ximea_param = "sensor_output_channel_count"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_FRAMERATE: + ximea_param = "framerate"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_COUNTER_SELECTOR: + ximea_param = "counter_selector"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_COUNTER_VALUE: + ximea_param = "counter_value"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_ACQ_TIMING_MODE: + ximea_param = "acq_timing_mode"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_AVAILABLE_BANDWIDTH: + ximea_param = "available_bandwidth"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_BUFFER_POLICY: + ximea_param = "buffer_policy"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_LUT_EN: + ximea_param = "LUTEnable"; + value_type = xiTypeBoolean; + break; + case CV_CAP_PROP_XI_LUT_INDEX: + ximea_param = "LUTIndex"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_LUT_VALUE: + ximea_param = "LUTValue"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_TRG_DELAY: + ximea_param = "trigger_delay"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_TS_RST_MODE: + ximea_param = "ts_rst_mode"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_TS_RST_SOURCE: + ximea_param = "ts_rst_source"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_IS_DEVICE_EXIST: + ximea_param = "isexist"; + value_type = xiTypeBoolean; + break; + case CV_CAP_PROP_XI_ACQ_BUFFER_SIZE: + ximea_param = "acq_buffer_size"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_ACQ_BUFFER_SIZE_UNIT: + ximea_param = "acq_buffer_size_unit"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_ACQ_TRANSPORT_BUFFER_SIZE: + ximea_param = "acq_transport_buffer_size"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_BUFFERS_QUEUE_SIZE: + ximea_param = "buffers_queue_size"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_ACQ_TRANSPORT_BUFFER_COMMIT: + ximea_param = "acq_transport_buffer_commit"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_RECENT_FRAME: + ximea_param = "recent_frame"; + value_type = xiTypeBoolean; + break; + case CV_CAP_PROP_XI_DEVICE_RESET: + ximea_param = "device_reset"; + value_type = xiTypeCommand; + doAcqReset = true; + break; + case CV_CAP_PROP_XI_COLUMN_FPN_CORRECTION: + ximea_param = "column_fpn_correction"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_SENSOR_MODE: + ximea_param = "sensor_mode"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_HDR: + ximea_param = "hdr"; + value_type = xiTypeBoolean; + break; + case CV_CAP_PROP_XI_HDR_KNEEPOINT_COUNT: + ximea_param = "hdr_kneepoint_count"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_HDR_T1: + ximea_param = "hdr_t1"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_HDR_T2: + ximea_param = "hdr_t2"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_KNEEPOINT1: + ximea_param = "hdr_kneepoint1"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_KNEEPOINT2: + ximea_param = "hdr_kneepoint2"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_IMAGE_BLACK_LEVEL: + ximea_param = "image_black_level"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_HW_REVISION: + ximea_param = "hw_revision"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_DEBUG_LEVEL: + ximea_param = "debug_level"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_AUTO_BANDWIDTH_CALCULATION: + ximea_param = "auto_bandwidth_calculation"; + value_type = xiTypeBoolean; + break; + case CV_CAP_PROP_XI_FREE_FFS_SIZE: + ximea_param = "free_ffs_size"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_USED_FFS_SIZE: + ximea_param = "used_ffs_size"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_FFS_ACCESS_KEY: + ximea_param = "ffs_access_key"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_SENSOR_FEATURE_SELECTOR: + ximea_param = "sensor_feature_selector"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_SENSOR_FEATURE_VALUE: + ximea_param = "sensor_feature_value"; + value_type = xiTypeInteger; + break; + default: + // report invalid parameter as it is not of numerical type + errMsg("CvCaptureCAM_XIMEA::setProperty", XI_UNKNOWN_PARAM); + return false; + } + + if(doAcqReset) + { + stat = xiStopAcquisition(hmv); + errMsg("CvCaptureCAM_XIMEA::setProperty, xiStopAcquisition", stat); + if(stat != XI_OK) + setProp_result = false; + } + + switch(value_type) + { + case xiTypeInteger : // integer parameter type + case xiTypeEnum : // enumerator parameter type + case xiTypeBoolean : // boolean parameter type + case xiTypeCommand : // command parameter type + stat = xiSetParamInt(hmv, ximea_param.c_str(), ival); + break; + case xiTypeFloat : // float parameter type + stat = xiSetParamFloat(hmv, ximea_param.c_str(), fval); + break; + default: + errMsg("CvCaptureCAM_XIMEA::setProperty", XI_WRONG_PARAM_TYPE); + setProp_result = false; + } + + if(stat != XI_OK) + { + // report error on parameter setting + errMsg("CvCaptureCAM_XIMEA::setProperty, xiSetParam", stat); + setProp_result = false; + } - switch(property_id) - { - // OCV parameters - case CV_CAP_PROP_FRAME_WIDTH : mvret = xiSetParamInt( hmv, XI_PRM_WIDTH, ival); break; - case CV_CAP_PROP_FRAME_HEIGHT : mvret = xiSetParamInt( hmv, XI_PRM_HEIGHT, ival); break; - case CV_CAP_PROP_FPS : mvret = xiSetParamFloat( hmv, XI_PRM_FRAMERATE, fval); break; - case CV_CAP_PROP_GAIN : mvret = xiSetParamFloat( hmv, XI_PRM_GAIN, fval); break; - case CV_CAP_PROP_EXPOSURE : mvret = xiSetParamInt( hmv, XI_PRM_EXPOSURE, ival); break; - // XIMEA camera properties - case CV_CAP_PROP_XI_DOWNSAMPLING : mvret = xiSetParamInt( hmv, XI_PRM_DOWNSAMPLING, ival); break; - case CV_CAP_PROP_XI_DATA_FORMAT : mvret = xiSetParamInt( hmv, XI_PRM_IMAGE_DATA_FORMAT, ival); break; - case CV_CAP_PROP_XI_OFFSET_X : mvret = xiSetParamInt( hmv, XI_PRM_OFFSET_X, ival); break; - case CV_CAP_PROP_XI_OFFSET_Y : mvret = xiSetParamInt( hmv, XI_PRM_OFFSET_Y, ival); break; - case CV_CAP_PROP_XI_TRG_SOURCE : mvret = xiSetParamInt( hmv, XI_PRM_TRG_SOURCE, ival); break; - case CV_CAP_PROP_XI_GPI_SELECTOR : mvret = xiSetParamInt( hmv, XI_PRM_GPI_SELECTOR, ival); break; - case CV_CAP_PROP_XI_TRG_SOFTWARE : mvret = xiSetParamInt( hmv, XI_PRM_TRG_SOFTWARE, 1); break; - case CV_CAP_PROP_XI_GPI_MODE : mvret = xiSetParamInt( hmv, XI_PRM_GPI_MODE, ival); break; - case CV_CAP_PROP_XI_GPI_LEVEL : mvret = xiSetParamInt( hmv, XI_PRM_GPI_LEVEL, ival); break; - case CV_CAP_PROP_XI_GPO_SELECTOR : mvret = xiSetParamInt( hmv, XI_PRM_GPO_SELECTOR, ival); break; - case CV_CAP_PROP_XI_GPO_MODE : mvret = xiSetParamInt( hmv, XI_PRM_GPO_MODE, ival); break; - case CV_CAP_PROP_XI_LED_SELECTOR : mvret = xiSetParamInt( hmv, XI_PRM_LED_SELECTOR, ival); break; - case CV_CAP_PROP_XI_LED_MODE : mvret = xiSetParamInt( hmv, XI_PRM_LED_MODE, ival); break; - case CV_CAP_PROP_XI_AUTO_WB : mvret = xiSetParamInt( hmv, XI_PRM_AUTO_WB, ival); break; - case CV_CAP_PROP_XI_MANUAL_WB : mvret = xiSetParamInt( hmv, XI_PRM_MANUAL_WB, ival); break; - case CV_CAP_PROP_XI_AEAG : mvret = xiSetParamInt( hmv, XI_PRM_AEAG, ival); break; - case CV_CAP_PROP_XI_EXP_PRIORITY : mvret = xiSetParamFloat( hmv, XI_PRM_EXP_PRIORITY, fval); break; - case CV_CAP_PROP_XI_AE_MAX_LIMIT : mvret = xiSetParamInt( hmv, XI_PRM_AE_MAX_LIMIT, ival); break; - case CV_CAP_PROP_XI_AG_MAX_LIMIT : mvret = xiSetParamFloat( hmv, XI_PRM_AG_MAX_LIMIT, fval); break; - case CV_CAP_PROP_XI_AEAG_LEVEL : mvret = xiSetParamInt( hmv, XI_PRM_AEAG_LEVEL, ival); break; - case CV_CAP_PROP_XI_TIMEOUT : timeout = ival; break; - } - - if(mvret != XI_OK) - { - errMsg("Set parameter error", mvret); - return false; - } - else - return true; - -} + if(doAcqReset) + { + stat = xiStartAcquisition(hmv); + errMsg("xiStartAcquisition::setProperty, xiStartAcquisition", stat); + if(stat != XI_OK) + setProp_result = false; + } + return setProp_result; +} /**********************************************************************************/ - -void CvCaptureCAM_XIMEA::errMsg(const char* msg, int errNum) + +double CvCaptureCAM_XIMEA::getProperty( int property_id ) { -#if defined WIN32 || defined _WIN32 - char buf[512]=""; - sprintf( buf, "%s : %d\n", msg, errNum); - OutputDebugString(buf); -#else - fprintf(stderr, "%s : %d\n", msg, errNum); -#endif + XI_RETURN stat = XI_OK; + double getPropVal = 0; + int ival = 0; + float fval = 0; + string ximea_param = ""; + XI_PRM_TYPE value_type = xiTypeInteger; + + if(hmv == NULL) + { + errMsg("CvCaptureCAM_XIMEA::getProperty", XI_INVALID_HANDLE); + return 0; + } + + // convert OCV property id to XIMEA id if necessary + property_id = ocvParamtoXimeaParam(property_id); + + // decode OpenCV parameter to xiAPI parameter + switch( property_id ) + { + case CV_CAP_PROP_XI_TIMEOUT: + return (double) timeout; + + case CV_CAP_PROP_XI_EXPOSURE: + ximea_param = "exposure"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_EXPOSURE_BURST_COUNT: + ximea_param = "exposure_burst_count"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_GAIN_SELECTOR: + ximea_param = "gain_selector"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_GAIN: + ximea_param = "gain"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_DOWNSAMPLING: + ximea_param = "downsampling"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_DOWNSAMPLING_TYPE: + ximea_param = "downsampling_type"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_BINNING_SELECTOR: + ximea_param = "binning_selector"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_BINNING_VERTICAL: + ximea_param = "binning_vertical"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_BINNING_HORIZONTAL: + ximea_param = "binning_horizontal"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_BINNING_PATTERN: + ximea_param = "binning_pattern"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_DECIMATION_SELECTOR: + ximea_param = "decimation_selector"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_DECIMATION_VERTICAL: + ximea_param = "decimation_vertical"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_DECIMATION_HORIZONTAL: + ximea_param = "decimation_horizontal"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_DECIMATION_PATTERN: + ximea_param = "decimation_pattern"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_IMAGE_DATA_FORMAT: + ximea_param = "imgdataformat"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_SHUTTER_TYPE: + ximea_param = "shutter_type"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_SENSOR_TAPS: + ximea_param = "sensor_taps"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_AEAG: + ximea_param = "aeag"; + value_type = xiTypeBoolean; + break; + case CV_CAP_PROP_XI_AEAG_ROI_OFFSET_X: + ximea_param = "aeag_roi_offset_x"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_AEAG_ROI_OFFSET_Y: + ximea_param = "aeag_roi_offset_y"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_AEAG_ROI_WIDTH: + ximea_param = "aeag_roi_width"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_AEAG_ROI_HEIGHT: + ximea_param = "aeag_roi_height"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_BPC: + ximea_param = "bpc"; + value_type = xiTypeBoolean; + break; + case CV_CAP_PROP_XI_AUTO_WB: + ximea_param = "auto_wb"; + value_type = xiTypeBoolean; + break; + case CV_CAP_PROP_XI_MANUAL_WB: + ximea_param = "manual_wb"; + value_type = xiTypeCommand; + break; + case CV_CAP_PROP_XI_WB_KR: + ximea_param = "wb_kr"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_WB_KG: + ximea_param = "wb_kg"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_WB_KB: + ximea_param = "wb_kb"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_WIDTH: + ximea_param = "width"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_HEIGHT: + ximea_param = "height"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_OFFSET_X: + ximea_param = "offsetX"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_OFFSET_Y: + ximea_param = "offsetY"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_EXP_PRIORITY: + ximea_param = "exp_priority"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_AG_MAX_LIMIT: + ximea_param = "ag_max_limit"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_AE_MAX_LIMIT: + ximea_param = "ae_max_limit"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_AEAG_LEVEL: + ximea_param = "aeag_level"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_LIMIT_BANDWIDTH: + ximea_param = "limit_bandwidth"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_SENSOR_DATA_BIT_DEPTH: + ximea_param = "sensor_bit_depth"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_OUTPUT_DATA_BIT_DEPTH: + ximea_param = "output_bit_depth"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_IMAGE_DATA_BIT_DEPTH: + ximea_param = "image_data_bit_depth"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_OUTPUT_DATA_PACKING: + ximea_param = "output_bit_packing"; + value_type = xiTypeBoolean; + break; + case CV_CAP_PROP_XI_OUTPUT_DATA_PACKING_TYPE: + ximea_param = "output_bit_packing_type"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_IS_COOLED: + ximea_param = "iscooled"; + value_type = xiTypeBoolean; + break; + case CV_CAP_PROP_XI_COOLING: + ximea_param = "cooling"; + value_type = xiTypeBoolean; + break; + case CV_CAP_PROP_XI_TARGET_TEMP: + ximea_param = "target_temp"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CHIP_TEMP: + ximea_param = "chip_temp"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_HOUS_TEMP: + ximea_param = "hous_temp"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CMS: + ximea_param = "cms"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_APPLY_CMS: + ximea_param = "apply_cms"; + value_type = xiTypeBoolean; + break; + case CV_CAP_PROP_XI_IMAGE_IS_COLOR: + ximea_param = "iscolor"; + value_type = xiTypeBoolean; + break; + case CV_CAP_PROP_XI_COLOR_FILTER_ARRAY: + ximea_param = "cfa"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_GAMMAY: + ximea_param = "gammaY"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_GAMMAC: + ximea_param = "gammaC"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_SHARPNESS: + ximea_param = "sharpness"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_00: + ximea_param = "ccMTX00"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_01: + ximea_param = "ccMTX01"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_02: + ximea_param = "ccMTX02"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_03: + ximea_param = "ccMTX03"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_10: + ximea_param = "ccMTX10"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_11: + ximea_param = "ccMTX11"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_12: + ximea_param = "ccMTX12"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_13: + ximea_param = "ccMTX13"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_20: + ximea_param = "ccMTX20"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_21: + ximea_param = "ccMTX21"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_22: + ximea_param = "ccMTX22"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_23: + ximea_param = "ccMTX23"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_30: + ximea_param = "ccMTX30"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_31: + ximea_param = "ccMTX31"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_32: + ximea_param = "ccMTX32"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_CC_MATRIX_33: + ximea_param = "ccMTX33"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_DEFAULT_CC_MATRIX: + ximea_param = "defccMTX"; + value_type = xiTypeCommand; + break; + case CV_CAP_PROP_XI_TRG_SOURCE: + ximea_param = "trigger_source"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_TRG_SOFTWARE: + ximea_param = "trigger_software"; + value_type = xiTypeCommand; + break; + case CV_CAP_PROP_XI_TRG_SELECTOR: + ximea_param = "trigger_selector"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_ACQ_FRAME_BURST_COUNT: + ximea_param = "acq_frame_burst_count"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_GPI_SELECTOR: + ximea_param = "gpi_selector"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_GPI_MODE: + ximea_param = "gpi_mode"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_GPI_LEVEL: + ximea_param = "gpi_level"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_GPO_SELECTOR: + ximea_param = "gpo_selector"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_GPO_MODE: + ximea_param = "gpo_mode"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_LED_SELECTOR: + ximea_param = "led_selector"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_LED_MODE: + ximea_param = "led_mode"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_DEBOUNCE_EN: + ximea_param = "dbnc_en"; + value_type = xiTypeBoolean; + break; + case CV_CAP_PROP_XI_DEBOUNCE_T0: + ximea_param = "dbnc_t0"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_DEBOUNCE_T1: + ximea_param = "dbnc_t1"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_DEBOUNCE_POL: + ximea_param = "dbnc_pol"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_LENS_MODE: + ximea_param = "lens_mode"; + value_type = xiTypeBoolean; + break; + case CV_CAP_PROP_XI_LENS_APERTURE_VALUE: + ximea_param = "lens_aperture_value"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_LENS_FOCUS_MOVEMENT_VALUE: + ximea_param = "lens_focus_movement_value"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_LENS_FOCUS_MOVE: + ximea_param = "lens_focus_move"; + value_type = xiTypeCommand; + break; + case CV_CAP_PROP_XI_LENS_FOCUS_DISTANCE: + ximea_param = "lens_focus_distance"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_LENS_FOCAL_LENGTH: + ximea_param = "lens_focal_length"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_LENS_FEATURE_SELECTOR: + ximea_param = "lens_feature_selector"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_LENS_FEATURE: + ximea_param = "lens_feature"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_DEVICE_MODEL_ID: + ximea_param = "device_model_id"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_DEVICE_SN: + ximea_param = "device_sn"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_IMAGE_DATA_FORMAT_RGB32_ALPHA: + ximea_param = "imgdataformatrgb32alpha"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_IMAGE_PAYLOAD_SIZE: + ximea_param = "imgpayloadsize"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_TRANSPORT_PIXEL_FORMAT: + ximea_param = "transport_pixel_format"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_SENSOR_CLOCK_FREQ_HZ: + ximea_param = "sensor_clock_freq_hz"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_SENSOR_CLOCK_FREQ_INDEX: + ximea_param = "sensor_clock_freq_index"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_SENSOR_OUTPUT_CHANNEL_COUNT: + ximea_param = "sensor_output_channel_count"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_FRAMERATE: + ximea_param = "framerate"; + value_type = xiTypeFloat; + break; + case CV_CAP_PROP_XI_COUNTER_SELECTOR: + ximea_param = "counter_selector"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_COUNTER_VALUE: + ximea_param = "counter_value"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_ACQ_TIMING_MODE: + ximea_param = "acq_timing_mode"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_AVAILABLE_BANDWIDTH: + ximea_param = "available_bandwidth"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_BUFFER_POLICY: + ximea_param = "buffer_policy"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_LUT_EN: + ximea_param = "LUTEnable"; + value_type = xiTypeBoolean; + break; + case CV_CAP_PROP_XI_LUT_INDEX: + ximea_param = "LUTIndex"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_LUT_VALUE: + ximea_param = "LUTValue"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_TRG_DELAY: + ximea_param = "trigger_delay"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_TS_RST_MODE: + ximea_param = "ts_rst_mode"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_TS_RST_SOURCE: + ximea_param = "ts_rst_source"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_IS_DEVICE_EXIST: + ximea_param = "isexist"; + value_type = xiTypeBoolean; + break; + case CV_CAP_PROP_XI_ACQ_BUFFER_SIZE: + ximea_param = "acq_buffer_size"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_ACQ_BUFFER_SIZE_UNIT: + ximea_param = "acq_buffer_size_unit"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_ACQ_TRANSPORT_BUFFER_SIZE: + ximea_param = "acq_transport_buffer_size"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_BUFFERS_QUEUE_SIZE: + ximea_param = "buffers_queue_size"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_ACQ_TRANSPORT_BUFFER_COMMIT: + ximea_param = "acq_transport_buffer_commit"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_RECENT_FRAME: + ximea_param = "recent_frame"; + value_type = xiTypeBoolean; + break; + case CV_CAP_PROP_XI_DEVICE_RESET: + ximea_param = "device_reset"; + value_type = xiTypeCommand; + break; + case CV_CAP_PROP_XI_COLUMN_FPN_CORRECTION: + ximea_param = "column_fpn_correction"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_SENSOR_MODE: + ximea_param = "sensor_mode"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_HDR: + ximea_param = "hdr"; + value_type = xiTypeBoolean; + break; + case CV_CAP_PROP_XI_HDR_KNEEPOINT_COUNT: + ximea_param = "hdr_kneepoint_count"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_HDR_T1: + ximea_param = "hdr_t1"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_HDR_T2: + ximea_param = "hdr_t2"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_KNEEPOINT1: + ximea_param = "hdr_kneepoint1"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_KNEEPOINT2: + ximea_param = "hdr_kneepoint2"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_IMAGE_BLACK_LEVEL: + ximea_param = "image_black_level"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_HW_REVISION: + ximea_param = "hw_revision"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_DEBUG_LEVEL: + ximea_param = "debug_level"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_AUTO_BANDWIDTH_CALCULATION: + ximea_param = "auto_bandwidth_calculation"; + value_type = xiTypeBoolean; + break; + case CV_CAP_PROP_XI_FREE_FFS_SIZE: + ximea_param = "free_ffs_size"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_USED_FFS_SIZE: + ximea_param = "used_ffs_size"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_FFS_ACCESS_KEY: + ximea_param = "ffs_access_key"; + value_type = xiTypeInteger; + break; + case CV_CAP_PROP_XI_SENSOR_FEATURE_SELECTOR: + ximea_param = "sensor_feature_selector"; + value_type = xiTypeEnum; + break; + case CV_CAP_PROP_XI_SENSOR_FEATURE_VALUE: + ximea_param = "sensor_feature_value"; + value_type = xiTypeInteger; + break; + default: + // report invalid parameter as it is not of string type + errMsg("CvCaptureCAM_XIMEA::getProperty", XI_UNKNOWN_PARAM); + return 0; + } + + switch(value_type) + { + case xiTypeInteger : // integer parameter type + case xiTypeEnum : // enumerator parameter type + case xiTypeBoolean : // boolean parameter type + case xiTypeCommand : // command parameter type + stat = xiGetParamInt(hmv, ximea_param.c_str(), &ival); + if(stat == XI_OK) getPropVal = ival; + else errMsg("CvCaptureCAM_XIMEA::getProperty, xiGetParamInt", stat); + break; + case xiTypeFloat : // float parameter type + stat = xiGetParamFloat(hmv, ximea_param.c_str(), &fval); + if(stat == XI_OK) getPropVal = fval; + else errMsg("CvCaptureCAM_XIMEA::getProperty, xiGetParamFloat", stat); + break; + default: + // unknown value type selected + errMsg("CvCaptureCAM_XIMEA::getProperty", XI_WRONG_PARAM_TYPE); + } + return getPropVal; } + +/**********************************************************************************/ -/**********************************************************************************/ - -int CvCaptureCAM_XIMEA::getBpp() +void CvCaptureCAM_XIMEA::errMsg(const char* msg, int errNum) { - switch( image.frm) - { - case XI_MONO8 : - case XI_RAW8 : return 1; - case XI_MONO16 : - case XI_RAW16 : return 2; - case XI_RGB24 : - case XI_RGB_PLANAR : return 3; - case XI_RGB32 : return 4; - default : - return 0; - } + // with XI_OK there is nothing to report + if(errNum == XI_OK) return; + string error_message = ""; + switch(errNum) + { + + case XI_OK : error_message = "Function call succeeded"; break; + case XI_INVALID_HANDLE : error_message = "Invalid handle"; break; + case XI_READREG : error_message = "Register read error"; break; + case XI_WRITEREG : error_message = "Register write error"; break; + case XI_FREE_RESOURCES : error_message = "Freeing resiurces error"; break; + case XI_FREE_CHANNEL : error_message = "Freeing channel error"; break; + case XI_FREE_BANDWIDTH : error_message = "Freeing bandwith error"; break; + case XI_READBLK : error_message = "Read block error"; break; + case XI_WRITEBLK : error_message = "Write block error"; break; + case XI_NO_IMAGE : error_message = "No image"; break; + case XI_TIMEOUT : error_message = "Timeout"; break; + case XI_INVALID_ARG : error_message = "Invalid arguments supplied"; break; + case XI_NOT_SUPPORTED : error_message = "Not supported"; break; + case XI_ISOCH_ATTACH_BUFFERS : error_message = "Attach buffers error"; break; + case XI_GET_OVERLAPPED_RESULT : error_message = "Overlapped result"; break; + case XI_MEMORY_ALLOCATION : error_message = "Memory allocation error"; break; + case XI_DLLCONTEXTISNULL : error_message = "DLL context is NULL"; break; + case XI_DLLCONTEXTISNONZERO : error_message = "DLL context is non zero"; break; + case XI_DLLCONTEXTEXIST : error_message = "DLL context exists"; break; + case XI_TOOMANYDEVICES : error_message = "Too many devices connected"; break; + case XI_ERRORCAMCONTEXT : error_message = "Camera context error"; break; + case XI_UNKNOWN_HARDWARE : error_message = "Unknown hardware"; break; + case XI_INVALID_TM_FILE : error_message = "Invalid TM file"; break; + case XI_INVALID_TM_TAG : error_message = "Invalid TM tag"; break; + case XI_INCOMPLETE_TM : error_message = "Incomplete TM"; break; + case XI_BUS_RESET_FAILED : error_message = "Bus reset error"; break; + case XI_NOT_IMPLEMENTED : error_message = "Not implemented"; break; + case XI_SHADING_TOOBRIGHT : error_message = "Shading too bright"; break; + case XI_SHADING_TOODARK : error_message = "Shading too dark"; break; + case XI_TOO_LOW_GAIN : error_message = "Gain is too low"; break; + case XI_INVALID_BPL : error_message = "Invalid bad pixel list"; break; + case XI_BPL_REALLOC : error_message = "Bad pixel list realloc error"; break; + case XI_INVALID_PIXEL_LIST : error_message = "Invalid pixel list"; break; + case XI_INVALID_FFS : error_message = "Invalid Flash File System"; break; + case XI_INVALID_PROFILE : error_message = "Invalid profile"; break; + case XI_INVALID_CALIBRATION : error_message = "Invalid calibration"; break; + case XI_INVALID_BUFFER : error_message = "Invalid buffer"; break; + case XI_INVALID_DATA : error_message = "Invalid data"; break; + case XI_TGBUSY : error_message = "Timing generator is busy"; break; + case XI_IO_WRONG : error_message = "Wrong operation open/write/read/close"; break; + case XI_ACQUISITION_ALREADY_UP : error_message = "Acquisition already started"; break; + case XI_OLD_DRIVER_VERSION : error_message = "Old version of device driver installed to the system."; break; + case XI_GET_LAST_ERROR : error_message = "To get error code please call GetLastError function."; break; + case XI_CANT_PROCESS : error_message = "Data cant be processed"; break; + case XI_ACQUISITION_STOPED : error_message = "Acquisition has been stopped. It should be started before GetImage."; break; + case XI_ACQUISITION_STOPED_WERR : error_message = "Acquisition has been stoped with error."; break; + case XI_INVALID_INPUT_ICC_PROFILE : error_message = "Input ICC profile missed or corrupted"; break; + case XI_INVALID_OUTPUT_ICC_PROFILE : error_message = "Output ICC profile missed or corrupted"; break; + case XI_DEVICE_NOT_READY : error_message = "Device not ready to operate"; break; + case XI_SHADING_TOOCONTRAST : error_message = "Shading too contrast"; break; + case XI_ALREADY_INITIALIZED : error_message = "Module already initialized"; break; + case XI_NOT_ENOUGH_PRIVILEGES : error_message = "Application doesnt enough privileges(one or more app"; break; + case XI_NOT_COMPATIBLE_DRIVER : error_message = "Installed driver not compatible with current software"; break; + case XI_TM_INVALID_RESOURCE : error_message = "TM file was not loaded successfully from resources"; break; + case XI_DEVICE_HAS_BEEN_RESETED : error_message = "Device has been reseted, abnormal initial state"; break; + case XI_NO_DEVICES_FOUND : error_message = "No Devices Found"; break; + case XI_RESOURCE_OR_FUNCTION_LOCKED : error_message = "Resource(device) or function locked by mutex"; break; + case XI_BUFFER_SIZE_TOO_SMALL : error_message = "Buffer provided by user is too small"; break; + case XI_COULDNT_INIT_PROCESSOR : error_message = "Couldnt initialize processor."; break; + case XI_NOT_INITIALIZED : error_message = "The object/module/procedure/process being referred to has not been started."; break; + case XI_UNKNOWN_PARAM : error_message = "Unknown parameter"; break; + case XI_WRONG_PARAM_VALUE : error_message = "Wrong parameter value"; break; + case XI_WRONG_PARAM_TYPE : error_message = "Wrong parameter type"; break; + case XI_WRONG_PARAM_SIZE : error_message = "Wrong parameter size"; break; + case XI_BUFFER_TOO_SMALL : error_message = "Input buffer too small"; break; + case XI_NOT_SUPPORTED_PARAM : error_message = "Parameter info not supported"; break; + case XI_NOT_SUPPORTED_PARAM_INFO : error_message = "Parameter info not supported"; break; + case XI_NOT_SUPPORTED_DATA_FORMAT : error_message = "Data format not supported"; break; + case XI_READ_ONLY_PARAM : error_message = "Read only parameter"; break; + case XI_BANDWIDTH_NOT_SUPPORTED : error_message = "This camera does not support currently available bandwidth"; break; + case XI_INVALID_FFS_FILE_NAME : error_message = "FFS file selector is invalid or NULL"; break; + case XI_FFS_FILE_NOT_FOUND : error_message = "FFS file not found"; break; + case XI_PROC_OTHER_ERROR : error_message = "Processing error - other"; break; + case XI_PROC_PROCESSING_ERROR : error_message = "Error while image processing."; break; + case XI_PROC_INPUT_FORMAT_UNSUPPORTED : error_message = "Input format is not supported for processing."; break; + case XI_PROC_OUTPUT_FORMAT_UNSUPPORTED : error_message = "Output format is not supported for processing."; break; + default: + error_message = "Unknown error value"; + } + + #if defined WIN32 || defined _WIN32 + char buf[512]=""; + sprintf( buf, "%s : %d, %s\n", msg, errNum, error_message.c_str()); + OutputDebugString(buf); + #else + fprintf(stderr, "%s : %d, %s\n", msg, errNum, error_message.c_str()); + #endif } /**********************************************************************************/ + \ No newline at end of file