ZED Open Capture  v0.6.0
Low level camera driver for the ZED stereo camera family
Public Member Functions | List of all members
sl_oc::video::VideoCapture Class Reference

The VideoCapture class provides image grabbing functions and settings control for all the Stereolabs camera models. More...

#include <videocapture.hpp>

Public Member Functions

 VideoCapture (VideoParams params=VideoParams())
 The default constructor. More...
 
virtual ~VideoCapture ()
 The class destructor. More...
 
bool initializeVideo (int devId=-1)
 Open a ZED camera using the specified ID or searching for the first available. More...
 
const FramegetLastFrame (uint64_t timeout_msec=100)
 Get the last received camera image. More...
 
void getFrameSize (int &width, int &height)
 Get the size of the camera frame. More...
 
int setLEDstatus (bool status)
 Set the status of the camera led. More...
 
int getLEDstatus (bool *status)
 Get the status of the camera led. More...
 
int toggleLED (bool *value)
 Toggle the status of the camera led. More...
 
void setBrightness (int brightness)
 Set the Brightness value. More...
 
int getBrightness ()
 Get the Brightness value. More...
 
void resetBrightness ()
 Reset the Brightness value to default value. More...
 
void setSharpness (int sharpness)
 Set the Sharpness value. More...
 
int getSharpness ()
 Get the Sharpness value. More...
 
void resetSharpness ()
 Reset the Sharpness value to default value. More...
 
void setContrast (int contrast)
 Set the Contrast value. More...
 
int getContrast ()
 Get the Contrast value. More...
 
void resetContrast ()
 Reset the Contrast value to default value. More...
 
void setHue (int hue)
 Set the Hue value. More...
 
int getHue ()
 Get the Hue value. More...
 
void resetHue ()
 Reset the Hue value to default value. More...
 
void setSaturation (int saturation)
 Set the Saturation value. More...
 
int getSaturation ()
 Get the Saturation value. More...
 
void resetSaturation ()
 Reset the Saturation value to default value. More...
 
void setWhiteBalance (int wb)
 Set the White Balance value (disable auto White Balance if active) More...
 
int getWhiteBalance ()
 Get the White Balance value. More...
 
void setAutoWhiteBalance (bool active)
 Enable/Disable the automatic White Balance control. More...
 
bool getAutoWhiteBalance ()
 Get the status of the automatic White Balance control. More...
 
void resetAutoWhiteBalance ()
 Reset the automatic White Balance control value to default value. More...
 
void setGamma (int gamma)
 Set the Gamma value. More...
 
int getGamma ()
 Get the Gamma value. More...
 
void resetGamma ()
 Reset the Gamma value to default value. More...
 
int setAECAGC (bool active)
 Enable/Disable the automatic Exposure and Gain control. More...
 
bool getAECAGC ()
 Get the status of the automatic Exposure and Gain control. More...
 
void resetAECAGC ()
 Reset the automatic Exposure and Gain control value to default value. More...
 
bool setROIforAECAGC (CAM_SENS_POS side, uint16_t x, uint16_t y, uint16_t w, uint16_t h)
 Set Region Of Interest (ROI) for AECAGC control. More...
 
bool resetROIforAECAGC (CAM_SENS_POS side)
 Reset the ROI for AECAGC control. More...
 
bool getROIforAECAGC (CAM_SENS_POS side, uint16_t &x, uint16_t &y, uint16_t &w, uint16_t &h)
 Get the coordinates of the current ROI for AECAGC control. More...
 
void setGain (CAM_SENS_POS cam, int gain)
 Set the Gain value (disable Exposure and Gain control if active) More...
 
int getGain (CAM_SENS_POS cam)
 Get the current Gain value. More...
 
void setExposure (CAM_SENS_POS cam, int exposure)
 Set the Exposure value (disable Exposure and Gain control if active) More...
 
int getExposure (CAM_SENS_POS cam)
 Get the current Exposure value. More...
 
int getSerialNumber ()
 Retrieve the serial number of the connected camera. More...
 
void setColorBars (int side, bool c)
 Utils fct to set Color Bars on Image. More...
 
std::string getDeviceName ()
 Retrieve the OS device name. More...
 
int getDeviceId ()
 Retrieve the OS device index. More...
 
bool enableAecAgcSensLogging (bool enable, int frame_skip=10)
 Start logging to file of AEG/AGC camera registers. More...
 
void saveAllISPRegisters (std::string filename)
 Save all ISP camera registers into a file. More...
 
void saveAllSensorsRegisters (std::string filename)
 Save all sensors ctrl register. More...
 
bool enableSensorSync (sensors::SensorCapture *sensCap=nullptr)
 Enable synchronizations between Camera frame and Sensors timestamps. More...
 
void setReadyToSync ()
 Indicates that the SensorCapture object received the HW sync signal and a frame must be synchronized to the last Sensor Data. More...
 
bool resetAGCAECregisters ()
 

Detailed Description

The VideoCapture class provides image grabbing functions and settings control for all the Stereolabs camera models.

Examples
zed_oc_control_example.cpp, zed_oc_depth_example.cpp, zed_oc_rectify_example.cpp, zed_oc_sync_example.cpp, zed_oc_tune_stereo_sgbm.cpp, and zed_oc_video_example.cpp.

Definition at line 64 of file videocapture.hpp.

Constructor & Destructor Documentation

◆ VideoCapture()

sl_oc::video::VideoCapture::VideoCapture ( VideoParams  params = VideoParams())

The default constructor.

  • Parameters
    paramsthe initialization parameters (see VideoParams)

Definition at line 115 of file videocapture.cpp.

