1 |
jakw |
1 |
#include <ueye.h>
|
|
|
2 |
#include <iostream>
|
|
|
3 |
|
|
|
4 |
using namespace std;
|
|
|
5 |
|
|
|
6 |
int main(int argc, char *argv[]){
|
|
|
7 |
|
|
|
8 |
// Init Camera
|
|
|
9 |
HIDS camera = (HIDS) 0 + 1;
|
|
|
10 |
is_InitCamera(&camera, NULL);
|
|
|
11 |
|
|
|
12 |
// Error reporting
|
|
|
13 |
is_SetErrorReport(camera, IS_ENABLE_ERR_REP);
|
|
|
14 |
|
|
|
15 |
// // Set display mode
|
|
|
16 |
// is_SetDisplayMode(camera, IS_SET_DM_DIB);
|
|
|
17 |
|
|
|
18 |
// Use 2x scaler to double attainable framerate
|
|
|
19 |
is_SetSensorScaler(camera, IS_ENABLE_SENSOR_SCALER, 2.0);
|
|
|
20 |
|
|
|
21 |
// Get current AOI info
|
|
|
22 |
IS_RECT rectAOI;
|
|
|
23 |
is_AOI(camera, IS_AOI_IMAGE_GET_AOI, (void*)&rectAOI, sizeof(rectAOI));
|
|
|
24 |
// Decrease AOI a little to improve readout speed
|
|
|
25 |
rectAOI.s32X = 6; rectAOI.s32Width -= 12;
|
|
|
26 |
is_AOI(camera, IS_AOI_IMAGE_SET_AOI, (void*)&rectAOI, sizeof(rectAOI));
|
|
|
27 |
unsigned int frameWidth = rectAOI.s32Width;
|
|
|
28 |
unsigned int frameHeight = rectAOI.s32Height;
|
|
|
29 |
|
|
|
30 |
// Set up 8bit monochrome color depth
|
|
|
31 |
is_SetColorMode(camera, IS_CM_MONO8);
|
|
|
32 |
int bitsPerPixel = 8;
|
|
|
33 |
|
|
|
34 |
char* frameMemory[10]; // 10 char pointers
|
|
|
35 |
int memoryID[10];
|
|
|
36 |
|
|
|
37 |
// Memory initialization
|
|
|
38 |
is_ClearSequence(camera);
|
|
|
39 |
for(unsigned int i=0; i<10; i++){
|
|
|
40 |
is_AllocImageMem(camera, frameWidth, frameHeight, bitsPerPixel, &frameMemory[i], &memoryID[i]);
|
|
|
41 |
is_AddToSequence(camera, frameMemory[i], memoryID[i]);
|
|
|
42 |
}
|
|
|
43 |
// Configure FIFO queue
|
|
|
44 |
// is_InitImageQueue(camera, 0);
|
|
|
45 |
|
|
|
46 |
// // Single frame memory
|
|
|
47 |
// is_AllocImageMem(camera, frameWidth, frameHeight, bitsPerPixel, ¤tFrameMemory, ¤tFrameID);
|
|
|
48 |
// is_SetImageMem(camera, currentFrameMemory, currentFrameID);
|
|
|
49 |
|
|
|
50 |
// Set max available pixel clock
|
|
|
51 |
unsigned int pixelClockRange[3];
|
|
|
52 |
is_PixelClock(camera, IS_PIXELCLOCK_CMD_GET_RANGE, (void*)pixelClockRange, sizeof(pixelClockRange));
|
|
|
53 |
unsigned int nMax = pixelClockRange[1];
|
|
|
54 |
is_PixelClock(camera, IS_PIXELCLOCK_CMD_SET,(void*)&nMax, sizeof(nMax));
|
|
|
55 |
|
|
|
56 |
// Set low framerate to enable long exposure setting.
|
|
|
57 |
// Note: framerate setting has no other effect in trigger mode.
|
|
|
58 |
is_SetFrameRate(camera, 30.0, NULL);
|
|
|
59 |
|
|
|
60 |
// // Use global shutter
|
|
|
61 |
// is_SetGlobalShutter(camera, IS_SET_GLOBAL_SHUTTER_ON);
|
|
|
62 |
// int shutterMode = IS_DEVICE_FEATURE_CAP_SHUTTER_MODE_GLOBAL;
|
|
|
63 |
// is_DeviceFeature(camera, IS_DEVICE_FEATURE_CMD_SET_SHUTTER_MODE, (void*)&shutterMode, sizeof(shutterMode));
|
|
|
64 |
|
|
|
65 |
// Enable gain boost
|
|
|
66 |
is_SetGainBoost(camera, IS_SET_GAINBOOST_ON);
|
|
|
67 |
|
|
|
68 |
// Disable hardware gamma
|
|
|
69 |
is_SetHardwareGamma(camera, IS_SET_HW_GAMMA_OFF);
|
|
|
70 |
|
|
|
71 |
// Print current settings
|
|
|
72 |
cout << "Camera IDS Imaging" << endl;
|
|
|
73 |
double shutter;
|
|
|
74 |
is_Exposure(camera, IS_EXPOSURE_CMD_GET_EXPOSURE, &shutter, sizeof(shutter));
|
|
|
75 |
cout << "Shutter: " << shutter << " ms" << endl;
|
|
|
76 |
cout << "Gamma: " << (float)is_SetGamma(camera, IS_GET_GAMMA)/100.0 << endl;
|
|
|
77 |
cout << "Gain: " << is_SetHardwareGain(camera, IS_GET_MASTER_GAIN, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER) << " %" << endl;
|
|
|
78 |
|
|
|
79 |
// Configure for hardware triggered mode
|
|
|
80 |
is_SetExternalTrigger(camera, IS_SET_TRIGGER_OFF);
|
|
|
81 |
|
|
|
82 |
// Timeout for marking a trigger event as failed
|
|
|
83 |
//is_SetTimeout(camera, IS_TRIGGER_TIMEOUT, 10000);
|
|
|
84 |
|
|
|
85 |
// Begin transmission
|
|
|
86 |
is_CaptureVideo(camera, IS_DONT_WAIT);
|
|
|
87 |
|
|
|
88 |
is_EnableEvent(camera, IS_SET_EVENT_FRAME);
|
|
|
89 |
|
|
|
90 |
// Capture a couple of frames
|
|
|
91 |
char* currentFrameMemory;
|
|
|
92 |
int currentFrameID;
|
|
|
93 |
for(unsigned int i=0; i<100; i++){
|
|
|
94 |
// is_WaitForNextImage(camera, 10000, ¤tFrameMemory, ¤tFrameID);
|
|
|
95 |
is_WaitEvent(camera, IS_SET_EVENT_FRAME, 1000);
|
|
|
96 |
is_GetActSeqBuf(camera, NULL, NULL, ¤tFrameMemory);
|
|
|
97 |
is_LockSeqBuf(camera, IS_IGNORE_PARAMETER, currentFrameMemory);
|
|
|
98 |
is_UnlockSeqBuf(camera, IS_IGNORE_PARAMETER, currentFrameMemory);
|
|
|
99 |
cout << "Caputured frame " << i << endl << flush;
|
|
|
100 |
}
|
|
|
101 |
|
|
|
102 |
is_StopLiveVideo(camera, IS_WAIT);
|
|
|
103 |
|
|
|
104 |
// is_ExitImageQueue(camera);
|
|
|
105 |
// // Gracefully close the camera
|
|
|
106 |
// is_ClearSequence(camera);
|
|
|
107 |
|
|
|
108 |
// unsigned int ringBufferSize = 10;
|
|
|
109 |
// for(unsigned int i=0; i<ringBufferSize; i++){
|
|
|
110 |
// is_FreeImageMem(camera, frameMemory[i], memoryID[i]);
|
|
|
111 |
// }
|
|
|
112 |
|
|
|
113 |
// Exit and free memories
|
|
|
114 |
is_ExitCamera(camera);
|
|
|
115 |
|
|
|
116 |
return 0;
|
|
|
117 |
}
|
|
|
118 |
|
|
|
119 |
|
|
|
120 |
|