//============================================================================= // Copyright © 2019 FLIR Integrated Imaging Solutions, Inc. All Rights Reserved. // // This software is the confidential and proprietary information of FLIR // Integrated Imaging Solutions, Inc. ("Confidential Information"). You // shall not disclose such Confidential Information and shall use it only in // accordance with the terms of the license agreement you entered into // with FLIR Integrated Imaging Solutions, Inc. (FLIR). // // FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE // SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR // PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES // SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING // THIS SOFTWARE OR ITS DERIVATIVES. //============================================================================= /** * @example SaveToMemoryChannel.cpp * * @brief SaveToMemoryChannel.cpp shows how to save custom settings to user set. By default, * it modifies the exposure time to 2 milliseconds, then saves this change to Memory Channel 1. * It can also be configured to reset the camera to factory default settings. */ #include "stdafx.h" #include "FlyCapture2.h" #include #include using namespace FlyCapture2; using namespace std; // Uncomment to have the camera restored to factory default settings (please note this overrides any settings changes made) // //#define RESTORE_FACTORY_DEFAULT void PrintBuildInfo() { FC2Version fc2Version; Utilities::GetLibraryVersion(&fc2Version); ostringstream version; version << "FlyCapture2 library version: " << fc2Version.major << "." << fc2Version.minor << "." << fc2Version.type << "." << fc2Version.build; cout << version.str() << endl; ostringstream timeStamp; timeStamp << "Application build date: " << __DATE__ << " " << __TIME__; cout << timeStamp.str() << endl << endl; } void PrintCameraInfo(CameraInfo* pCamInfo) { cout << endl; cout << "*** CAMERA INFORMATION ***" << endl; cout << "Serial number - " << pCamInfo->serialNumber << endl; cout << "Camera model - " << pCamInfo->modelName << endl; cout << "Camera vendor - " << pCamInfo->vendorName << endl; cout << "Sensor - " << pCamInfo->sensorInfo << endl; cout << "Resolution - " << pCamInfo->sensorResolution << endl; cout << "Firmware version - " << pCamInfo->firmwareVersion << endl; cout << "Firmware build time - " << pCamInfo->firmwareBuildTime << endl << endl; } void PrintError(Error error) { error.PrintErrorTrace(); } // This function sets the shutter time to 2 milliseconds and saves that to memory channel 1 int SaveCustomSettings(PGRGuid guid) { Error error; // Connect to a camera Camera cam; error = cam.Connect(&guid); if (error != PGRERROR_OK) { PrintError(error); return -1; } // Get the camera information CameraInfo camInfo; error = cam.GetCameraInfo(&camInfo); if (error != PGRERROR_OK) { PrintError(error); return -1; } PrintCameraInfo(&camInfo); // Turn auto shutter off then set shutter to 2 milliseconds Property property; property.type = SHUTTER; cam.GetProperty(&property); property.autoManualMode = false; property.absControl = true; property.absValue = 2; cam.SetProperty(&property); cout << "Auto shutter turned off, shutter set to 2 milliseconds" << endl; // Set memory channel to channel 1 cam.SaveToMemoryChannel(1); cout << "Saved Custom Settings to memory channel 1 " << endl; #ifdef RESTORE_FACTORY_DEFAULT // Restore to default and set memory channel to factory default cam.RestoreFromMemoryChannel(0); cout << "Camera set to default settings" << endl; cam.SaveToMemoryChannel(0); cout << "Memory channel set to factory default" << endl; #endif // Disconnect the camera error = cam.Disconnect(); if (error != PGRERROR_OK) { PrintError(error); return -1; } return 0; } int main(int /*argc*/, char** /*argv*/) { PrintBuildInfo(); Error error; BusManager busMgr; unsigned int numCameras; error = busMgr.GetNumOfCameras(&numCameras); if (error != PGRERROR_OK) { PrintError(error); return -1; } cout << "Number of cameras detected: " << numCameras << endl; for (unsigned int i = 0; i < numCameras; i++) { PGRGuid guid; error = busMgr.GetCameraFromIndex(i, &guid); if (error != PGRERROR_OK) { PrintError(error); return -1; } SaveCustomSettings(guid); } cout << "Press Enter to exit..." << endl; cin.ignore(); return 0; }