Subversion Repositories seema-scanner

Rev

Rev 19 | Rev 23 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 19 Rev 20
Line 30... Line 30...
30
        FlyCapture2::Camera cam;
30
        FlyCapture2::Camera cam;
31
        error = cam.Connect(&guid);
31
        error = cam.Connect(&guid);
32
        if (error != FlyCapture2::PGRERROR_OK)
32
        if (error != FlyCapture2::PGRERROR_OK)
33
            PrintError( error );
33
            PrintError( error );
34
 
34
 
-
 
35
        // Get camera information
-
 
36
        FlyCapture2::CameraInfo camInfo;
-
 
37
        error = cam.GetCameraInfo(&camInfo);
-
 
38
        if (error != FlyCapture2::PGRERROR_OK)
-
 
39
            PrintError( error );
-
 
40
 
-
 
41
        CameraInfo camera;
-
 
42
        camera.busID = camInfo.nodeNumber;
-
 
43
        camera.model = camInfo.modelName;
-
 
44
        camera.vendor = "Point Grey Research";
-
 
45
 
-
 
46
        ret.push_back(camera);
-
 
47
    }
-
 
48
 
-
 
49
    return ret;
-
 
50
}
-
 
51
 
-
 
52
CameraPointGrey::CameraPointGrey(unsigned int camNum, CameraTriggerMode triggerMode) : Camera(triggerMode){
-
 
53
 
-
 
54
    FlyCapture2::Error error;
-
 
55
 
-
 
56
    // Connect to camera
-
 
57
    FlyCapture2::BusManager busManager;
-
 
58
    FlyCapture2::PGRGuid camGuid;
-
 
59
    busManager.GetCameraFromIndex(camNum, &camGuid);
-
 
60
    error = cam.Connect(&camGuid);
-
 
61
    if (error != FlyCapture2::PGRERROR_OK)
-
 
62
        PrintError(error);
-
 
63
 
35
    //    // Configure DCAM video mode and frame rate
64
//    // Configure DCAM video mode and frame rate
36
    //    FlyCapture2::VideoMode videoMode = FlyCapture2::VIDEOMODE_1280x960Y8;
65
//    FlyCapture2::VideoMode videoMode = FlyCapture2::VIDEOMODE_1280x960Y8;
37
    //    FlyCapture2::FrameRate frameRate = FlyCapture2::FRAMERATE_7_5;
66
//    FlyCapture2::FrameRate frameRate = FlyCapture2::FRAMERATE_7_5;
38
    //    error = cam.SetVideoModeAndFrameRate(videoMode, frameRate);
67
//    error = cam.SetVideoModeAndFrameRate(videoMode, frameRate);
39
    //    if (error != FlyCapture2::PGRERROR_OK)
68
//    if (error != FlyCapture2::PGRERROR_OK)
40
    //        PrintError(error);
69
//        PrintError(error);
41
 
70
 
42
        // Configure Format7 mode
71
    // Configure Format7 mode
43
        FlyCapture2::Format7ImageSettings format7Settings;
72
    FlyCapture2::Format7ImageSettings format7Settings;
44
        format7Settings.mode = FlyCapture2::MODE_0;
73
    format7Settings.mode = FlyCapture2::MODE_0;
45
        format7Settings.pixelFormat = FlyCapture2::PIXEL_FORMAT_RAW8;
74
    format7Settings.pixelFormat = FlyCapture2::PIXEL_FORMAT_RAW16;
46
        format7Settings.width = 1296;
75
    format7Settings.width = 3376;
47
        format7Settings.height = 964;
76
    format7Settings.height = 2704;
48
        format7Settings.offsetX = 0;
77
    format7Settings.offsetX = 0;
49
        format7Settings.offsetY = 0;
78
    format7Settings.offsetY = 0;
50
 
79
 
51
        // Validate and set mode
80
    // Validate and set mode
52
        FlyCapture2::Format7PacketInfo packetInfo;
81
    FlyCapture2::Format7PacketInfo packetInfo;
53
        bool valid;
82
    bool valid;
54
        cam.ValidateFormat7Settings(&format7Settings, &valid, &packetInfo);
83
    error = cam.ValidateFormat7Settings(&format7Settings, &valid, &packetInfo);
-
 
84
    if (error != FlyCapture2::PGRERROR_OK)
-
 
85
        PrintError(error);
55
        // packetsize indirectly configures frame rate
86
    // packetsize indirectly configures frame rate
56
        error = cam.SetFormat7Configuration(&format7Settings, packetInfo.unitBytesPerPacket*3);
87
    error = cam.SetFormat7Configuration(&format7Settings, packetInfo.recommendedBytesPerPacket);
57
        if (error != FlyCapture2::PGRERROR_OK)
88
    if (error != FlyCapture2::PGRERROR_OK)
58
            PrintError(error);
89
        PrintError(error);
59
 
90
 
60
        // Configure general
91
    // Configure general
61
        FlyCapture2::FC2Config config;
92
    FlyCapture2::FC2Config config;
Line 67... Line 98...
67
        //config.asyncBusSpeed = FlyCapture2::BUSSPEED_S_FASTEST;
98
    //config.asyncBusSpeed = FlyCapture2::BUSSPEED_S_FASTEST;
68
        error = cam.SetConfiguration(&config);
99
    error = cam.SetConfiguration(&config);
69
        if (error != FlyCapture2::PGRERROR_OK)
100
    if (error != FlyCapture2::PGRERROR_OK)
70
            PrintError(error);
101
        PrintError(error);
71
 
102
 
72
        // Get camera information
-
 
73
        FlyCapture2::CameraInfo camInfo;
-
 
74
        error = cam.GetCameraInfo(&camInfo);
-
 
75
        if (error != FlyCapture2::PGRERROR_OK)
-
 
76
            PrintError( error );
-
 
77
 
-
 
78
        CameraInfo camera;
-
 
79
        camera.busID = camInfo.nodeNumber;
-
 
80
        camera.model = camInfo.modelName;
-
 
81
        camera.vendor = "Point Grey Research";
-
 
82
 
-
 
83
        ret.push_back(camera);
-
 
84
    }
