LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need Help with reconstructing UYVY Payload to BGRA 8 Packed

Solved!
Go to solution

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:

PixelFormat = BGRA8Packed

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:
    1. NI-IMAQdx internally converts UYVY → BGRA8 before display.
    2. The raw buffer still contains UYVY and the conversion happens later.
    3. I need to manually convert UYVY → BGRA in C++.

My Goal

Ultimately, I want to:

  1. First reconstruct the image exactly as NI MAX displays it (correct color).
  2. Then convert it to grayscale.

My Main Questions

  1. When NI MAX shows BGRA8 Packed, is the buffer actually BGRA (4 bytes per pixel)?
  2. If the payload is 4,608,000 bytes, does that definitively mean the buffer is UYVY?
  3. Does NI-IMAQdx automatically convert UYVY to BGRA for display only?
  4. 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!

0 Kudos
Message 1 of 2
(553 Views)
Solution
Accepted by topic author Falcon9

Found the solution to this - open example at 'C:\Users\Public\Documents\National Instruments\NI-IMAQdx\Examples\MSVC\Example Code.sln'

Here is my code snippet that took the image pointer and converted into grayscale u8 array

 

Falcon9_0-1780379972231.jpeg

Falcon9_1-1780379980753.jpeg

This thread can be marked as done for me, thanks for the interest.

 

 

0 Kudos
Message 2 of 2
(457 Views)