#include #include "FX3.h" #pragma comment(lib, "SUB2r-lib.lib") int main() { using namespace std; using namespace S2R; cout << "SUB2r-lib sample #1: basic functionality\n\n"; const auto numDevs{ImgSensor::deviceCount()}; cout << "Cypress devices attached to this system: " << static_cast(numDevs) << "\n\n"; ImgSensor dev(false); for(uint8_t i{}; i < numDevs; ++i){ auto GAIN_R{IImgSensorChip::Value::gain_r}; cout << "Opening device #" << static_cast(i) << "... "; if(dev.open(i)){ wcout << L"success.\nDevice name is: " << dev[FX3::PropWString::friendly_name].c_str() << "\n"; cout << "Sensor chipset: " << dev->chipsetName() << "\n"; cout << "FX3 version info: " << string(dev.fx3Version()) << "\n"; cout << "FPGA version info: " << string(dev.fpgaVersion()) << "\n"; { auto & ov{dev.sensor()}; // shortcut to the sensor chip cout << "current red channel gain is: " << dev->val(GAIN_R) << "\n"; auto gainR{ov[GAIN_R]}; gainR = gainR + 1; // increment the red gain by one and update the sensor with the new value cout << "after increasing red channel gain by 1 it is now: " << gainR << "\n"; ov[GAIN_R] -= 1; cout << "and back to the previous value of: " << gainR << "\n"; ov[GAIN_R] *= 1.0; } cout << "Closing the device... "; dev.close(); // or the destructor (or even the next call to open()) will take care of that if(dev){ cout << "something has gone terribly wrong - the device was supposed to be closed by now!\n"; }else{ cout << "the device is now closed and cannot be accessed without re-opening it\n"; cout << "For example the red channel gain is now: " << dev.sensor()[GAIN_R] << "\n"; cout << "But some info is still available, like the sensor chipset: " << dev->chipsetName() << "\n"; cout << "Or the information about the limit of red channel gain: " << dev->getLimit(GAIN_R) << "\n"; } }else{ cout << "failed.\n"; if(dev.isValid()){ wcout << L"But the FX3 part is still functional, so we can get info like the device's name: " << dev[FX3::PropWString::friendly_name].c_str() << "\n"; } } cout << "\n"; } return 0; }