-
 
85
 
-
 
86
    return ret;
-
 
87
}
-
 
88
 
-
 
89
CameraPointGrey::CameraPointGrey(unsigned int camNum, CameraTriggerMode triggerMode) : Camera(triggerMode){
-
 
90
 
-
 
91
    FlyCapture2::Error error;
-
 
92
 
-
 
93
    // Connect to camera
-
 
94
    FlyCapture2::BusManager busManager;
-
 
95
    FlyCapture2::PGRGuid camGuid;
-
 
96
    busManager.GetCameraFromIndex(camNum, &camGuid);
-
 
97
    error = cam.Connect(&camGuid);
-
 
98
    if (error != FlyCapture2::PGRERROR_OK)
-
 
99
        PrintError(error);
-
 
100
 
-
 
101
    // Configure video mode and frame rate
-
 
102
    FlyCapture2::VideoMode videoMode = FlyCapture2::VIDEOMODE_640x480Y16;
-
 
103
    FlyCapture2::FrameRate frameRate = FlyCapture2::FRAMERATE_15;
-
 
104
    cam.SetVideoModeAndFrameRate(videoMode, frameRate);
-
 
105
 
103
 
106
    // Get the camera information
104
    // Get the camera information
107
    FlyCapture2::CameraInfo camInfo;
105
    FlyCapture2::CameraInfo camInfo;
108
    error = cam.GetCameraInfo(&camInfo);
106
    error = cam.GetCameraInfo(&camInfo);
109
    if (error != FlyCapture2::PGRERROR_OK)
107
    if (error != FlyCapture2::PGRERROR_OK)
Line 116... Line 114...
116
    //settings.shutter = 8.33;
114
    //settings.shutter = 8.33;
117
    settings.shutter = 33.33;
115
    settings.shutter = 33.33;
118
    settings.gain = 0.0;
116
    settings.gain = 0.0;
119
    this->setCameraSettings(settings);
117
    this->setCameraSettings(settings);
120
 
118
 
121
    // Start isochronous image transfer
-
 
122
    error = cam.StartCapture();
-
 
123
    if (error != FlyCapture2::PGRERROR_OK)
-
 
124
        PrintError(error);
-
 
125
 
-
 
126
    return;
119
    return;
127
}
120
}
128
 
121
 
129
CameraSettings CameraPointGrey::getCameraSettings(){
122
CameraSettings CameraPointGrey::getCameraSettings(){
130
 
123
 
Line 160... Line 153...
160
 
153
 
161
}
154
}
162
 
155
 