116 {
117  memcpy( &mParams, &params, sizeof(VideoParams) );
118 
119  if( mParams.verbose )
120  {
121  std::string ver =
122  "ZED Open Capture - Camera module - Version: "
123  + std::to_string(mMajorVer) + "."
124  + std::to_string(mMinorVer) + "."
125  + std::to_string(mPatchVer);
126  INFO_OUT(mParams.verbose,ver);
127  }
128 
129  // Check that FPS is coherent with user resolution
130  checkResFps( );
131 
132  // Calculate gain zones (required because the raw gain control is not continuous in the range of values)
133  mGainSegMax = (GAIN_ZONE4_MAX-GAIN_ZONE4_MIN)+(GAIN_ZONE3_MAX-GAIN_ZONE3_MIN)+(GAIN_ZONE2_MAX-GAIN_ZONE2_MIN)+(GAIN_ZONE1_MAX-GAIN_ZONE1_MIN);
134 
135  // FPS mapping
136  if( mFps <= 15 )
137  mExpoureRawMax = EXP_RAW_MAX_15FPS;
138  else if( mFps <= 30 )
139  mExpoureRawMax = EXP_RAW_MAX_30FPS;
140  else if( mFps <= 60 )
141  mExpoureRawMax = EXP_RAW_MAX_60FPS;
142  else
143  mExpoureRawMax = EXP_RAW_MAX_100FPS;
144 }
struct sl_oc::video::VideoParams VideoParams
The camera configuration parameters.
sl_oc::video::VideoParams params

References params, and sl_oc::video::VideoParams::verbose.

◆ ~VideoCapture()

sl_oc::video::VideoCapture::~VideoCapture ( )
virtual

The class destructor.

Definition at line 146 of file videocapture.cpp.

147 {
148  reset();
149 }

Member Function Documentation

◆ enableAecAgcSensLogging()

bool sl_oc::video::VideoCapture::enableAecAgcSensLogging ( bool  enable,
int  frame_skip = 10 
)

Start logging to file of AEG/AGC camera registers.

Parameters
enableset to true to enable logging
frame_skipnumber of frames to skip when logging to file
Returns
true if log file can be correctly created/closed
Examples
zed_oc_control_example.cpp.

Definition at line 1939 of file videocapture.cpp.

1940 {
1941  if(!enable)
1942  {
1943  mLogEnable=false;
1944  if(mLogFileLeft.is_open())
1945  {
1946  mLogFileLeft.close();
1947  }
1948  if(mLogFileRight.is_open())
1949  {
1950  mLogFileRight.close();
1951  }
1952  return true;
1953  }
1954 
1955  mLogFrameSkip = frame_skip;
1956 
1957  mLogFilenameLeft = getCurrentDateTime(DATE);
1958  mLogFilenameLeft += "_";
1959  mLogFilenameLeft += getCurrentDateTime(TIME);
1960  mLogFilenameLeft += "_agc_aec_registers-LEFT.csv";
1961 
1962  mLogFilenameRight = getCurrentDateTime(DATE);
1963  mLogFilenameRight += "_";
1964  mLogFilenameRight += getCurrentDateTime(TIME);
1965  mLogFilenameRight += "_agc_aec_registers-RIGHT.csv";
1966 
1967  mLogFileLeft.open(mLogFilenameLeft, std::ofstream::out );
1968  mLogFileRight.open(mLogFilenameRight, std::ofstream::out );
1969 
1970  if(mLogFileLeft.bad())
1971  {
1972  std::cerr << "Logging not started. Error creating the log file: '" << mLogFilenameLeft << "'" << std::endl;
1973  mLogEnable = false;
1974  return false;
1975  }
1976 
1977  if(mLogFileRight.bad())
1978  {
1979  std::cerr << "Logging not started. Error creating the log file: '" << mLogFilenameRight << "'" << std::endl;
1980  mLogEnable = false;
1981  mLogFileLeft.close();
1982  return false;
1983  }
1984 
1985  mLogFileLeft << "TIMESTAMP" << LOG_SEP;
1986  mLogFileLeft << "OV580-ISP_EN_HIGH" << LOG_SEP;
1987  mLogFileLeft << "OV580-yavg_low" << LOG_SEP;
1988  mLogFileLeft << "OV580-yavg_high" << LOG_SEP;
1989  mLogFileLeft << "OV580-interrupt_ctrl1";
1990 
1991  mLogFileRight << "TIMESTAMP" << LOG_SEP;
1992  mLogFileRight << "OV580-ISP_EN_HIGH" << LOG_SEP;
1993  mLogFileRight << "OV580-yavg_low" << LOG_SEP;
1994  mLogFileRight << "OV580-yavg_high" << LOG_SEP;
1995  mLogFileRight << "OV580-interrupt_ctrl1";
1996 
1997  for (int addr = 0x00; addr <= 0x22; ++addr)
1998  {
1999  mLogFileLeft << LOG_SEP << "OV580-YAVG[0x" << std::hex << std::setfill('0') << std::setw(2) << addr << "]";
2000  mLogFileRight << LOG_SEP << "OV580-YAVG[0x" << std::hex << std::setfill('0') << std::setw(2) << addr << "]";
2001  }
2002 
2003  for (int addr = 0x3500; addr <= 0x3515; ++addr)
2004  {
2005  mLogFileLeft << LOG_SEP << "OV4689-GAIN_EXP[0x" << std::hex << std::setfill('0') << std::setw(4) << addr << "]";
2006  mLogFileRight << LOG_SEP << "OV4689-GAIN_EXP[0x" << std::hex << std::setfill('0') << std::setw(4) << addr << "]";
2007  }
2008 
2009  mLogFileLeft << std::endl;
2010  mLogFileRight << std::endl;
2011 
2012  mLogEnable = true;
2013  return true;
2014 }

Referenced by main().

◆ enableSensorSync()

bool sl_oc::video::VideoCapture::enableSensorSync ( sensors::SensorCapture sensCap = nullptr)

Enable synchronizations between Camera frame and Sensors timestamps.

