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

Pixel Format (dart E)#

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

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

資訊

關於 pixel format 的詳細資訊,請參見 GenICam Pixel Format Naming Convention 2.1。

使用此功能#

選擇 Pixel Format#

若要選擇 pixel format:

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

決定 Pixel Format#

若要決定相機目前使用的 pixel format,請讀取 PixelFormat 參數的值。

可用的 Pixel Format#

資訊

如需列舉值的清單,請參見隨 Basler pylon Software Suite 一起提供的 Programmer's Guide and Reference Documentation。

單色格式#

如果單色相機使用其中一種單色 pixel format,它會每個像素輸出 8、10 或 12 位元的資料。

如果彩色相機使用其中一種單色 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 / Board 可用的 Pixel Format
daA2500-60mc i.MX8M Plus YUV422_8
daA2500-60mci NVIDIA Jetson 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_Semiplanar
daA3840-30mc i.MX8M Plus YUV422_8
daA4200-30mci NVIDIA Jetson 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_Semiplanar

範例程式碼#

// 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 輕鬆設定參數。