6

There is a nice Visual Studio extension Image Watch.

It can take an arbitrary address in RAM and show its contents as an image with @mem operator.

@mem(address, type, channels, width, height, stride): interpret raw memory as pixels, starting at address (UINT64), with channel type (see Pixel Formats), number of channels (UINT32), width (UINT32), height (UINT32), and stride (UINT32). Example: @mem(myimg.data, UINT8, 1, 320, 240, 320)

According to the help page, it can display several complex pixel formats, BGR, NV12 and YV12 are among them.

Optionally, a format string may be associated with the pixel format. It specifies the semantics of each channel for rendering:

  • RG, UV

  • RGB, BGR, YUV

  • RGBA, BGRA

...

A number of special YUV formats are supported as well. In this case, the format string also defines the data layout.

  • NV12 (two planes: one Y plane, one packed UV plane, subsampled by 2 in both dimensions)

  • YV12 (three planes: one Y plane, one packed U and V plane each, both subsampled by 2 in both dimensions)

However, it is not clear for me, how to make Image Watch to display images in NV12 and YV12 formats with @mem operator.

Help page does not contain too much information.

I've managed to display gray single channel images, specifying UINT8 as a channel type. I can also correctly display BGR image with channel type = UINT8 and 3 channels: @mem(pBGR, UINT8, 3, 640, 480, 640*3). This was described in documentation, but was not obvious.

I've tried various combinations of numbers of channels and format strings with or without quotes: @mem(ptr, NV12, 3, 640, 480, 640*3), @mem(ptr, "NV12", 1, 640, 480, 640*3), @mem(ptr, UINT8NV12, 3, 640, 480, 640*3) @mem(ptr, NV12UINT8, 1, 640, 480, 640*3), etc - no luck. I see only gray rectangle with the word [invalid].

Same thing with YV12.

wl2776
  • 4,099
  • 4
  • 35
  • 77
  • Aren't UV interleaved in these formats? – silver_rocket Mar 27 '18 at 16:23
  • Yes, they are, at least in NV12. I've concluded from ImageWatch docs that it is clever enough to correctly handle it. I'm not sure, since its sources are closed. – wl2776 Mar 27 '18 at 16:27
  • i guess a normal solution will be to write simple wrapper structure with required fields named open-cv like style. Than place natvis file in image watch folder (tutorial describes it) make sure .planes .format and others set correct and it should work fine – silver_rocket Mar 27 '18 at 18:35

0 Answers0