Parameters
sensCappointer to SensorCapture object
Returns
true if synchronization has been correctly started

Definition at line 2151 of file videocapture.cpp.

2152 {
2153  if(!sensCap)
2154  return false;
2155 
2156  // Activate low level sync mechanism
2157  ll_activate_sync();
2158 
2159  mSyncEnabled = true;
2160  mSensPtr = sensCap;
2161 
2162  mSensPtr->setVideoPtr(this);
2163 
2164  return true;
2165 }
void setVideoPtr(video::VideoCapture *videoPtr)
Called by VideoCapture to set the pointer to it.

References sl_oc::sensors::SensorCapture::setVideoPtr().

Referenced by main().

◆ getAECAGC()

bool sl_oc::video::VideoCapture::getAECAGC ( )

Get the status of the automatic Exposure and Gain control.

Returns
the status of the automatic Exposure and Gain control
Examples
zed_oc_control_example.cpp.

Definition at line 1711 of file videocapture.cpp.

1712 {
1713  int resL = ll_isp_is_aecagc(0);
1714  int resR = ll_isp_is_aecagc(1);
1715  return (resL && resR);
1716 }

Referenced by setExposure(), and setGain().

◆ getAutoWhiteBalance()

bool sl_oc::video::VideoCapture::getAutoWhiteBalance ( )

Get the status of the automatic White Balance control.

Returns
the status of the automatic White Balance control
Examples
zed_oc_control_example.cpp.

Definition at line 1664 of file videocapture.cpp.

1665 {
1666  return (getCameraControlSettings(LINUX_CTRL_AWB_AUTO)!=0);
1667 }

Referenced by setWhiteBalance().

◆ getBrightness()

int sl_oc::video::VideoCapture::getBrightness ( )

Get the Brightness value.

Returns
the current Brightness value
Examples
zed_oc_control_example.cpp.

Definition at line 1585 of file videocapture.cpp.

1586 {
1587  return getCameraControlSettings(LINUX_CTRL_BRIGHTNESS);
1588 }

◆ getContrast()

int sl_oc::video::VideoCapture::getContrast ( )

Get the Contrast value.

Returns
the current Contrast value
Examples
zed_oc_control_example.cpp.

Definition at line 1615 of file videocapture.cpp.

1616 {
1617  return getCameraControlSettings(LINUX_CTRL_CONTRAST);
1618 }

◆ getDeviceId()

int sl_oc::video::VideoCapture::getDeviceId ( )
inline

Retrieve the OS device index.

Returns
the OS device index

Definition at line 358 of file videocapture.hpp.

358 {return mDevId;}

◆ getDeviceName()

std::string sl_oc::video::VideoCapture::getDeviceName ( )
inline

Retrieve the OS device name.

Returns
the OS device name
Examples
zed_oc_video_example.cpp.

Definition at line 352 of file videocapture.hpp.

352 {return mDevName;}

Referenced by main().

◆ getExposure()

int sl_oc::video::VideoCapture::getExposure ( CAM_SENS_POS  cam)

Get the current Exposure value.

Parameters
camposition of the camera sensor (see CAM_SENS_POS)
Returns
the current Exposure value
Examples
zed_oc_control_example.cpp.

Definition at line 1867 of file videocapture.cpp.

1868 {
1869  int rawExp=0;
1870 
1871  unsigned char val[3];
1872  memset(val, 0, 3);
1873 
1874  int sensorId = static_cast<int>(cam);
1875 
1876  int r = ll_isp_get_exposure(val, sensorId);
1877  if(r<0)
1878  return r;
1879  rawExp = (int) ((val[2] << 12) + (val[1] << 4) + (val[0] >> 4));
1880 
1881  //std::cout << "Get Raw Exp: " << rawExp << std::endl;
1882 
1883  int exposure = static_cast<int>(std::round((100.0*rawExp)/mExpoureRawMax));
1884  return exposure;
1885 }

◆ getFrameSize()

void sl_oc::video::VideoCapture::getFrameSize ( int &  width,
int &  height 
)
inline

Get the size of the camera frame.

Parameters
widththe frame width
heightthe frame height
Examples
zed_oc_depth_example.cpp, and zed_oc_rectify_example.cpp.

Definition at line 105 of file videocapture.hpp.

105 {width=mWidth;height=mHeight;}

Referenced by main().

◆ getGain()

int sl_oc::video::VideoCapture::getGain ( CAM_SENS_POS  cam)

Get the current Gain value.

Parameters
camposition of the camera sensor (see CAM_SENS_POS)
Returns
the current Gain value
Examples
zed_oc_control_example.cpp.

Definition at line 1825 of file videocapture.cpp.

1826 {
1827  int rawGain=0;
1828 
1829  uint8_t val[3];
1830  memset(val, 0, 3);
1831 
1832  int sensorId = static_cast<int>(cam);
1833  int r = ll_isp_get_gain(val, sensorId);
1834  if(r<0)
1835  return r;
1836 
1837  rawGain = (int) ((val[1] << 8) + val[0]);
1838  return calcGainValue(rawGain);
1839 }

◆ getGamma()

int sl_oc::video::VideoCapture::getGamma ( )

Get the Gamma value.

Returns
the current Gamma value
Examples
zed_oc_control_example.cpp.

Definition at line 1699 of file videocapture.cpp.

1699  {
1700  return getCameraControlSettings(LINUX_CTRL_GAMMA);
1701 }

◆ getHue()

int sl_oc::video::VideoCapture::getHue ( )

Get the Hue value.

Returns
the current Hue value
Examples
zed_oc_control_example.cpp.

Definition at line 1630 of file videocapture.cpp.

1631 {
1632  return getCameraControlSettings(LINUX_CTRL_HUE);
1633 }

◆ getLastFrame()

