跳转到内容

Pixel Format (dart E)#

相机的 Pixel Format 功能允许您选择相机传输的图像数据的格式。

像素格式会有所不同,具体取决于您的相机型号及其是彩色相机还是单色相机。

信息

有关像素格式的详细信息,请参见GenICam 像素格式命名约定 2.1

该功能的使用#

选择一种像素格式#

选择像素格式:

  1. 确保相机空闲,即未在捕获图像。
  2. 设置 PixelFormat 参数为以下值(如果可用):

确定像素格式#

To determine the pixel format currently used by the camera, read the value of the PixelFormat parameter.

可用像素格式#

信息

有关枚举值的列表,请参阅 Basler pylon Camera Software Suite 随附的程序员指南和参考文档

单色格式#

如果单色相机使用某种 Mono 像素格式,则每个像素输出 8、10 或 12 位数据。

如果彩色相机使用某种单色像素格式,则每个像素的值首先会转换为 YCbCr 颜色模型。此模型的 Y 分量表示亮度值,并且等效于从单色传感器中的一个像素得出的值。因此,从本质上讲,将彩色相机设置为 Mono 8 格式(例如)时,它将输出 8 位单色图像。

YCbCr 格式#

彩色相机还可以基于 YCbCr(或 YUV)格式的像素数据输出彩色图像。

如果彩色相机使用此格式,则采集到的图像中的每个像素值在离开传感器并通过相机时都会经历一个转换过程。此过程为每个像素值生成 Y、Cb 和 Cr 颜色信息。

RGB 和 BGR 格式#

当彩色相机使用 RGB 8 或 BGR 8 像素格式时,相机将为所采集帧中的每个像素输出 8 位红色数据、8 位绿色数据和 8 位蓝色数据。

像素格式因颜色数据的输出顺序(红、绿、蓝或蓝、绿、红)而异。

最大像素位深度#

最大像素位深度由相机上可用像素格式中具有最高位深度的像素格式定义。

示例:如果相机可用的像素格式为 Mono 8 和 Mono 12,则相机的最大像素位深度为 12 位。

详情#

相机型号 SoC/板 可用像素格式
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 轻松设置参数。