basler工業相機引數設定
// ParametrizeCamera_GenericParameterAccess.cpp
/*
Note: Before getting started, Basler recommends reading the Programmer's Guide topic
in the pylon C++ API documentation that gets installed with pylon.
If you are upgrading to a higher major version of pylon, Basler also
strongly recommends reading the Migration topic in the pylon C++ API documentation.
For camera configuration and for accessing other parameters, the pylon API
uses the technologies defined by the GenICam standard hosted by the
European Machine Vision Association (EMVA). The GenICam specification
(http://www.GenICam.org) defines a format for camera description files.
These files describe the configuration interface of GenICam compliant cameras.
The description files are written in XML (eXtensible Markup Language) and
describe camera registers, their interdependencies, and all other
information needed to access high-level features such as Gain,
Exposure Time, or Image Format by means of low-level register read and
write operations.
The elements of a camera description file are represented as software
objects called Nodes. For example, a node can represent a single camera
register, a camera parameter such as Gain, a set of available parameter
values, etc. Each node implements the GenApi::INode interface.
The nodes are linked together by different relationships as explained in the
GenICam standard document available at www.GenICam.org. The complete set of
nodes is stored in a data structure called Node Map.
At runtime, a Node Map is instantiated from an XML description.
This sample shows the 'generic' approach for configuring a camera
using the GenApi nodemaps represented by the GenApi::INodeMap interface.
The names and types of the parameter nodes can be found in the Basler pylon Programmer's Guide
and API Reference, in the camera User's Manual, in the camera's document about
Register Structure and Access Methodes (if applicable), and by using the pylon Viewer tool.
See also the ParametrizeCamera_NativeParameterAccess sample for the 'native'
approach for configuring a camera.
*/
// Include files to use the pylon API.
#include <pylon/PylonIncludes.h>
// Namespace for using pylon objects.
using namespace Pylon;
// Namespace for using GenApi objects.
using namespace GenApi;
// Namespace for using cout.
using namespace std;
// Adjust value to make it comply with range and increment passed.
//
// The parameter's minimum and maximum are always considered as valid values.
// If the increment is larger than one, the returned value will be: min + (n * inc).
// If the value doesn't meet these criteria, it will be rounded down to ensure compliance.
int64_t Adjust(int64_t val, int64_t minimum, int64_t maximum, int64_t inc)
{
// Check the input parameters.
if (inc <= 0)
{
// Negative increments are invalid.
throw LOGICAL_ERROR_EXCEPTION("Unexpected increment %d", inc);
}
if (minimum > maximum)
{
// Minimum must not be bigger than or equal to the maximum.
throw LOGICAL_ERROR_EXCEPTION("minimum bigger than maximum.");
}
// Check the lower bound.
if (val < minimum)
{
return minimum;
}
// Check the upper bound.
if (val > maximum)
{
return maximum;
}
// Check the increment.
if (inc == 1)
{
// Special case: all values are valid.
return val;
}
else
{
// The value must be min + (n * inc).
// Due to the integer division, the value will be rounded down.
return minimum + ( ((val - minimum) / inc) * inc );
}
}
int main(int argc, char* argv[])
{
// The exit code of the sample application.
int exitCode = 0;
// Before using any pylon methods, the pylon runtime must be initialized.
PylonInitialize();
try
{
// Create an instant camera object with the camera found first.
CInstantCamera camera( CTlFactory::GetInstance().CreateFirstDevice());
INodeMap& nodemap = camera.GetNodeMap();
// Open the camera for accessing the parameters.
camera.Open();
// Get camera device information.
cout << "Camera Device Information" << endl
<< "=========================" << endl;
cout << "Vendor : "
<< CStringPtr( nodemap.GetNode( "DeviceVendorName") )->GetValue() << endl;
cout << "Model : "
<< CStringPtr( nodemap.GetNode( "DeviceModelName") )->GetValue() << endl;
cout << "Firmware version : "
<< CStringPtr( nodemap.GetNode( "DeviceFirmwareVersion") )->GetValue() << endl << endl;
// Camera settings.
cout << "Camera Device Settings" << endl
<< "======================" << endl;
// Set the AOI:
// Get the integer nodes describing the AOI.
CIntegerPtr offsetX( nodemap.GetNode( "OffsetX"));
CIntegerPtr offsetY( nodemap.GetNode( "OffsetY"));
CIntegerPtr width( nodemap.GetNode( "Width"));
CIntegerPtr height( nodemap.GetNode( "Height"));
// On some cameras the offsets are read-only,
// so we check whether we can write a value. Otherwise, we would get an exception.
// GenApi has some convenience predicates to check this easily.
if ( IsWritable( offsetX))
{
offsetX->SetValue( offsetX->GetMin());
}
if ( IsWritable( offsetY))
{
offsetY->SetValue( offsetY->GetMin());
}
// Some properties have restrictions. Use GetInc/GetMin/GetMax to make sure you set a valid value.
int64_t newWidth = 202;
newWidth = Adjust(newWidth, width->GetMin(), width->GetMax(), width->GetInc());
int64_t newHeight = 101;
newHeight = Adjust(newHeight, height->GetMin(), height->GetMax(), height->GetInc());
width->SetValue(newWidth);
height->SetValue(newHeight);
cout << "OffsetX : " << offsetX->GetValue() << endl;
cout << "OffsetY : " << offsetY->GetValue() << endl;
cout << "Width : " << width->GetValue() << endl;
cout << "Height : " << height->GetValue() << endl;
// Access the PixelFormat enumeration type node.
CEnumerationPtr pixelFormat( nodemap.GetNode( "PixelFormat"));
// Remember the current pixel format.
String_t oldPixelFormat = pixelFormat->ToString();
cout << "Old PixelFormat : " << oldPixelFormat << endl;
// Set the pixel format to Mono8 if available.
if ( IsAvailable( pixelFormat->GetEntryByName( "Mono8")))
{
pixelFormat->FromString( "Mono8");
cout << "New PixelFormat : " << pixelFormat->ToString() << endl;
}
// Set the new gain to 50% -> Min + ((Max-Min) / 2).
//
// Note: Some newer camera models may have auto functions enabled.
// To be able to set the gain value to a specific value
// the Gain Auto function must be disabled first.
// Access the enumeration type node GainAuto.
CEnumerationPtr gainAuto( nodemap.GetNode( "GainAuto"));
if ( IsWritable( gainAuto))
{
gainAuto->FromString("Off");
}
// Check to see which Standard Feature Naming Convention (SFNC) is used by the camera device.
if ( camera.GetSfncVersion() >= Sfnc_2_0_0)
{
// Access the Gain float type node. This node is available for USB camera devices.
// USB camera devices are compliant to SFNC version 2.0.
CFloatPtr gain( nodemap.GetNode( "Gain"));
double newGain = gain->GetMin() + ((gain->GetMax() - gain->GetMin()) / 2);
gain->SetValue(newGain);
cout << "Gain (50%) : " << gain->GetValue() << " (Min: " << gain->GetMin() << "; Max: " << gain->GetMax() << ")" << endl;
}
else
{
// Access the GainRaw integer type node. This node is available for IIDC 1394 and GigE camera devices.
CIntegerPtr gainRaw( nodemap.GetNode( "GainRaw"));
int64_t newGainRaw = gainRaw->GetMin() + ((gainRaw->GetMax() - gainRaw->GetMin()) / 2);
// Make sure the calculated value is valid.
newGainRaw = Adjust(newGainRaw, gainRaw->GetMin(), gainRaw->GetMax(), gainRaw->GetInc());
gainRaw->SetValue(newGainRaw);
cout << "Gain (50%) : " << gainRaw->GetValue() << " (Min: " << gainRaw->GetMin() << "; Max: " << gainRaw->GetMax() << "; Inc: " << gainRaw->GetInc() << ")" << endl;
}
// Restore the old pixel format.
pixelFormat->FromString(oldPixelFormat);
// Close the camera.
camera.Close();
}
catch (const GenericException &e)
{
// Error handling.
cerr << "An exception occurred." << endl
<< e.GetDescription() << endl;
exitCode = 1;
}
// Comment the following two lines to disable waiting on exit.
cerr << endl << "Press Enter to exit." << endl;
while( cin.get() != '\n');
// Releases all pylon resources.
PylonTerminate();
return exitCode;
}
相關文章
- oracle 安裝相關引數設定Oracle
- 全景拍攝“快門時間”相機引數設定策略
- Code::Blocks 編譯引數的相關設定BloC編譯
- 智慧相機與工業相機的區別
- 工業智慧相機在汽車車間引導機器人的應用機器人
- 幾個和MySQL InnoDB相關的引數設定說明MySql
- [轉帖]Redis相關的核心引數解釋與設定Redis
- 工業相機丟包的問題
- vsftpd設定引數FTP
- RAC 特定引數設定
- 兩個引數設定
- sql*plus會話環境相關的引數設定檔案SQL會話
- 朗銳智科工業智慧相機在機器人視覺引導中的應機器人視覺
- Metasploit設定LHOST引數技巧
- Metasploit設定VERBOSE引數技巧
- pandas引數設定小技巧
- Metasploit設定HttpTrace引數技巧HTTP
- tomcat vm 引數設定Tomcat
- JVM常見引數設定JVM
- JVM引數設定大氣JVM
- SAP系統引數設定
- SAP 系統引數設定
- ORACLE JOB INTERVAL引數設定Oracle
- chrome啟動引數設定Chrome
- 設定NLS_LANG引數
- MySQL的幾個和innodb相關的主要引數設定總結MySql
- Swift語言中為外部引數設定預設值可變引數常量引數變數引數輸入輸出引數Swift變數
- Oracle CSS的引數設定 心跳時間設定OracleCSS
- 工業機器視覺系統相機如何選型?視覺
- Oracle8i,9i Standby引數設定及相關說明Oracle
- 【SQL 效能優化】引數設定SQL優化
- SAP 系統引數設定(zt)
- DBReplicator設定setpath.bat引數BAT
- javascript為函式設定預設引數JavaScript函式
- AIX7.1 VMO 引數預設設定AI
- 工業智慧相機鏡頭選型要點分析
- 高速工業相機在流水線中的應用
- USB3.0介面的工業相機應用