163
void CameraPointGrey::startCapture(){
156
void CameraPointGrey::startCapture(){
164
 
157
 
165
    FlyCapture2::Error error;\
158
    FlyCapture2::Error error;
166
 
159
 
167
    CameraSettings settings = this->getCameraSettings();
160
    CameraSettings settings = this->getCameraSettings();
168
    std::cout << "\tShutter: " << settings.shutter << "ms" << std::endl;
161
    std::cout << "\tShutter: " << settings.shutter << "ms" << std::endl;
169
    std::cout << "\tGain: " << settings.gain << "dB" << std::endl;
162
    std::cout << "\tGain: " << settings.gain << "dB" << std::endl;
170
 
163
 
Line 177... Line 170...
177
        triggerMode.mode = 14;
170
        triggerMode.mode = 14;
178
        error = cam.SetTriggerMode(&triggerMode);
171
        error = cam.SetTriggerMode(&triggerMode);
179
        if (error != FlyCapture2::PGRERROR_OK)
172
        if (error != FlyCapture2::PGRERROR_OK)
180
            PrintError(error);
173
            PrintError(error);
181
 
174
 
182
        error = cam.StartCapture();
-
 
183
        if (error != FlyCapture2::PGRERROR_OK)
-
 
184
            PrintError(error);
-
 
185
 
-
 
186
    } else if(triggerMode == triggerModeSoftware){
175
    } else if(triggerMode == triggerModeSoftware){
187
        // Configure software trigger
176
        // Configure software trigger
188
        FlyCapture2::TriggerMode triggerMode;
177
        FlyCapture2::TriggerMode triggerMode;
189
        triggerMode.onOff = true;
178
        triggerMode.onOff = true;
190
        triggerMode.polarity = 0;
179
        triggerMode.polarity = 0;
Line 200... Line 189...
200
    config.grabTimeout = 1000;
189
    config.grabTimeout = 1000;
201
    error = cam.SetConfiguration(&config);
190
    error = cam.SetConfiguration(&config);
202
    if (error != FlyCapture2::PGRERROR_OK)
191
    if (error != FlyCapture2::PGRERROR_OK)
203
        PrintError(error);
192
        PrintError(error);
204
 
193
 
-
 
194
    error = cam.StartCapture();
-
 
195
    if (error != FlyCapture2::PGRERROR_OK)
-
 
196
        PrintError(error);
-
 
197
 
205
    capturing = true;
198
    capturing = true;
206
}
199
}
207
 
200
 
208
void CameraPointGrey::stopCapture(){
201
void CameraPointGrey::stopCapture(){
209
 
202
 
Line 228... Line 221...
228
    FlyCapture2::Image rawImage;
221
    FlyCapture2::Image rawImage;
229
    error = cam.RetrieveBuffer(&rawImage);
222
    error = cam.RetrieveBuffer(&rawImage);
230
    if (error != FlyCapture2::PGRERROR_OK)
223
    if (error != FlyCapture2::PGRERROR_OK)
231
        PrintError(error);
224
        PrintError(error);
232
 
225
 
-
 
226
    rawImage.SetColorProcessing(FlyCapture2::IPP);
-
 
227
 
-
 
228
    // de-Bayer
-
 
229
    rawImage.Convert(FlyCapture2::PIXEL_FORMAT_RGB16, &currentImage);
-
 
230
 
233
    CameraFrame frame;
231
    CameraFrame frame;
234
 
232
 
235
    frame.timeStamp = rawImage.GetTimeStamp().cycleCount;
233
    frame.timeStamp = currentImage.GetTimeStamp().cycleCount;
236
    frame.height = rawImage.GetRows();
234
    frame.height = currentImage.GetRows();
237
    frame.width = rawImage.GetCols();
235
    frame.width = currentImage.GetCols();
238
    frame.bitDepth = 16;
236
    frame.bitDepth = 14;
239
    frame.memory = (unsigned short*)rawImage.GetData();
237
    frame.memory = (unsigned short*)currentImage.GetData();
240
 
238
 
241
    return frame;
239
    return frame;
242
}
240
}
243
 
241
 
244
 
242
 
245
size_t CameraPointGrey::getFrameSizeBytes(){
243
size_t CameraPointGrey::getFrameSizeBytes(){
246
    
244
    
247
    return 0;
245
    return 3376*2704*2*3;
248
}
246
}
249
 
247
 
250
size_t CameraPointGrey::getFrameWidth(){
248
size_t CameraPointGrey::getFrameWidth(){
251
 
249
 
252
    // How do we poll this from the camera?
250
    // How do we poll this from the camera?
253
    return 640;
251
    return 3376;
254
 
252
 
255
}
253
}
256
 
254
 
257
size_t CameraPointGrey::getFrameHeight(){
255
size_t CameraPointGrey::getFrameHeight(){
258
 
256
 
259
    // How do we poll this from the camera?
257
    // How do we poll this from the camera?
260
    return 480;
258
    return 2704;
261
 
259
 
262
}
260
}
263
 
261
 
264
 
262
 
265
CameraPointGrey::~CameraPointGrey(){
263
CameraPointGrey::~CameraPointGrey(){