const Frame & sl_oc::video::VideoCapture::getLastFrame ( uint64_t  timeout_msec = 100)

Get the last received camera image.

Parameters
timeout_msecframe grabbing timeout in millisecond.
Returns
returns a reference to the last received frame as pointer.
Note
To check if a new frame is available it is possible to compare the timestamp of the returned frame with the timestamp of the previous valid frame
Frame received will contains the RAW buffer from the camera, in YUV4:2:2 color format and in side by side mode. Images must then be converted to RGB for proper display and will not be rectified.
Examples
zed_oc_depth_example.cpp, zed_oc_rectify_example.cpp, and zed_oc_video_example.cpp.

Definition at line 890 of file videocapture.cpp.

891 {
892  // ----> Wait for a new frame
893  uint64_t time_count = timeout_msec*10;
894  while( !mNewFrame )
895  {
896  if(time_count==0)
897  {
898  return mLastFrame;
899  }
900  time_count--;
901  usleep(100);
902  }
903  // <---- Wait for a new frame
904 
905  // Get the frame mutex
906  const std::lock_guard<std::mutex> lock(mBufMutex);
907  mNewFrame = false;
908  return mLastFrame;
909 }

Referenced by main().

◆ getLEDstatus()

int sl_oc::video::VideoCapture::getLEDstatus ( bool *  status)

Get the status of the camera led.

Parameters
statusreturned status: true for "ON", false for "OFF"
Returns
returns a negative value if an error occurred

Definition at line 1418 of file videocapture.cpp.

1419 {
1420  if( status==nullptr)
1421  {
1422  return -1;
1423  }
1424 
1425  uint8_t val;
1426  int hr = ll_set_gpio_direction(2, 1);
1427  hr += ll_get_gpio_value(2, &val);
1428  *status = val!=0;
1429  return hr;
1430 }

Referenced by toggleLED().

◆ getROIforAECAGC()

bool sl_oc::video::VideoCapture::getROIforAECAGC ( CAM_SENS_POS  side,
uint16_t &  x,
uint16_t &  y,
uint16_t &  w,
uint16_t &  h 
)

Get the coordinates of the current ROI for AECAGC control.

Parameters
sideposition of the camera sensor (see CAM_SENS_POS)
xtop left ROI rectangle X coordinate
ytop left ROI rectangle Y coordinate
wROI rectangle width
hROI rectangle width
Returns
returns true if no errors occurred
Examples
zed_oc_control_example.cpp.

Definition at line 1773 of file videocapture.cpp.

1774 {
1775  uint8_t x_start_high = 0;
1776  uint8_t x_start_low = 0;
1777  uint8_t y_start_high =0;
1778  uint8_t y_start_low = 0;
1779  uint8_t w_start_high =0;
1780  uint8_t w_start_low = 0;
1781  uint8_t h_start_high = 0;
1782  uint8_t h_start_low = 0;
1783  uint32_t ulAddr = 0x801810C0;
1784  if (static_cast<int>(side)==1)
1785  ulAddr= 0x801818C0;
1786  int r = ll_read_system_register(ulAddr,&x_start_high);ulAddr++;usleep(100);
1787  r += ll_read_system_register(ulAddr,&x_start_low);ulAddr++;usleep(100);
1788  r += ll_read_system_register(ulAddr,&y_start_high);ulAddr++;usleep(100);
1789  r += ll_read_system_register(ulAddr,&y_start_low);ulAddr++;usleep(100);
1790  r += ll_read_system_register(ulAddr,&w_start_high);ulAddr++;usleep(100);
1791  r += ll_read_system_register(ulAddr,&w_start_low);ulAddr++;usleep(100);
1792  r += ll_read_system_register(ulAddr,&h_start_high);ulAddr++;usleep(100);
1793  r += ll_read_system_register(ulAddr,&h_start_low);ulAddr++;usleep(100);
1794 
1795  x = x_start_high*256 + x_start_low;
1796  y = y_start_high*256 + y_start_low;
1797  w = w_start_high*256 + w_start_low;
1798  h = h_start_high*256 + h_start_low;
1799 
1800  return (r==0);
1801 }

◆ getSaturation()

int sl_oc::video::VideoCapture::getSaturation ( )

Get the Saturation value.

Returns
the current Saturation value
Examples
zed_oc_control_example.cpp.

Definition at line 1645 of file videocapture.cpp.

1646 {
1647  return getCameraControlSettings(LINUX_CTRL_SATURATION);
1648 }

◆ getSerialNumber()

int sl_oc::video::VideoCapture::getSerialNumber ( )

Retrieve the serial number of the connected camera.

Returns
the serial number of the connected camera
Examples
zed_oc_depth_example.cpp, zed_oc_rectify_example.cpp, and zed_oc_video_example.cpp.

Definition at line 548 of file videocapture.cpp.

549 {
550  /*if(!mInitialized)
551  return -1;*/
552 
553  int ulValue = -1;
554 
555  uint8_t UNIQUE_BUF[384];
556  memset(UNIQUE_BUF, 0, 384);
557 
558  int res = -1;
559 
560  int try_count = 0;
561  while(res!=0)
562  {
563  res = ll_SPI_FlashProgramRead(&UNIQUE_BUF[0], UNIQUE_ID_START, 64, true);
564 
565  //check bytes read
566  if (UNIQUE_BUF[0] != 'O') {
567  res = -1;
568  }
569  if (UNIQUE_BUF[1] != 'V') {
570  res = -1;
571  }
572 
573  try_count++;
574  if (try_count>500)
575  break;
576  usleep(1000);
577  }
578 
579  if (res != 0)
580  return -1;
581 
582  //check bytes read
583  if (UNIQUE_BUF[0] != 'O') {
584  return -1;
585  }
586  if (UNIQUE_BUF[1] != 'V') {
587  return -1;
588  }
589 
590  ulValue = (UNIQUE_BUF[2] << 24) + (UNIQUE_BUF[3] << 16) + (UNIQUE_BUF[4] << 8) + UNIQUE_BUF[5];
591 
592  char buff[128];
593  memset(buff, 0, 128);
594  sprintf(buff, "%x", ulValue);
595  return (int) atoi(buff);
596 }

