跳至內容
測試伺服器
開發伺服器

Pixel Format (dart E)#

透過 Pixel Format 相機功能,您可以選擇相機所傳輸的影像資料格式。

根據您的相機型號以及相機是彩色相機還是單色相機,會有不同的 Pixel Format。

資訊

有關 Pixel Format 的詳細資訊,請參閱 GenICam Pixel Format Naming Convention 2.1。

使用功能#

選擇 Pixel Format#

若要選擇 Pixel Format:

  1. 請確保相機處於閒置狀態,也就是未擷取影像。
  2. 將相機中的 PixelFormat 將參數設為下列其中一個值(若適用):

決定 Pixel Format#

要確定相機目前使用的像素格式,請讀取 PixelFormat 參數中選擇性地指定 HTML 記錄檔 (*.html) 的路徑與檔名。

可用的 Pixel Format#

資訊

有關枚舉值的清單,請參閱隨 Baslerpylon Software Suite 附帶提供的《程式設計師指南》及《參考文件》。

Mono 格式#

如果單色相機採用其中一種單色像素格式,則每像素會輸出 8、10 或 12 位元的資料。

如果彩色相機使用其中一種 Mono Pixel Format,每個像素的值會先轉換為 YCbCr 色彩模型。此模型的 Y 分量代表亮度值,相當於從單色感光元件中的像素所衍生出的值。因此,本質上當彩色相機設定為例如 Mono 8 時,它會輸出 8 位元的單色影像。

YCbCr 格式#

彩色相機也可以根據 YCbCr(或 YUV)格式的像素資料來輸出彩色影像。

如果彩色相機使用此格式,擷取影像中的每個像素值在離開感光元件並通過相機時,都會經過轉換過程。此過程會為每個像素值產生 Y、Cb 和 Cr 色彩資訊。

RGB 與 BGR 格式#

當彩色相機使用 RGB 8 或 BGR 8 Pixel Format 時,相機會針對擷取畫面中的每個像素,輸出 8 位元的紅色資料、8 位元的綠色資料以及 8 位元的藍色資料。

Pixel Format 的差異在於色彩資料的輸出順序(紅、綠、藍或藍、綠、紅)。

最大像素位元深度#

最大像素位元深度是由您相機上可用的 pixel format 中位元深度最高的 pixel format 所定義。

範例:如果相機可用的 pixel format 為 Mono 8 和 Mono 12,則相機的最大像素位元深度為 12 bit。

詳細資料#

相機型號 SoC / 電路板 可用的 Pixel Format
daA2500-60mc i.MX8M Plus YUV422_8
daA2500-60mci NVIDIAJetson YUV422_8_UYVY
daA2500-60mci i.MX8M Quad YUV422_8_UYVY
daA2500-60mci i.MX8M Plus YUV422_8
daA2500-60mci i.MX8M Mini YUV422_8_UYVY、YCbCr420_8_YY_CbCr_半平面
daA3840-30mc i.MX8M Plus YUV422_8
daA4200-30mci NVIDIAJetson YUV422_8_UYVY
daA4200-30mci i.MX8M Quad YUV422_8_UYVY
daA4200-30mci i.MX8M Plus YUV422_8
daA4200-30mci i.MX8M Mini YUV422_8_UYVY、YCbCr420_8_YY_CbCr_半平面

範例程式碼#

// Set the pixel format to Mono 8
camera.PixelFormat.SetValue(PixelFormat_Mono8);
INodeMap& nodemap = camera.GetNodeMap();
// Set the pixel format to Mono 8
CEnumParameter(nodemap, "PixelFormat").SetValue("Mono8");
// Set the pixel format to Mono 8
camera.Parameters[PLCamera.PixelFormat].SetValue(PLCamera.PixelFormat.Mono8);
/* Macro to check for errors */
#define CHECK(errc) if (GENAPI_E_OK != errc) printErrorAndExit(errc)
GENAPIC_RESULT errRes = GENAPI_E_OK;  /* Return value of pylon methods */
/* Set the pixel format to Mono 8 */
errRes = PylonDeviceFeatureFromString(hdev, "PixelFormat", "Mono8");
CHECK(errRes);
# Set the pixel format to Mono 8
camera.PixelFormat.Value = "Mono8"
/* Macro to check for errors */
#define CHECK(errc) if (GENAPI_E_OK != errc) printErrorAndExit(errc)
GENAPIC_RESULT errRes = GENAPI_E_OK;  /* Return value of pylon methods */
/* Set the pixel format to Mono 8 */
errRes = PylonDeviceFeatureFromString(hdev, "PixelFormat", "Mono8");
CHECK(errRes);

您也可以使用 pylon Viewer 輕鬆設定參數。