Hi everyone,
I’m trying to understand how NI-IMAQdx handles pixel formatting, and I’m running into confusion when reproducing the behavior in C++.
Setup
- Camera format: UYVY (UVC Camera)
- Adapter: NI-IMAQdx
- Resolution: 1920 × 1200
- Pixel Format shown in NI MAX: BGRA8 Packed
- Reported payload size in NI MAX: 4,608,000 bytes
- NI MAX display: Shows correct 32-bit RGB color image
- When saving as
.tiff from NI MAX:
- Image size: 1920 × 1200 × 3
- File size: 6,912,000 bytes
Observations
- 1920 × 1200 × 2 bytes = 4,608,000 bytes → matches the payload size
(This suggests the camera is still delivering 16-bit UYVY data.)
- But NI MAX reports BGRA8 Packed, which implies:
- 4 bytes per pixel
- 1920 × 1200 × 4 = 9,216,000 bytes (which does not match payload)
Additionally:
- NI MAX displays a correct color image.
- When saved as TIFF, it becomes a 3-channel RGB image (no alpha), 6,912,000 bytes.
What I’m Doing in C++
I am initializing the NI-IMAQdx SDK in C++ and configuring the camera to use:
I am able to acquire the buffer, but I’m stuck on how to correctly reconstruct the image from the acquired data.
Specifically:
- If the payload is 4,608,000 bytes, that matches UYVY (16 bits per pixel).
- But if NI reports BGRA8Packed, that implies 32 bits per pixel.
- I’m unsure whether:
- NI-IMAQdx internally converts UYVY → BGRA8 before display.
- The raw buffer still contains UYVY and the conversion happens later.
- I need to manually convert UYVY → BGRA in C++.
My Goal
Ultimately, I want to:
- First reconstruct the image exactly as NI MAX displays it (correct color).
- Then convert it to grayscale.
My Main Questions
- When NI MAX shows BGRA8 Packed, is the buffer actually BGRA (4 bytes per pixel)?
- If the payload is 4,608,000 bytes, does that definitively mean the buffer is UYVY?
- Does NI-IMAQdx automatically convert UYVY to BGRA for display only?
- What is the correct way in C++ to reproduce the exact image NI MAX displays?
If anyone has experience with NI-IMAQdx pixel formats or handling UYVY/BGRA conversions in C++, I would really appreciate clarification.
Thanks in advance!