Referenced by main().

◆ getSharpness()

int sl_oc::video::VideoCapture::getSharpness ( )

Get the Sharpness value.

Returns
the current Sharpness value
Examples
zed_oc_control_example.cpp.

Definition at line 1600 of file videocapture.cpp.

1601 {
1602  return getCameraControlSettings(LINUX_CTRL_SHARPNESS);
1603 }

◆ getWhiteBalance()

int sl_oc::video::VideoCapture::getWhiteBalance ( )

Get the White Balance value.

Returns
the current White Balance value
Examples
zed_oc_control_example.cpp.

Definition at line 1650 of file videocapture.cpp.

1651 {
1652  return getCameraControlSettings(LINUX_CTRL_AWB);
1653 }

◆ initializeVideo()

bool sl_oc::video::VideoCapture::initializeVideo ( int  devId = -1)

Open a ZED camera using the specified ID or searching for the first available.

Parameters
devIdId of the camera (see /dev/video*). Use -1 to open the first available camera
Returns
returns true if the camera is correctly opened
Examples
zed_oc_depth_example.cpp, zed_oc_rectify_example.cpp, and zed_oc_video_example.cpp.

Definition at line 276 of file videocapture.cpp.

277 {
278  reset();
279 
280  bool opened=false;
281 
282  if( devId==-1 )
283  {
284  // Try to open all the devices until the first success (max allowed by v4l: 64)
285  for( uint8_t id=0; id<64; id++ )
286  {
287  opened = openCamera( id );
288  if(opened) break;
289  }
290  }
291  else
292  {
293  opened = openCamera( static_cast<uint8_t>(devId) );
294  }
295 
296  if(!opened)
297  {
298  return false;
299  }
300 
301  mInitialized = startCapture();
302 
303  if( mParams.verbose && mInitialized)
304  {
305  std::string msg = "Device '" + mDevName + "' opened";
306  INFO_OUT(mParams.verbose,msg );
307  }
308 
309  setLEDstatus( true );
310 
311  resetAECAGC();
313  resetBrightness();
314  resetContrast();
315  resetGamma();
316  resetHue();
317  resetSaturation();
318  resetSharpness();
319 
320  return mInitialized;
321 }
void resetBrightness()
Reset the Brightness value to default value.
int setLEDstatus(bool status)
Set the status of the camera led.
void resetGamma()
Reset the Gamma value to default value.
void resetHue()
Reset the Hue value to default value.
void resetAutoWhiteBalance()
Reset the automatic White Balance control value to default value.
void resetSharpness()
Reset the Sharpness value to default value.
void resetSaturation()
Reset the Saturation value to default value.
void resetAECAGC()
Reset the automatic Exposure and Gain control value to default value.
void resetContrast()
Reset the Contrast value to default value.

References resetAECAGC(), resetAutoWhiteBalance(), resetBrightness(), resetContrast(), resetGamma(), resetHue(), resetSaturation(), resetSharpness(), setLEDstatus(), and sl_oc::video::VideoParams::verbose.

Referenced by main().

◆ resetAECAGC()

void sl_oc::video::VideoCapture::resetAECAGC ( )

Reset the automatic Exposure and Gain control value to default value.

Examples
zed_oc_control_example.cpp.

Definition at line 1718 of file videocapture.cpp.

1719 {
1720  setAECAGC(true);
1721 }
int setAECAGC(bool active)
Enable/Disable the automatic Exposure and Gain control.

References setAECAGC().

Referenced by initializeVideo().

◆ resetAGCAECregisters()

bool sl_oc::video::VideoCapture::resetAGCAECregisters ( )
Examples
zed_oc_control_example.cpp.

Definition at line 2138 of file videocapture.cpp.

2138  {
2139  int res = 0;
2140 
2141  res += ll_write_sensor_register( 0, 1, 0x3503, 0x04);
2142  res += ll_write_sensor_register( 1, 1, 0x3503, 0x04);
2143  res += ll_write_sensor_register( 0, 1, 0x3505, 0x00);
2144  res += ll_write_sensor_register( 1, 1, 0x3505, 0x00);
2145 
2146  return res==0;
2147 }

◆ resetAutoWhiteBalance()

void sl_oc::video::VideoCapture::resetAutoWhiteBalance ( )

Reset the automatic White Balance control value to default value.

Examples
zed_oc_control_example.cpp.

Definition at line 1674 of file videocapture.cpp.

1675 {
1676  setAutoWhiteBalance(true);
1677 }
void setAutoWhiteBalance(bool active)
Enable/Disable the automatic White Balance control.

References setAutoWhiteBalance().

Referenced by initializeVideo().

◆ resetBrightness()

void sl_oc::video::VideoCapture::resetBrightness ( )

Reset the Brightness value to default value.

Examples
zed_oc_control_example.cpp.

Definition at line 1580 of file videocapture.cpp.

1581 {
1582  resetCameraControlSettings(LINUX_CTRL_BRIGHTNESS);
1583 }

Referenced by initializeVideo().

◆ resetContrast()

void sl_oc::video::VideoCapture::resetContrast ( )

Reset the Contrast value to default value.

Examples
zed_oc_control_example.cpp.

Definition at line 1610 of file videocapture.cpp.

1611 {
1612  resetCameraControlSettings(LINUX_CTRL_CONTRAST);
1613 }

Referenced by initializeVideo().

◆ resetGamma()

void sl_oc::video::VideoCapture::resetGamma ( )

Reset the Gamma value to default value.

