-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFeatureControl.cpp
More file actions
74 lines (62 loc) · 2.16 KB
/
Copy pathFeatureControl.cpp
File metadata and controls
74 lines (62 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <iostream>
#include <sstream>
#include <string>
#include "FeatureControl.h"
using namespace Spinnaker::GenApi;
using namespace Spinnaker::GenICam;
bool WriteFeatureValue(Spinnaker::CameraPtr pCam, const std::string& strName, const std::string& strValue) {
try {
INodeMap& nodeMap = pCam->GetNodeMap();
INode* pNode = nodeMap.GetNode(strName.c_str());
if (!pNode) {
std::cout << "WriteFeatureValue Unknown feature name: " << strName << std::endl;
return false;
}
CNodePtr pFeatureNode = pNode;
CValuePtr pValue = (CValuePtr)pFeatureNode;
if (IsWritable(pValue)) {
pValue->FromString(strValue.c_str());
return true;
}
else {
std::cout << "WriteFeatureValue feature name: " << strName << " is not writable" << std::endl;
return false;
}
}
catch (Spinnaker::Exception& e) {
std::cout << "Spinnaker exception WriteFeatureValue: " << e.what() << std::endl;
}
catch (...) {
std::cout << "Unknown exception WriteFeatureValue" << std::endl;
}
return false;
}
bool ReadFeatureValue(Spinnaker::CameraPtr pCam, const std::string& strName, std::string& strValue) {
try {
INodeMap& nodeMap = pCam->GetNodeMap();
INode* pNode = nodeMap.GetNode(strName.c_str());
if (!pNode) {
std::cout << "ReadFeatureValue Unknown feature name: " << strName << std::endl;
return false;
}
CNodePtr pFeatureNode = pNode;
CValuePtr pValue = (CValuePtr)pFeatureNode;
if (IsReadable(pValue)) {
gcstring strVal;
strVal = pValue->ToString();
strValue = strVal.c_str();
return true;
}
else {
std::cout << "ReadFeatureValue feature name: " << strName << " is not readable" << std::endl;
return false;
}
}
catch (Spinnaker::Exception& e) {
std::cout << "Spinnaker exception ReadFeatureValue: " << e.what() << std::endl;
}
catch (...) {
std::cout << "Unknown exception ReadFeatureValue" << std::endl;
}
return false;
}