# Optical zoom control on EH6300 (C#)

**URL:** <https://forum.commonvisionblox.com/t/optical-zoom-control-on-eh6300-c/172>\
**Category:** C-style API\
**Tags:** activex, csharp, genapi\
**Created:** [July 24, 2017, 2:51pm UTC](https://forum.commonvisionblox.com/t/optical-zoom-control-on-eh6300-c/172 "2017-07-24T14:51:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![trob](https://avatars.discourse-cdn.com/v4/letter/t/6f9a4e/32.png) [@trob](https://forum.commonvisionblox.com/u/trob)\
**Post date:** [July 24, 2017, 2:51pm UTC](https://forum.commonvisionblox.com/t/optical-zoom-control-on-eh6300-c/172/1 "2017-07-24T14:51:04Z")

</div>

Hi,  
I’ve used the CSMovie2Recorder tutorial program lately, and adjusted to my needs for a Sony EH6300 (ethernet). It works prefectly!  
Only point is that I’d need to control the **Optical Zoom** from a scrollBar I’ve added, but I’m still not sure what command to use… since the function m\_cvDisplay.SetDisplayZoomEx() is for digital zoom in my case.  
Thanks for your help.

---

<div class="post-metadata">

**Author:** ![trob](https://avatars.discourse-cdn.com/v4/letter/t/6f9a4e/32.png) [@trob](https://forum.commonvisionblox.com/u/trob)\
**Post date:** [July 24, 2017, 3:58pm UTC](https://forum.commonvisionblox.com/t/optical-zoom-control-on-eh6300-c/172/2 "2017-07-24T15:58:35Z")

</div>

Ok, in addition. The management of the Zoom Control in CVB is made of two statements:

- first have to set control mode (ZoomControlMode) to “ZoomTarget”
- then can manage zoom position (ZoomPositionTarget) from an integer

Here is an extract of the GenICam Settings File \*.gcs file given by CVB Manager when trying to finding the function :

```
Cust::ZoomControlMode = "ZoomTarget"
Cust::ZoomFactor = "1"
Cust::ZoomPosition = "0"
Cust::ZoomPositionTarget = "152" (<-- here is to set zoom position)
Cust::ZoomPlusSpeed = "0"
Cust::ZoomMinusSpeed = "0"
Cust::ZoomDEnable = "1"

```

I’m still looking to find those properties, but honestly, am getting lost…

---

<div class="post-metadata">

**Author:** ![Diverl](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/diverl/32/434_2.png) [@Diverl](https://forum.commonvisionblox.com/u/Diverl)\
**Post date:** [July 25, 2017, 6:59am UTC](https://forum.commonvisionblox.com/t/optical-zoom-control-on-eh6300-c/172/3 "2017-07-25T06:59:20Z")

</div>

Hi trob,

thank you very much for your question. You can access any camera parameter value which is read/writeable via the INodeMap interface. In CVB all parameters are within the NodeMap, one parameter is a Node. So on the Common Vision Blox Manual you can find according programming information.

You may also find information in following link, where you can find a sample code:  
[CVB User Guide NodeMap](https://help.commonvisionblox.com/NextGen/14.0/md_theory_of_operation_hardware __gen_i_cam__ c_v_b__user_guide.html#gcug_chmtopic54)

```cpp
// Check if INodemap interface is available
if (CanNodeMapHandle((IMG)m_cvImg.GetImage()))
{
  NODEMAP nodeMap = nullptr;
  // Get NodeMap from Camera
  cvbres_t result = NMHGetNodeMap(reinterpret_cast<IMG>(m_cvImg.GetImage()), nodeMap);
  if (result >= 0)
  {
    NODE exposureTimeNode = nullptr;
    result = NMGetNode(nodeMap, "ExposureTime", exposureTimeNode);
    if (result >= 0)
    {
      // Set the Exposuretime to 20ms
      result = NSetAsFloat(exposureTimeNode, 20000);
 
      ReleaseObject(exposureTimeNode);
    }
 
    ReleaseObject(nodeMap);
  }
 
  // TODO result < 0 => error
}

```

I hope, this answers your question.

Regards,  
Bea

---

<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:** [July 25, 2017, 7:25am UTC](https://forum.commonvisionblox.com/t/optical-zoom-control-on-eh6300-c/172/4 "2017-07-25T07:25:14Z")

</div>

> [@trob](#):
>
> ZoomPositionTarget

I also was nearly finished with the C# implementation when @Diverl posted her answer. 🙂 So I assume you use a _Windows.Forms_ dialog with an :cvb: _Image ActiveX Control_ `m_cvImage`:

```auto
using (var nodeMap = NodeMapExtensions.NodeMapFromDriverImage(m_cvImage.Image))
{
  using (var zoomControlMode = nodeMap.GetNode("ZoomControlMode"))
  {
    zoomControlMode.SetValue("ZoomTarget");
  }
  using (var zoomTarget = nodeMap.GetNode("ZoomPositionTarget")
  {
    zoomTarget.SetValue(42);
  }
}

```

To be able to use that you need these two extension classes which need the _iCVCImg.dll_, _iCVCDriver.dll_ and _iCVGenApi.dll_ from _%CVB%\Lib\Net_ as references:

```auto
using Cvb
using static Cvb.Driver.INodeMapHandle
using static Cvb.GenApi
using static Cvb.Image

static class NodeMapExtensions
{
  public static SharedNodeMap NodeMapFromDriverImage(IMG driver)
  {
    SharedNodeMap nodeMap;
    int result = NMHGetNodeMap(driver, out nodeMap);
    if (result < 0)
      throw new Exception("CVB error #" + (result & 0x7FFFFFFF));
    return nodeMap;
  }

  public static SharedNode GetNode(this SharedNodeMap nodeMap, string nodeName)
  {
    SharedNode node;
    int result = NMGetNode(nodeMap, nodeName, out node);
    if (result < 0)
      throw new Exception("CVB error #" + (result & 0x7FFFFFFF));
    return node;
  }
}

static class NodeExtensions
{
  public static void SetValue(this SharedNode node, string value)
  {
    int result = NSetAsString(node, value);
    if (result < 0)
      throw new Exception("CVB error #" + (result & 0x7FFFFFFF));
   }
	
  public static void GetValue(this SharedNode node, out string value)
  {
    int result = NGetAsString(node, out value);
    if (result < 0)
      throw new Exception("CVB error #" + (result & 0x7FFFFFFF));
  }

  public static void SetValue(this SharedNode node, long value)
  {
    int result = NSetAsInteger(node, value);
    if (result < 0)
      throw new Exception("CVB error #" + (result & 0x7FFFFFFF));
  }

  public static void GetValue(this SharedNode node, out long value)
  {
    int result = NGetAsInteger(node, out value);
    if (result < 0)
      throw new Exception("CVB error #" + (result & 0x7FFFFFFF));
   }
}

```

---

<div class="post-metadata">

**Author:** ![trob](https://avatars.discourse-cdn.com/v4/letter/t/6f9a4e/32.png) [@trob](https://forum.commonvisionblox.com/u/trob)\
**Post date:** [July 27, 2017, 1:02pm UTC](https://forum.commonvisionblox.com/t/optical-zoom-control-on-eh6300-c/172/5 "2017-07-27T13:02:23Z")

</div>

Many thanks for your help. I’ll try it right away.