Examples
zed_oc_control_example.cpp.

Definition at line 1691 of file videocapture.cpp.

1692 {
1693  int def_value = DEFAULT_GAMMA_NOECT;
1694  setGammaPreset(0,def_value);
1695  setGammaPreset(1,def_value);
1696  setCameraControlSettings(LINUX_CTRL_GAMMA, def_value);
1697 }

Referenced by initializeVideo().

◆ resetHue()

void sl_oc::video::VideoCapture::resetHue ( )

Reset the Hue value to default value.

Examples
zed_oc_control_example.cpp.

Definition at line 1625 of file videocapture.cpp.

1626 {
1627  resetCameraControlSettings(LINUX_CTRL_HUE);
1628 }

Referenced by initializeVideo().

◆ resetROIforAECAGC()

bool sl_oc::video::VideoCapture::resetROIforAECAGC ( CAM_SENS_POS  side)

Reset the ROI for AECAGC control.

Parameters
sideposition of the camera sensor (see CAM_SENS_POS)
Returns
returns true if the ROI has been correctly reset
Examples
zed_oc_control_example.cpp.

Definition at line 1768 of file videocapture.cpp.

1769 {
1770  return setROIforAECAGC(side, 0,0, mWidth/2, mHeight);
1771 }
bool setROIforAECAGC(CAM_SENS_POS side, uint16_t x, uint16_t y, uint16_t w, uint16_t h)
Set Region Of Interest (ROI) for AECAGC control.

References setROIforAECAGC().

◆ resetSaturation()

void sl_oc::video::VideoCapture::resetSaturation ( )

Reset the Saturation value to default value.

Examples
zed_oc_control_example.cpp.

Definition at line 1640 of file videocapture.cpp.

1641 {
1642  resetCameraControlSettings(LINUX_CTRL_SATURATION);
1643 }

Referenced by initializeVideo().

◆ resetSharpness()

void sl_oc::video::VideoCapture::resetSharpness ( )

Reset the Sharpness value to default value.

Examples
zed_oc_control_example.cpp.

Definition at line 1595 of file videocapture.cpp.

1596 {
1597  resetCameraControlSettings(LINUX_CTRL_SHARPNESS);
1598 }

Referenced by initializeVideo().

◆ saveAllISPRegisters()

void sl_oc::video::VideoCapture::saveAllISPRegisters ( std::string  filename)

Save all ISP camera registers into a file.

Parameters
filenamecsv filename
Note
CSV file will contain Adress , L value, R value

Definition at line 2030 of file videocapture.cpp.

2031 {
2032  std::ofstream logFile;
2033  logFile.open(filename,std::ofstream::out);
2034  int res = 0;
2035  unsigned long long ulAddrL = 0x80181000;
2036  unsigned long long ulAddrR = 0x80181800;
2037 
2038  for (int p = 0;p<0x800;p++)
2039  {
2040  uint8_t valL,valR;
2041  res += ll_read_system_register( ulAddrL+p, &valL);
2042  res += ll_read_system_register( ulAddrR+p, &valR);
2043 
2044  logFile <<"0x" << std::hex << std::setfill('0') << std::setw(8) << static_cast<unsigned long long>(ulAddrL+p)<<" , "<<std::hex << std::setfill('0') << std::setw(2) << static_cast<unsigned long long>(valL)<<" , "<<std::hex << std::setfill('0') << std::setw(2) << static_cast<unsigned long long>(valR)<<std::endl;
2045  usleep(10);
2046  }
2047 
2048  logFile.close();
2049 }

Referenced by main().

◆ saveAllSensorsRegisters()

void sl_oc::video::VideoCapture::saveAllSensorsRegisters ( std::string  filename)

Save all sensors ctrl register.

Parameters
filenamecsv filename
Note
CSV file will contain Adress , L value, R value

Definition at line 2051 of file videocapture.cpp.

2052 {
2053  std::ofstream logFile;
2054  logFile.open(filename,std::ofstream::out);
2055 
2056  int res = 0;
2057  for (int addr = 0x3000; addr <= 0x6000; ++addr)
2058  {
2059  uint8_t valL,valR;
2060  res += ll_read_sensor_register( 0, 1, addr, &valL);
2061  res += ll_read_sensor_register( 1, 1, addr, &valR);
2062 
2063  usleep(10);
2064  logFile <<"0x" << std::hex << std::setfill('0') << std::setw(8) << static_cast<int>(addr)<<" , "<<std::hex << std::setfill('0') << std::setw(2) << static_cast<unsigned long long>(valL)<<" , "<<std::hex << std::setfill('0') << std::setw(2) << static_cast<unsigned long long>(valR)<<std::endl;
2065  }
2066 
2067  logFile.close();
2068 }

Referenced by main().

◆ setAECAGC()

int sl_oc::video::VideoCapture::setAECAGC ( bool  active)

Enable/Disable the automatic Exposure and Gain control.

Parameters
activetrue to activate automatic White Balance
Examples
zed_oc_control_example.cpp.

Definition at line 1703 of file videocapture.cpp.

1704 {
1705  int res = 0;
1706  res += ll_isp_aecagc_enable(0, active);
1707  res += ll_isp_aecagc_enable(1, active);
1708  return res;
1709 }

Referenced by main(), resetAECAGC(), setExposure(), and setGain().

◆ setAutoWhiteBalance()

void sl_oc::video::VideoCapture::setAutoWhiteBalance ( bool  active)

Enable/Disable the automatic White Balance control.

Parameters
activetrue to activate automatic White Balance
Examples
zed_oc_control_example.cpp.

Definition at line 1669 of file videocapture.cpp.

1670 {
1671  setCameraControlSettings(LINUX_CTRL_AWB_AUTO, active?1:0);
1672 }

Referenced by main(), resetAutoWhiteBalance(), and setWhiteBalance().

