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.
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…
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
// 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
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
:
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:
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));
}
}
Many thanks for your help. I’ll try it right away.