|
|
Spinnaker C |
4.3.0.189 |
|
|
NodeMapInfo_C.c shows how to retrieve node map information. It relies on information provided in the Enumeration_C example. Following this, check out the Acquisition_C example if you haven't already. It explores acquiring images.
This example explores retrieving information from all major node types on the camera. This includes string, integer, float, boolean, command, enumeration, category, and value types. Looping through multiple child nodes is also covered. A few node types are not covered - base, port, and register - as they are not fundamental. The final node type - enumeration entry - is explored only in terms of its parent node type - enumeration.
Once comfortable with NodeMapInfo_C, we suggest checking out ImageFormatControl_C and Exposure_C. ImageFormatControl_C explores customizing image settings on a camera while Exposure_C introduces the standard structure of configuring a device, acquiring some images, and then returning the device to a default state.
Please leave us feedback at: https://www.surveymonkey.com/r/TDYMVAPI More source code examples at: https://github.com/Teledyne-MV/Spinnaker-Examples Need help? Check out our forum at: https://teledynevisionsolutions.zendesk.com/hc/en-us/community/topics
#include "stdio.h"
#include "string.h"
#define MAX_BUFF_LEN 256
#define MAX_CHARS 35
{
}
{
} readType;
void indent(
unsigned int level)
{
unsigned int i = 0;
for (i = 0; i < level; i++)
{
printf(" ");
}
}
{
{
return err;
}
{
return err;
}
if (valueLength <= k_maxChars)
{
{
return err;
}
}
printf("%s: ", displayName);
if (valueLength > k_maxChars)
{
printf("...\n");
}
else
{
printf("%s\n", value);
}
return err;
}
{
{
return err;
}
{
return err;
}
if (stringValueLength <= k_maxChars)
{
{
return err;
}
}
printf("%s: ", displayName);
if (stringValueLength > k_maxChars)
{
printf("...\n");
}
else
{
printf("%s\n", stringValue);
}
return err;
}
{
{
return err;
}
int64_t integerValue = 0;
{
return err;
}
printf("%s: %d\n", displayName, (int)integerValue);
return err;
}
{
{
return err;
}
double floatValue = 0.0;
{
return err;
}
printf("%s: %f\n", displayName, floatValue);
return err;
}
{
{
return err;
}
{
return err;
}
printf("%s: %s\n", displayName, (booleanValue ? "true" : "false"));
return err;
}
{
{
return err;
}
{
return err;
}
printf("%s: ", displayName);
if (toolTipLength > k_maxChars)
{
for (unsigned int i = 0; i < k_maxChars; i++)
{
printf("%c", toolTip[i]);
}
printf("...\n");
}
else
{
printf("%s\n", toolTip);
}
return err;
}
{
{
return err;
}
{
return err;
}
{
return err;
}
printf("%s: %s\n", displayName, currentEntrySymbolic);
return err;
}
{
unsigned int i = 0;
{
return err;
}
printf("%s\n", displayName);
size_t numberOfFeatures = 0;
{
return err;
}
for (i = 0; i < numberOfFeatures; i++)
{
{
return err;
}
{
return err;
}
if (!featureNodeIsReadable)
{
continue;
}
{
return err;
}
{
}
{
}
{
switch (type)
{
break;
break;
break;
break;
break;
break;
break;
}
}
}
printf("\n");
return err;
}
{
unsigned int level = 0;
printf("\n*** PRINTING TL DEVICE NODEMAP ***\n\n");
{
printf(
"Unable to print TL device nodemap (nodemap retrieval). Aborting with error: %s [%d]\n\n",
err);
return err;
}
{
printf(
"Unable to print TL device nodemap (root node retrieval). Aborting with error: %s [%d]\n\n",
err);
return err;
}
{
return err;
}
printf("*** PRINTING TL STREAM NODEMAP ***\n\n");
{
printf(
"Unable to print TL stream nodemap (nodemap retrieval). Aborting with error: %s [%d]\n\n",
err);
return err;
}
{
printf(
"Unable to print TL stream nodemap (root node retrieval). Aborting with error: %s [%d]\n\n",
err);
return err;
}
{
return err;
}
{
printf(
"Unable to initialize camera. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
printf("*** PRINTING GENICAM NODEMAP ***\n\n");
{
printf(
"Unable to print GenICam nodemap (nodemap retrieval). Aborting with error: %s [%d]\n\n",
err);
return err;
}
{
printf(
"Unable to print GenICam nodemap (root node retrieval). Aborting with error: %s [%d]\n\n",
err);
return err;
}
{
return err;
}
{
printf(
"Unable to deinitialize camera. Non-fatal error: %s [%d]\n\n",
GetLastErrorMessage(), err);
}
return err;
}
{
unsigned int i = 0;
printf("Application build date: %s %s \n\n", __DATE__, __TIME__);
{
printf(
"Unable to retrieve system instance. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
spinLibraryVersion hLibraryVersion;
printf(
"Spinnaker library version: %d.%d.%d.%d\n\n",
hLibraryVersion.major,
hLibraryVersion.minor,
hLibraryVersion.type,
hLibraryVersion.build);
{
printf(
"Unable to create camera list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
{
printf(
"Unable to retrieve camera list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
size_t numCameras = 0;
{
printf(
"Unable to retrieve number of cameras. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
printf("Number of cameras detected: %u\n\n", (unsigned int)numCameras);
if (numCameras == 0)
{
{
printf(
"Unable to clear camera list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
{
printf(
"Unable to destroy camera list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
{
printf(
"Unable to release system instance. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
printf("Not enough cameras!\n");
printf("Done! Press Enter to exit...\n");
getchar();
return -1;
}
for (i = 0; i < numCameras; i++)
{
printf("\nRunning example for camera %d...\n", i);
{
printf(
"Unable to retrieve camera from list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
errReturn = err;
}
else
{
{
errReturn = err;
}
}
{
errReturn = err;
}
printf("Camera %d example complete...\n\n", i);
}
{
printf(
"Unable to clear camera list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
{
printf(
"Unable to destroy camera list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
{
printf(
"Unable to release system instance. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
printf("\nDone! Press Enter to exit...\n");
getchar();
return errReturn;
}
SPINNAKERC_API spinCameraRelease(spinCamera hCamera)
Releases a camera.
SPINNAKERC_API spinCameraGetNodeMap(spinCamera hCamera, spinNodeMapHandle *phNodeMap)
Retrieves the GenICam nodemap from a camera.
SPINNAKERC_API spinBooleanGetValue(spinNodeHandle hNode, bool8_t *pbValue)
Retrieves the value of a boolean node; boolean values are represented by 'True' (which equals '0') an...
SPINNAKERC_API spinCameraListClear(spinCameraList hCameraList)
Clears a camera list.
SPINNAKERC_API spinNodeGetToolTip(spinNodeHandle hNode, char *pBuf, size_t *pBufLen)
Retrieves a short description of a node.
char * GetLastErrorMessage()
Definition: NodeMapInfo_C.c:59
@ BooleanNode
Definition: SpinnakerGenApiDefsC.h:76
SPINNAKERC_API spinSystemReleaseInstance(spinSystem hSystem)
Releases the system; make sure handle is cleaned up properly by setting it to NULL after system is re...
@ EnumerationNode
Definition: SpinnakerGenApiDefsC.h:81
@ RegisterNode
Definition: SpinnakerGenApiDefsC.h:80
SPINNAKERC_API spinErrorGetLastMessage(char *pBuf, size_t *pBufLen)
Retrieves the error message of the last error.
SPINNAKERC_API spinSystemGetCameras(spinSystem hSystem, spinCameraList hCameraList)
Retrieves a list of detected (and enumerable) cameras on the system; camera lists must be created and...
SPINNAKERC_API spinStringGetValue(spinNodeHandle hNode, char *pBuf, size_t *pBufLen)
Retrieves the value of a string node as a c-string.
@ StringNode
Definition: SpinnakerGenApiDefsC.h:79
void * spinNodeMapHandle
Handle for nodemap functionality.
Definition: SpinnakerGenApiDefsC.h:39
spinError printStringNode(spinNodeHandle hNode, unsigned int level)
Definition: NodeMapInfo_C.c:162
spinError printEnumerationNodeAndCurrentEntry(spinNodeHandle hEnumerationNode, unsigned int level)
Definition: NodeMapInfo_C.c:405
@ PortNode
Definition: SpinnakerGenApiDefsC.h:84
@ INDIVIDUAL
Definition: NodeMapInfo_C.c:72
SPINNAKERC_API spinNodeGetType(spinNodeHandle hNode, spinNodeType *pType)
Retrieves the type of a node (as an enum, spinNodeType)
SPINNAKERC_API spinIntegerGetValue(spinNodeHandle hNode, int64_t *pValue)
Retrieves the value of an integer node.
SPINNAKERC_API spinCategoryGetNumFeatures(spinNodeHandle hCategoryNode, size_t *pValue)
Retrieves the number of a features (or child nodes) or a category node.
SPINNAKERC_API spinFloatGetValue(spinNodeHandle hNode, double *pValue)
Retrieves the value of a float node.
spinError printCategoryNodeAndAllFeatures(spinNodeHandle hCategoryNode, unsigned int level)
Definition: NodeMapInfo_C.c:463
@ CommandNode
Definition: SpinnakerGenApiDefsC.h:78
SPINNAKERC_API spinSystemGetLibraryVersion(spinSystem hSystem, spinLibraryVersion *hLibraryVersion)
Get current library version of Spinnaker.
@ VALUE
Definition: NodeMapInfo_C.c:71
void * spinSystem
Handle for system functionality.
Definition: SpinnakerDefsC.h:51
spinError printValueNode(spinNodeHandle hNode, unsigned int level)
Definition: NodeMapInfo_C.c:91
SPINNAKERC_API spinNodeGetDisplayName(spinNodeHandle hNode, char *pBuf, size_t *pBufLen)
Retrieves the display name of a node (whitespace possible)
spinError printCommandNode(spinNodeHandle hNode, unsigned int level)
Definition: NodeMapInfo_C.c:349
SPINNAKERC_API spinCameraInit(spinCamera hCamera)
Initializes a camera, allowing for much more interaction.
@ ValueNode
Definition: SpinnakerGenApiDefsC.h:73
spinError RunSingleCamera(spinCamera hCam)
Definition: NodeMapInfo_C.c:598
static const bool8_t False
Definition: SpinnakerDefsC.h:36
int main()
Definition: NodeMapInfo_C.c:770
SPINNAKERC_API spinCameraGetTLStreamNodeMap(spinCamera hCamera, spinNodeMapHandle *phNodeMap)
Retrieves the transport layer stream nodemap from a camera.
SPINNAKERC_API spinCameraListDestroy(spinCameraList hCameraList)
Destroys a camera list.
const readType chosenRead
Definition: NodeMapInfo_C.c:75
@ UnknownNode
Definition: SpinnakerGenApiDefsC.h:85
void indent(unsigned int level)
Definition: NodeMapInfo_C.c:78
SPINNAKERC_API spinEnumerationEntryGetSymbolic(spinNodeHandle hNode, char *pBuf, size_t *pBufLen)
Retrieves the symbolic of an entry node as a c-string.
spinError printIntegerNode(spinNodeHandle hNode, unsigned int level)
Definition: NodeMapInfo_C.c:228
void * spinCameraList
Handle for interface functionality.
Definition: SpinnakerDefsC.h:75
SPINNAKERC_API spinSystemGetInstance(spinSystem *phSystem)
Retrieves an instance of the system object; the system is a singleton, so there will only ever be one...
@ CategoryNode
Definition: SpinnakerGenApiDefsC.h:83
spinError printBooleanNode(spinNodeHandle hNode, unsigned int level)
Definition: NodeMapInfo_C.c:308
SPINNAKERC_API spinCameraListGet(spinCameraList hCameraList, size_t index, spinCamera *phCamera)
Retrieves a camera from a camera list using an index.
uint8_t bool8_t
Definition: SpinnakerDefsC.h:35
void * spinCamera
Handle for camera functionality.
Definition: SpinnakerDefsC.h:82
#define MAX_CHARS
Definition: NodeMapInfo_C.c:53
void * spinNodeHandle
Handle for node functionality.
Definition: SpinnakerGenApiDefsC.h:45
SPINNAKERC_API spinNodeIsReadable(spinNodeHandle hNode, bool8_t *pbResult)
Checks whether a node is readable.
_readType
Definition: NodeMapInfo_C.c:69
@ FloatNode
Definition: SpinnakerGenApiDefsC.h:77
SPINNAKERC_API spinEnumerationGetCurrentEntry(spinNodeHandle hEnumNode, spinNodeHandle *phEntry)
Retrieves the currently selected entry node from an enum node.
size_t lenLastErrorMessage
Definition: NodeMapInfo_C.c:56
SPINNAKERC_API spinNodeMapGetNode(spinNodeMapHandle hNodeMap, const char *pName, spinNodeHandle *phNode)
Retrieves a node from the nodemap by name.
SPINNAKERC_API spinCameraListGetSize(spinCameraList hCameraList, size_t *pSize)
Retrieves the number of cameras on a camera list.
char lastErrorMessage[MAX_BUFF_LEN]
Definition: NodeMapInfo_C.c:55
SPINNAKERC_API spinCameraDeInit(spinCamera hCamera)
Deinitializes a camera, greatly reducing functionality.
SPINNAKERC_API spinCameraGetTLDeviceNodeMap(spinCamera hCamera, spinNodeMapHandle *phNodeMap)
Retrieves the transport layer device nodemap from a camera.
#define MAX_BUFF_LEN
Definition: NodeMapInfo_C.c:49
@ EnumEntryNode
Definition: SpinnakerGenApiDefsC.h:82
@ BaseNode
Definition: SpinnakerGenApiDefsC.h:74
@ IntegerNode
Definition: SpinnakerGenApiDefsC.h:75
SPINNAKERC_API spinCategoryGetFeatureByIndex(spinNodeHandle hCategoryNode, size_t index, spinNodeHandle *phFeature)
Retrieves a node from a category node using an index.
@ SPINNAKER_ERR_SUCCESS
An error code of 0 means that the function has run without error.
Definition: SpinnakerDefsC.h:233
SPINNAKERC_API spinCameraListCreateEmpty(spinCameraList *phCameraList)
Creates an empty camera list (camera lists created this way must be destroyed)
SPINNAKERC_API spinNodeToString(spinNodeHandle hNode, char *pBuf, size_t *pBufLen)
Retrieves the value of any node type as a c-string.
spinError printFloatNode(spinNodeHandle hNode, unsigned int level)
Definition: NodeMapInfo_C.c:268