◆ setBrightness()

void sl_oc::video::VideoCapture::setBrightness ( int  brightness)

Set the Brightness value.

Parameters
brightnessBrightness value in the range [0,8]
Examples
zed_oc_control_example.cpp.

Definition at line 1575 of file videocapture.cpp.

1576 {
1577  setCameraControlSettings(LINUX_CTRL_BRIGHTNESS, brightness);
1578 }

◆ setColorBars()

void sl_oc::video::VideoCapture::setColorBars ( int  side,
bool  c 
)

Utils fct to set Color Bars on Image.

Definition at line 2016 of file videocapture.cpp.

2017 {
2018 
2019 
2020  unsigned long long ulAddr2 = 0x80181080;
2021 
2022  if (side==1)
2023  ulAddr2 = 0x80181880;
2024 
2025  unsigned char ulValue2 =c?128:0;
2026  ll_write_system_register(ulAddr2,ulValue2);
2027 }

Referenced by main().

◆ setContrast()

void sl_oc::video::VideoCapture::setContrast ( int  contrast)

Set the Contrast value.

Parameters
contrastContrast value in the range [0,8]
Examples
zed_oc_control_example.cpp.

Definition at line 1605 of file videocapture.cpp.

1606 {
1607  setCameraControlSettings(LINUX_CTRL_CONTRAST, contrast);
1608 }

◆ setExposure()

void sl_oc::video::VideoCapture::setExposure ( CAM_SENS_POS  cam,
int  exposure 
)

Set the Exposure value (disable Exposure and Gain control if active)

Parameters
camposition of the camera sensor (see CAM_SENS_POS)
exposureExposure value in the range [0,100]
Examples
zed_oc_control_example.cpp.

Definition at line 1841 of file videocapture.cpp.

1842 {
1843  unsigned char ucExpH, ucExpM, ucExpL;
1844 
1845  if(getAECAGC())
1846  setAECAGC(false);
1847 
1848  if(exposure < DEFAULT_MIN_EXP)
1849  exposure = DEFAULT_MIN_EXP;
1850  if(exposure > DEFAULT_MAX_EXP)
1851  exposure = DEFAULT_MAX_EXP;
1852 
1853  int rawExp = (mExpoureRawMax * ((float) exposure / 100.0));
1854  if(rawExp<EXP_RAW_MIN)
1855  rawExp = EXP_RAW_MIN;
1856 
1857  //std::cout << "Set Raw Exp: " << rawExp << std::endl;
1858 
1859  int sensorId = static_cast<int>(cam);
1860 
1861  ucExpH = (rawExp >> 12) & 0xff;
1862  ucExpM = (rawExp >> 4) & 0xff;
1863  ucExpL = (rawExp << 4) & 0xf0;
1864  ll_isp_set_exposure(ucExpH, ucExpM, ucExpL, sensorId);
1865 }
bool getAECAGC()
Get the status of the automatic Exposure and Gain control.

References getAECAGC(), and setAECAGC().

◆ setGain()

void sl_oc::video::VideoCapture::setGain ( CAM_SENS_POS  cam,
int  gain 
)

Set the Gain value (disable Exposure and Gain control if active)

Parameters
camposition of the camera sensor (see CAM_SENS_POS)
gainGain value in the range [0,100]
Examples
zed_oc_control_example.cpp.

Definition at line 1803 of file videocapture.cpp.

1804 {
1805  if(getAECAGC())
1806  setAECAGC(false);
1807 
1808  if (gain <= DEFAULT_MIN_GAIN)
1809  gain = DEFAULT_MIN_GAIN;
1810  else if (gain >= DEFAULT_MAX_GAIN)
1811  gain = DEFAULT_MAX_GAIN;
1812 
1813  uint8_t ucGainH=0, ucGainM=0, ucGainL=0;
1814 
1815  int rawGain = calcRawGainValue(gain);
1816 
1817  int sensorId = static_cast<int>(cam);
1818 
1819  ucGainM = (rawGain >> 8) & 0xff;
1820  ucGainL = rawGain & 0xff;
1821  ll_isp_set_gain(ucGainH, ucGainM, ucGainL, sensorId);
1822 
1823 }

References getAECAGC(), and setAECAGC().

◆ setGamma()

void sl_oc::video::VideoCapture::setGamma ( int  gamma)

Set the Gamma value.

Parameters
gammaGamma value in the range [1,9]
Examples
zed_oc_control_example.cpp.

Definition at line 1679 of file videocapture.cpp.

1680 {
1681  int current_gamma = getCameraControlSettings(LINUX_CTRL_GAMMA);
1682 
1683  if (gamma!=current_gamma)
1684  {
1685  setGammaPreset(0,gamma);
1686  setGammaPreset(1,gamma);
1687  setCameraControlSettings(LINUX_CTRL_GAMMA, gamma);
1688  }
1689 }

◆ setHue()

void sl_oc::video::VideoCapture::setHue ( int  hue)

Set the Hue value.

Parameters
hueHue value in the range [0,11]
Examples
zed_oc_control_example.cpp.

Definition at line 1620 of file videocapture.cpp.

1621 {
1622  setCameraControlSettings(LINUX_CTRL_HUE, hue);
1623 }

◆ setLEDstatus()

int sl_oc::video::VideoCapture::setLEDstatus ( bool  status)

Set the status of the camera led.

Parameters
statustrue for "ON", false for "OFF"
Returns
returns a negative value if an error occurred

Definition at line 1403 of file videocapture.cpp.

1404 {
1405  int hr = 0;
1406  //LED GPIO : GPIO 2
1407  if (status) {
1408  hr += ll_set_gpio_direction(2, 0);
1409  hr += ll_set_gpio_value(2, 1);
1410  } else {
1411  hr += ll_set_gpio_direction(2, 0);
1412  hr += ll_set_gpio_value(2, 0);
1413  }
1414 
1415  return hr;
1416 }

