# MetaData from a Dalsa Nano

**URL:** <https://forum.commonvisionblox.com/t/metadata-from-a-dalsa-nano/810>\
**Category:** .Net API\
**Created:** [June 11, 2019, 1:48pm UTC](https://forum.commonvisionblox.com/t/metadata-from-a-dalsa-nano/810 "2019-06-11T13:48:26Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ben](https://avatars.discourse-cdn.com/v4/letter/b/df788c/32.png) [@Ben](https://forum.commonvisionblox.com/u/Ben)\
**Post date:** [June 11, 2019, 1:48pm UTC](https://forum.commonvisionblox.com/t/metadata-from-a-dalsa-nano/810/1 "2019-06-11T13:48:26Z")

</div>

There are metadata controls in the properties of a Dalsa Nano-M2590, but it’s not clear to me if they are sent _in_ the image, _with_ the image in the RingBuffer, or if one has to query the camera separately. Is this something that is exposed via :cvb:?

(I’m looking into this because we’ve had difficulty in the past correlating images to triggers (positions), especially as we’re doing HDR by cycling expositions, so it’s important to group the right images together).

---

<div class="post-metadata">

**Author:** ![Theo](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/theo/32/482_2.png) [@Theo](https://forum.commonvisionblox.com/u/Theo)\
**Post date:** [June 12, 2019, 2:34pm UTC](https://forum.commonvisionblox.com/t/metadata-from-a-dalsa-nano/810/2 "2019-06-12T14:34:28Z")

</div>

The Metadata of the Nano GigE Series are included into the image as “GenICam Chunk Data”. Those data do not overwrite the image data (as we discussed for the Linea camera). However they are send with each image and you are able to access them via software.

Currently I do not know if we have a sample code for the Nano but @parsd already answered on a similar question regarding a AT C5 camera:  
[https://forum.commonvisionblox.com/t/using-chunk-mode-data-with-cvb-net/333](https://forum.commonvisionblox.com/t/using-chunk-mode-data-with-cvb-net/333)

@M_M, do you have some sample code to receive ChunkData from the Nano? 😉

---

<div class="post-metadata">

**Author:** ![Ben](https://avatars.discourse-cdn.com/v4/letter/b/df788c/32.png) [@Ben](https://forum.commonvisionblox.com/u/Ben)\
**Post date:** [June 13, 2019, 5:09am UTC](https://forum.commonvisionblox.com/t/metadata-from-a-dalsa-nano/810/3 "2019-06-13T05:09:14Z")

</div>

Thanks; I tried this:

```
(device.NodeMaps[NodeMapNames.Device]["Std::ChunkDataControl"] as CategoryNode)

```

But strangely, all of the sub-nodes are “\<n/a\>”, even though if you use GenICam Browser you can see the values. So I’m pretty close, but still missing something, I think. (I did set `nodeMap.Set("Std::ChunkModeActive", true);` first)

---

<div class="post-metadata">

**Author:** ![Ben](https://avatars.discourse-cdn.com/v4/letter/b/df788c/32.png) [@Ben](https://forum.commonvisionblox.com/u/Ben)\
**Post date:** [June 14, 2019, 10:52am UTC](https://forum.commonvisionblox.com/t/metadata-from-a-dalsa-nano/810/4 "2019-06-14T10:52:17Z")

</div>

- Could someone point me towards documents which could at least give me the memory layout, offsets etc.?
- Do I have to use DeviceImage, or can I use StreamImage?
- Do I really have to set PixelFormat to Raw to get the metadata?

---

<div class="post-metadata">

**Author:** ![CvK](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/cvk/32/112_2.png) [@CvK](https://forum.commonvisionblox.com/u/CvK)\
**Post date:** [June 14, 2019, 12:55pm UTC](https://forum.commonvisionblox.com/t/metadata-from-a-dalsa-nano/810/5 "2019-06-14T12:55:34Z")

</div>

For the AT cameras at least, converting the pixel format (so effectively using anything but raw) made the chunk data go to 0. I’d be verry suprised if that only holds true for AT cameras.

Converting the pixeltypes seems to effect the chunk data appended to them as well.

---

<div class="post-metadata">

**Author:** ![Ben](https://avatars.discourse-cdn.com/v4/letter/b/df788c/32.png) [@Ben](https://forum.commonvisionblox.com/u/Ben)\
**Post date:** [June 14, 2019, 1:04pm UTC](https://forum.commonvisionblox.com/t/metadata-from-a-dalsa-nano/810/6 "2019-06-14T13:04:56Z")

</div>

Well it’s definitely not all zero, but I’m having difficulty working out what it _is_! I’ve managed to parse out the Tag, and it says that the length is 136 bytes, which divided by 17 (the number - I think - of properties I see in GenICam Browser), would give exactly 8 bytes each. But currently if I map a struct of 17 long/doubles onto that, I get weird numbers (again, I’m guessing the order too).

Now I’m going to try doing several images in a row - where only the timestamp, cycling preset and exposure time should change - and see which bytes move. Didn’t think I’d have to get this down and dirty ☹

---

<div class="post-metadata">

**Author:** ![Ben](https://avatars.discourse-cdn.com/v4/letter/b/df788c/32.png) [@Ben](https://forum.commonvisionblox.com/u/Ben)\
**Post date:** [June 14, 2019, 1:32pm UTC](https://forum.commonvisionblox.com/t/metadata-from-a-dalsa-nano/810/7 "2019-06-14T13:32:41Z")

</div>

OK, a few pointers for any other poor mortal who bites of more than they can chew.

- Do I have to use DeviceImage, or can I use StreamImage?  
This question related to the code [here](https://forum.commonvisionblox.com/t/using-chunk-mode-data-with-cvb-net/333) which uses DeviceImage. Given that the only ‘added value’ of DeviceImage is that it contains a reference to Device, I refactored the three classes from github, which ends up meaning that the signature of GetChunk is `GetChunk(Image image, Device device)`.

- Do I really have to set PixelFormat to Raw to get the metadata?  
It doesn’t look like it.

- Could someone point me towards documents which could at least give me the memory layout, offsets etc.?  
I didn’t find any documents, but I’ve managed to get this far (as it’s all I need):

For the rest

```
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct NanoInfoChunk
{
    public const uint ID = 0xCD000001;

    public long Dummy;
    public long ChunkExposureTime;
    public long ChunkCyclingPresetCurrentActiveSet;
}

```

If you want to work on the rest, you can add the three middle lines to DeferenceNanoInfoOn (still inspired from the code posted on the other topic):

```
private static unsafe NanoInfoChunk DereferenceNanoInfoOn(Image image, GevChunk chunk)
{
    var chunkPtr = new IntPtr(image.GetBufferBasePtr().ToInt64() + chunk.Offset);
    byte[] bytes = new byte[chunk.Length];
    Marshal.Copy(chunkPtr, bytes, 0, (int)chunk.Length);
    System.Diagnostics.Debug.WriteLine(BitConverter.ToString(bytes));
    return *(NanoInfoChunk*)chunkPtr;
}
```

---

<div class="post-metadata">

**Author:** ![parsd](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/parsd/32/7_2.png) [@parsd](https://forum.commonvisionblox.com/u/parsd)\
**Post date:** [June 15, 2019, 6:09am UTC](https://forum.commonvisionblox.com/t/metadata-from-a-dalsa-nano/810/8 "2019-06-15T06:09:46Z")

</div>

Hi @Ben,

just a few pointers as I am not in the office:

1. The AT cameras don’t use GenApi chunk and thus you need to parse it manually
2. :cvb: supports GenApi chunks even when converting pixel formats
3. If GenApi chunk nodes are available use these instead of parsing the raw data

If, as with the Nano, you want to use GenApi chunks you need to activate them manually. Sometimes even per value. You first need to set the selector (the parent node in the grid) and then enable it.

Then after calling `.Wait` the data is updated.

Regarding the last question: the `DeviceImage` is always the last acquired image. Thus this one is nice to have for display purposes, but not for processing as it is also updated with the `.Wait` call.

---

<div class="post-metadata">

**Author:** ![Julian](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@Julian](https://forum.commonvisionblox.com/u/Julian)\
**Post date:** [February 4, 2020, 3:46pm UTC](https://forum.commonvisionblox.com/t/metadata-from-a-dalsa-nano/810/9 "2020-02-04T15:46:47Z")

</div>

Hi @parsd,

i am struggling with the read out of the chunk data. I do select the values before trying to read the specific node, e.g. ExposureTime. In the GinICam Browser the values are shown, even though the fields are gray. With the API the nodes are not readable. Did i miss something or do i have to parse the payload manually?

Here is my code to read the ExposureTime:

```auto
    auto node = deviceNodeMap - > Node < Cvb::ValueNode > (CVB_LIT("ChunkSelector"));
    ROS_INFO_STREAM("ChunkSelector " << node - > ToString());
    node - > FromString("ExposureTime");

    node = deviceNodeMap - > Node < Cvb::ValueNode > (CVB_LIT("ChunkExposureTime"));
    if (node - > IsReadable()) {
      ROS_INFO_STREAM("ChunkExposureTime: " << node - > ToString());
    }

```

---

<div class="post-metadata">

**Author:** ![parsd](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/parsd/32/7_2.png) [@parsd](https://forum.commonvisionblox.com/u/parsd)\
**Post date:** [February 5, 2020, 9:56am UTC](https://forum.commonvisionblox.com/t/metadata-from-a-dalsa-nano/810/10 "2020-02-05T09:56:49Z")

</div>

Did you activate chunk parsing for the _GenICam.vin_? This can be done either in the camera section of the _GenICam.ini_ in _%CVBDATA%\Drivers_:

```ini
AttachChunk = 1

```

or via discovery:

```auto
var foundDevices = DeviceFactory.Discover();
var firstDeviceInfo = foundDevices[0]; // we simply assume we found at least one camera
firstDeviceInfo.SetParameter("AttachChunk", "1")

using (var device = DeviceFactory.Open(firstDeviceInfo))
{
  // ...
}

```

This is off by default as parsing this costs performance.

---

<div class="post-metadata">

**Author:** ![Julian](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@Julian](https://forum.commonvisionblox.com/u/Julian)\
**Post date:** [February 5, 2020, 10:27am UTC](https://forum.commonvisionblox.com/t/metadata-from-a-dalsa-nano/810/11 "2020-02-05T10:27:42Z")

</div>

Yes i activated it, but i still have the same problem. Fields are not readable/writeable with the API.  
Is there anything else i could have missed?

---

<div class="post-metadata">

**Author:** ![parsd](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/parsd/32/7_2.png) [@parsd](https://forum.commonvisionblox.com/u/parsd)\
**Post date:** [February 5, 2020, 10:48am UTC](https://forum.commonvisionblox.com/t/metadata-from-a-dalsa-nano/810/12 "2020-02-05T10:48:36Z")

</div>

Chunk-Nodes are only readable (this is why they are gray in the GenApi Grid). When you used them in the _GenICam Browser_: did you enable the features you wanted? This also needs to be done in your application as this is not persisted.

Both the _GenICam Browser_ and your app via our API use the same underlying technology. It is not standardized what happens if you disconnect from a device. Some settings might still be active in your camera, others not. So it is always the safe way to set-up your camera as you want it to be in your application.

---

<div class="post-metadata">

**Author:** ![Julian](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@Julian](https://forum.commonvisionblox.com/u/Julian)\
**Post date:** [February 5, 2020, 11:12am UTC](https://forum.commonvisionblox.com/t/metadata-from-a-dalsa-nano/810/13 "2020-02-05T11:12:09Z")

</div>

With enabling you mean selecting the meta data field with the ChunkSelector and enabling it with ChunkEnable before reading the field i assume? I did, but this triggers an error that says the ChunkEnable node is not writeable. This field is also gray in the GenICam Browser for each chunk field i select.

I do get the raw meta data block for each frame, so it is just about interpreting. I could mess around with it to extract the values but i´d like to do it based on the Nodemaps.

---

<div class="post-metadata">

**Author:** ![parsd](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/parsd/32/7_2.png) [@parsd](https://forum.commonvisionblox.com/u/parsd)\
**Post date:** [February 5, 2020, 12:09pm UTC](https://forum.commonvisionblox.com/t/metadata-from-a-dalsa-nano/810/14 "2020-02-05T12:09:51Z")

</div>

If the _ChunkEnable_ is not writeable it sounds like you started the acquisition locking all frame buffer related operations (buffer size would change). Can you check whether enabling this before `Stream.Start` helps?

---

<div class="post-metadata">

**Author:** ![Julian](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@Julian](https://forum.commonvisionblox.com/u/Julian)\
**Post date:** [February 5, 2020, 12:23pm UTC](https://forum.commonvisionblox.com/t/metadata-from-a-dalsa-nano/810/15 "2020-02-05T12:23:36Z")

</div>

Unfortunately that does not help either. The ChunkEnable field is even not writeable/settable in the GenICam Browser before and during capturing.

---

<div class="post-metadata">

**Author:** ![parsd](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/parsd/32/7_2.png) [@parsd](https://forum.commonvisionblox.com/u/parsd)\
**Post date:** [February 5, 2020, 12:50pm UTC](https://forum.commonvisionblox.com/t/metadata-from-a-dalsa-nano/810/16 "2020-02-05T12:50:26Z")

</div>

One last thing I can think of is to check whether _ChunkEnable_’s selector is set correctly. If that doesn’t help please contact support to get in-depth consultation.
