-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcamera.cpp
More file actions
172 lines (134 loc) · 4.36 KB
/
camera.cpp
File metadata and controls
172 lines (134 loc) · 4.36 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#include <iostream>
#include <stdio.h>
extern "C"
{
#include "camera.h"
}
void CPylonInitialize()
{
PylonInitialize();
}
GENAPIC_RESULT BindCamera(char *serialNo, PYLON_DEVICE_HANDLE *hdev)
{
size_t num;
GENAPIC_RESULT res;
res = PylonEnumerateDevices(&num);
if (GENAPI_E_OK != res)
{
goto err;
}
for (int i = 0; i < num; ++i)
{
res = PylonCreateDeviceByIndex(i, hdev);
if (GENAPI_E_OK != res)
{
goto err;
}
}
return GENAPI_E_OK;
err:
return res;
}
GENAPIC_RESULT CPylonGetDeviceInfo(size_t index, PylonDeviceInfo_t* pDi)
{
return PylonGetDeviceInfo(index, pDi);
}
void CPylonTerminate()
{
PylonTerminate();
}
GENAPIC_RESULT CPylonDeviceOpen(PYLON_DEVICE_HANDLE hdev, int mode)
{
return PylonDeviceOpen(hdev, mode);
}
GENAPIC_RESULT CPylonDeviceClose(PYLON_DEVICE_HANDLE hdev)
{
return PylonDeviceClose(hdev);
}
GENAPIC_RESULT CPylonDeviceIsOpen( PYLON_DEVICE_HANDLE hdev, _Bool* pOpen )
{
return PylonDeviceIsOpen(hdev, pOpen);
}
_Bool CPylonDeviceFeatureIsReadable(PYLON_DEVICE_HANDLE hdev,const char *prop)
{
bool isAvail;
isAvail = PylonDeviceFeatureIsAvailable(hdev, prop);
return true;
}
// GENAPIC_RESULT CPylonDeviceGetNumStreamGrabberChannels(PYLON_DEVICE_HANDLE hdev,size_t* pNumChannels )
// {
// return PylonDeviceGetNumStreamGrabberChannels(hdev, pNumChannels);
// }
GENAPIC_RESULT CPylonDeviceGetStreamGrabber( PYLON_DEVICE_HANDLE hDev, size_t index, PYLON_STREAMGRABBER_HANDLE* phStg )
{
return PylonDeviceGetStreamGrabber(hDev, index, phStg);
}
// GENAPIC_RESULT CPylonStreamGrabberOpen(PYLON_STREAMGRABBER_HANDLE hStg)
// {
// return PylonStreamGrabberOpen(hStg);
// }
// GENAPIC_RESULT CPylonStreamGrabberGetWaitObject( PYLON_STREAMGRABBER_HANDLE hStg, PYLON_WAITOBJECT_HANDLE* phWobj )
// {
// return PylonStreamGrabberGetWaitObject(hStg, phWobj);
// }
GENAPIC_RESULT CPylonDeviceGetIntegerFeatureInt32( PYLON_DEVICE_HANDLE dev, const char* name, int32_t* value )
{
return PylonDeviceGetIntegerFeatureInt32(dev, name, value);
}
// GENAPIC_RESULT CPylonStreamGrabberSetMaxNumBuffer( PYLON_STREAMGRABBER_HANDLE hStg, size_t numBuffers )
// {
// return PylonStreamGrabberSetMaxNumBuffer(hStg, numBuffers);
// }
// GENAPIC_RESULT CPylonStreamGrabberSetMaxBufferSize( PYLON_STREAMGRABBER_HANDLE hStg, size_t maxSize )
// {
// return PylonStreamGrabberSetMaxBufferSize(hStg, maxSize);
// }
// GENAPIC_RESULT CPylonStreamGrabberPrepareGrab( PYLON_STREAMGRABBER_HANDLE hStg )
// {
// return PylonStreamGrabberPrepareGrab(hStg);
// }
// GENAPIC_RESULT CPylonStreamGrabberRegisterBuffer( PYLON_STREAMGRABBER_HANDLE hStg, void* pBuffer, size_t BufLen, PYLON_STREAMBUFFER_HANDLE* phBuf )
// {
// return PylonStreamGrabberRegisterBuffer(hStg, pBuffer, BufLen, phBuf);
// }
// GENAPIC_RESULT CPylonStreamGrabberQueueBuffer( PYLON_STREAMGRABBER_HANDLE hStg, PYLON_STREAMBUFFER_HANDLE hBuf, const void* pContext )
// {
// return PylonStreamGrabberQueueBuffer(hStg, hBuf, pContext);
// }
void CPrintError(GENAPIC_RESULT errc) {
char* errMsg;
size_t length;
GenApiGetLastErrorMessage(NULL, &length);
errMsg = (char*) malloc( length );
GenApiGetLastErrorMessage(errMsg, &length);
fprintf( stderr, "%s (%#08x).\n", errMsg, (unsigned int) errc );
free( errMsg );
}
GENAPIC_RESULT CPylonDeviceExecuteCommandFeature( PYLON_DEVICE_HANDLE hDev, const char* pName )
{
return PylonDeviceExecuteCommandFeature(hDev, pName);
}
/*
* ----------------------------------------------------------------------------
* Device creation / destruction
* ----------------------------------------------------------------------------
*/
GENAPIC_RESULT CPylonCreateDeviceByIndex( size_t index, PYLON_DEVICE_HANDLE* phDev ){
return PylonCreateDeviceByIndex(index,phDev );
}
GENAPIC_RESULT CPylonDestroyDevice( PYLON_DEVICE_HANDLE hDev )
{
return PylonDestroyDevice(hDev);
}
GENAPIC_RESULT CPylonIsDeviceAccessible( size_t index, int accessMode, _Bool* pIsAccessible )
{
return PylonIsDeviceAccessible(index, accessMode, pIsAccessible );
}
/*
* ----------------------------------------------------------------------------
* Device enumeration
* ----------------------------------------------------------------------------
*/
GENAPIC_RESULT CPylonEnumerateDevices( size_t* numDevices ) {
return PylonEnumerateDevices(numDevices);
}