視覺人機(jī)器視覺培訓(xùn)-缺陷檢測(cè)項(xiàng)目-食品行業(yè)草雞蛋外觀檢測(cè)
相機(jī)參數(shù)類型可分為六類,除 command 參數(shù)外,每一類都有其對(duì)應(yīng)的設(shè)置與獲取函數(shù)接口。
表 1 參數(shù)類型及對(duì)應(yīng)函數(shù)接口介紹
*詳細(xì)函數(shù)接口可參考 SDK 手冊(cè):
?C:\Program Files (x86)\MVS\Development\Documentations
相機(jī)參數(shù)類型查詢
對(duì)于相機(jī)的每一個(gè)參數(shù),在 MVS 客戶端中都可以找到相應(yīng)的類型、節(jié)點(diǎn)名稱、取值范圍、步進(jìn)等信息,從圖 1 可以看出,相機(jī)高度節(jié)點(diǎn)名稱為”Height”,節(jié)點(diǎn)類型”Integer”,取值范圍 ”32-1080” , 步 進(jìn) 值 為 4 。 通 過 節(jié) 點(diǎn) 類 型 我 們 可 以 看 出 , 應(yīng) 該 使 用MV_CC_GetIntValueEx()獲取參數(shù)值,使用 MV_CC_SetIntValueEx()設(shè)置參數(shù)值。其他參數(shù)用法類似。
常用參數(shù)設(shè)置獲取示例
- Integer 型參數(shù)設(shè)置與獲取—以圖像寬度獲取設(shè)置為例
? MVS 查看參數(shù)類型及節(jié)點(diǎn)名稱
? 調(diào)用對(duì)應(yīng)函數(shù)接口
//獲取int型參數(shù)
MVCC_INTVALUE_EX struIntValue = { 0 };
nRet = MV_CC_GetIntValueEx(handle, "Width", &struIntValue);
if (MV_OK != nRet)
{
printf("Error: GetIntValue fail [%x]\n", nRet);
}
//打印當(dāng)前寬度的最大值、最小值、步進(jìn)
printf("Width:%I64d,Width_Max:%I64d,Width_min:%I64d,Width_Inc:%I64d\n", struIntValue.nCurValue,
struIntValue.nMax, struIntValue.nMin, struIntValue.nInc);
```csharp
//設(shè)置int型參數(shù)
/*
· value值必須是步進(jìn)值(Inc)的整數(shù)倍,否則會(huì)失敗
· 寬度、高度等參數(shù)設(shè)置時(shí),只有在MV_CC_OpenDevice之后,MV_CC_Startgrab接口調(diào)用前才能
設(shè)置,取流過程中,不能修改寬高
· 寬度、高度等參數(shù)設(shè)置時(shí),若有Offset X、Y偏移,應(yīng)當(dāng)先調(diào)用相關(guān)接口,將偏移量置0
```*/
int64_t nValue = 1000;
nRet = MV_CC_SetIntValueEx(handle, "Width", nValue);
if (MV_OK != nRet)
{
printf("Error: SetIntValue fail [%x]\n", nRet);
}
```csharp
- Command 型參數(shù)——以軟觸發(fā)設(shè)置為例
//設(shè)置Command型節(jié)點(diǎn)-發(fā)送軟觸發(fā)命令
//需要先打開【觸發(fā)模式】,觸發(fā)源選擇【軟觸發(fā)】后才可以設(shè)置軟觸發(fā)命令
nRet = MV_CC_SetCommandValue(handle, "TriggerSoftware");
if (MV_OK != nRet)
{
printf("Error: SetCommandValue fail [%x]\n", nRet);
}
- Float 型參數(shù)設(shè)置與獲取—以曝光獲取、設(shè)置為例
//曝光參數(shù)獲取
MVCC_FLOATVALUE struFloatValue = { 0 };
nRet = MV_CC_GetFloatValue(handle, "ExposureTime", &struFloatValue);
if (MV_OK != nRet)
{
printf("Error: GetFloatValue fail [%x]\n", nRet);
}
//設(shè)置float型參數(shù)-曝光值
//設(shè)置曝光時(shí),需要注意是否已經(jīng)開啟自動(dòng)曝光、曝光模式,它們都會(huì)影響曝光參數(shù)的設(shè)置范圍及是否可
以設(shè)置,可在MVS中進(jìn)行觀察
float fValue = 1000;
nRet = MV_CC_SetFloatValue(handle, "ExposureTime", fValue);
if (MV_OK != nRet)
{
printf("Error: SetFloatValue fail [%x]\n", nRet);
}
- Enumeration 型參數(shù)設(shè)置與獲取—以相機(jī)圖像格式獲取、設(shè)置為例
? MVS 查看參數(shù)類型及節(jié)點(diǎn)名稱
?? 調(diào)用對(duì)應(yīng)函數(shù)接口
//開啟水印信息需要按照步驟,才能一步步進(jìn)行操作
//只有在MV_CC_OpenDevice之后,MV_CC_Startgrab接口調(diào)用前才能設(shè)置水印信息
nRet = MV_CC_SetBoolValue(handle, "ChunkModeActive", 1);//開啟水印模式
if (MV_OK != nRet)
{
printf("Error: ChunkModeActive fail! nRet [0x%x]\n", nRet);
}
nRet = MV_CC_SetEnumValue(handle, "ChunkSelector", 6); //選擇水印信息:觸發(fā)計(jì)數(shù)
if (MV_OK != nRet)
{
printf("Error: ChunkSelector fail! nRet [0x%x]\n", nRet);;
}
nRet = MV_CC_SetBoolValue(handle, "ChunkEnable", 1);//使能水印
if (MV_OK != nRet)
{
printf("Error: ChunkEnable fail! nRet [0x%x]\n", nRet);
}
``5) String 參數(shù)獲取與設(shè)置—用戶名稱`
```csharp
//獲取string型參數(shù)
MVCC_STRINGVALUE struStringValue = { 0 };
nRet = MV_CC_GetStringValue(handle, "DeviceUserID", &struStringValue);
if (MV_OK != nRet)
{
printf("Error: GetStringValue fail [%x]\n", nRet);
}
printf("DeviceUserID:[%s]\n", struStringValue.chCurValue);
//設(shè)置string型參數(shù)-自定義用戶名稱
//只有在MV_CC_OpenDevice之后,MV_CC_Startgrab接口調(diào)用前才能設(shè)置用戶ID
nRet = MV_CC_SetStringValue(handle, "DeviceUserID", "HikrobotCamera");
if (MV_OK != nRet)
{
printf("Error: SetStringValue fail [%x]\n", nRet);
}
- Boolean 參數(shù)設(shè)置—觸發(fā)計(jì)數(shù)水印信息獲取
? MVS 查看參數(shù)類型及節(jié)點(diǎn)名稱
調(diào)用對(duì)應(yīng)函數(shù)接口
//開啟水印信息需要按照步驟,才能一步步進(jìn)行操作
//只有在MV_CC_OpenDevice之后,MV_CC_Startgrab接口調(diào)用前才能設(shè)置水印信息
nRet = MV_CC_SetBoolValue(handle, "ChunkModeActive", 1);//開啟水印模式
if (MV_OK != nRet)
{
printf("Error: ChunkModeActive fail! nRet [0x%x]\n", nRet);
}
nRet = MV_CC_SetEnumValue(handle, "ChunkSelector", 6); //選擇水印信息:觸發(fā)計(jì)數(shù)
if (MV_OK != nRet)
{
printf("Error: ChunkSelector fail! nRet [0x%x]\n", nRet);;
}
nRet = MV_CC_SetBoolValue(handle, "ChunkEnable", 1);//使能水印
if (MV_OK != nRet)
{
printf("Error: ChunkEnable fail! nRet [0x%x]\n", nRet);
}
文章來源:http://www.zghlxwxcb.cn/news/detail-467938.html
機(jī)器視覺康耐視智能相機(jī)Insight-臟污外觀缺陷檢測(cè)文章來源地址http://www.zghlxwxcb.cn/news/detail-467938.html
到了這里,關(guān)于機(jī)器視覺??倒I(yè)相機(jī)SDK參數(shù)設(shè)置獲取的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!