Referenced by initializeVideo(), and toggleLED().

◆ setReadyToSync()

void sl_oc::video::VideoCapture::setReadyToSync ( )
inline

Indicates that the SensorCapture object received the HW sync signal and a frame must be synchronized to the last Sensor Data.

Definition at line 397 of file videocapture.hpp.

397 { mSensReadyToSync=true; }

◆ setROIforAECAGC()

bool sl_oc::video::VideoCapture::setROIforAECAGC ( CAM_SENS_POS  side,
uint16_t  x,
uint16_t  y,
uint16_t  w,
uint16_t  h 
)

Set Region Of Interest (ROI) for AECAGC control.

Parameters
sideposition of the camera sensor (see CAM_SENS_POS)
xtop left ROI rectangle X coordinate
ytop left ROI rectangle Y coordinate
wROI rectangle width
hROI rectangle width
Returns
returns true if the ROI has been correctly set

Definition at line 1723 of file videocapture.cpp.

1724 {
1725  if(side!=CAM_SENS_POS::LEFT && side!=CAM_SENS_POS::RIGHT)
1726  {
1727  return false;
1728  }
1729  if(w==0 || h==0)
1730  {
1731  return false;
1732  }
1733  if((x+w)>(mWidth/2) || (y+h)>mHeight)
1734  {
1735  return false;
1736  }
1737  if(w*h<=100)
1738  {
1739  return false;
1740  }
1741 
1742  int x_start_high = x / 256;
1743  int x_start_low = (x - x_start_high * 256);
1744  int y_start_high = y / 256;
1745  int y_start_low = (y - x_start_high * 256);
1746  int w_start_high = w / 256;
1747  int w_start_low = (w - x_start_high * 256);
1748  int h_start_high = h / 256;
1749  int h_start_low = (h - x_start_high * 256);
1750 
1751 
1752  uint32_t ulAddr = 0x801810C0;
1753  if (static_cast<int>(side)==1)
1754  ulAddr= 0x801818C0;
1755 
1756  int r = ll_write_system_register(ulAddr,static_cast<uint8_t>(x_start_high));ulAddr++;usleep(100);
1757  r += ll_write_system_register(ulAddr,static_cast<uint8_t>(x_start_low));ulAddr++;usleep(100);
1758  r += ll_write_system_register(ulAddr,static_cast<uint8_t>(y_start_high));ulAddr++;usleep(100);
1759  r += ll_write_system_register(ulAddr,static_cast<uint8_t>(y_start_low));ulAddr++;usleep(100);
1760  r += ll_write_system_register(ulAddr,static_cast<uint8_t>(w_start_high));ulAddr++;usleep(100);
1761  r += ll_write_system_register(ulAddr,static_cast<uint8_t>(w_start_low));ulAddr++;usleep(100);
1762  r += ll_write_system_register(ulAddr,static_cast<uint8_t>(h_start_high));ulAddr++;usleep(100);
1763  r += ll_write_system_register(ulAddr,static_cast<uint8_t>(h_start_low));ulAddr++;usleep(100);
1764 
1765  return (r==0);
1766 }
@ RIGHT
The right sensor.
@ LEFT
The left sensor.

References sl_oc::video::LEFT, and sl_oc::video::RIGHT.

Referenced by resetROIforAECAGC().

◆ setSaturation()

void sl_oc::video::VideoCapture::setSaturation ( int  saturation)

Set the Saturation value.

Parameters
saturationSaturation value in the range [0,8]
Examples
zed_oc_control_example.cpp.

Definition at line 1635 of file videocapture.cpp.

1636 {
1637  setCameraControlSettings(LINUX_CTRL_SATURATION, saturation);
1638 }

◆ setSharpness()

void sl_oc::video::VideoCapture::setSharpness ( int  sharpness)

Set the Sharpness value.

Parameters
sharpnessSharpness value in the range [0,8]
Examples
zed_oc_control_example.cpp.

Definition at line 1590 of file videocapture.cpp.

1591 {
1592  setCameraControlSettings(LINUX_CTRL_SHARPNESS, sharpness);
1593 }

◆ setWhiteBalance()

void sl_oc::video::VideoCapture::setWhiteBalance ( int  wb)

Set the White Balance value (disable auto White Balance if active)

Parameters
wbWhite Balance value in the range [2800,6500]
Examples
zed_oc_control_example.cpp.

Definition at line 1655 of file videocapture.cpp.

1656 {
1657  // Disable auto white balance if active
1658  if (getAutoWhiteBalance() != 0)
1659  setAutoWhiteBalance(false);
1660 
1661  setCameraControlSettings(LINUX_CTRL_AWB, wb);
1662 }
bool getAutoWhiteBalance()
Get the status of the automatic White Balance control.

References getAutoWhiteBalance(), and setAutoWhiteBalance().

◆ toggleLED()

int sl_oc::video::VideoCapture::toggleLED ( bool *  value)

Toggle the status of the camera led.

Parameters
valuereturned status: true for "ON", false for "OFF"
Returns
returns a negative value if an error occurred
Examples
zed_oc_control_example.cpp.

Definition at line 1432 of file videocapture.cpp.

1433 {
1434  bool curVal;
1435 
1436  int ret = getLEDstatus( &curVal );
1437 
1438  if(ret==0)
1439  {
1440  bool newVal = !curVal;
1441  ret = setLEDstatus( newVal );
1442 
1443  if( ret==0 && value!=nullptr )
1444  {
1445  *value = newVal;
1446  }
1447  }
1448 
1449  return ret;
1450 }
int getLEDstatus(bool *status)
Get the status of the camera led.

References getLEDstatus(), and setLEDstatus().


The documentation for this class was generated from the following files: