Subversion Repositories seema-scanner

Rev

Rev 20 | Rev 26 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 20 Rev 23
Line 54... Line 54...
54
    FlyCapture2::Error error;
54
    FlyCapture2::Error error;
55
 
55
 
56
    // Connect to camera
56
    // Connect to camera
57
    FlyCapture2::BusManager busManager;
57
    FlyCapture2::BusManager busManager;
58
    FlyCapture2::PGRGuid camGuid;
58
    FlyCapture2::PGRGuid camGuid;
-
 
59
 
59
    busManager.GetCameraFromIndex(camNum, &camGuid);
60
    busManager.GetCameraFromIndex(camNum, &camGuid);
60
    error = cam.Connect(&camGuid);
61
    error = cam.Connect(&camGuid);
61
    if (error != FlyCapture2::PGRERROR_OK)
62
    if (error != FlyCapture2::PGRERROR_OK)
62
        PrintError(error);
63
        PrintError(error);
63
 
64
 
Line 205... Line 206...
205
        PrintError(error);
206
        PrintError(error);
206
 
207
 
207
    capturing = false;
208
    capturing = false;
208
}
209
}
209
 
210
 
210
CameraFrame CameraPointGrey::getFrame(){
211
void CameraPointGrey::trigger(){
211
 
212
 
212
    FlyCapture2::Error error;
213
    FlyCapture2::Error error;
213
 
214
 
214
    if(triggerMode == triggerModeSoftware){
-
 
215
        // Fire software trigger
215
    // Fire software trigger
216
        // broadcasting not supported on some platforms
216
    // broadcasting not supported on some platforms
217
        cam.FireSoftwareTrigger(false);
217
    error = cam.FireSoftwareTrigger(false);
-
 
218
 
-
 
219
    if (error != FlyCapture2::PGRERROR_OK)
-
 
220
        PrintError(error);
-
 
221
 
218
    }
222
}
-
 
223
 
-
 
224
CameraFrame CameraPointGrey::getFrame(){
-
 
225
 
-
 
226
    FlyCapture2::Error error;
219
 
227
 
220
    // Retrieve the image
228
    // Retrieve the image
221
    FlyCapture2::Image rawImage;
229
    FlyCapture2::Image rawImage;
222
    error = cam.RetrieveBuffer(&rawImage);
230
    error = cam.RetrieveBuffer(&rawImage);
223
    if (error != FlyCapture2::PGRERROR_OK)
231
    if (error != FlyCapture2::PGRERROR_OK)
224
        PrintError(error);
232
        PrintError(error);
225
 
233
 
226
    rawImage.SetColorProcessing(FlyCapture2::IPP);
234
    rawImage.SetColorProcessing(FlyCapture2::IPP);
227
 
235
 
228
    // de-Bayer
236
    // de-Bayer
229
    rawImage.Convert(FlyCapture2::PIXEL_FORMAT_RGB16, &currentImage);
237
    rawImage.Convert(FlyCapture2::PIXEL_FORMAT_RGB8, &currentImage);
230
 
238
 
231
    CameraFrame frame;
239
    CameraFrame frame;
232
 
240
 
233
    frame.timeStamp = currentImage.GetTimeStamp().cycleCount;
241
    frame.timeStamp = currentImage.GetTimeStamp().cycleCount;
234
    frame.height = currentImage.GetRows();
242
    frame.height = currentImage.GetRows();
235
    frame.width = currentImage.GetCols();
243
    frame.width = currentImage.GetCols();
236
    frame.bitDepth = 14;
244
    frame.bitDepth = 8;
-
 
245
    frame.channels = 3;
237
    frame.memory = (unsigned short*)currentImage.GetData();
246
    frame.memory = (unsigned short*)currentImage.GetData();
238
 
247
 
239
    return frame;
248
    return frame;
240
}
249
}
241
 
250
 
242
 
251
 
243
size_t CameraPointGrey::getFrameSizeBytes(){
252
size_t CameraPointGrey::getFrameSizeBytes(){
244
    
253
    
245
    return 3376*2704*2*3;
254
    return 3376*2704*3;
246
}
255
}
247
 
256
 
248
size_t CameraPointGrey::getFrameWidth(){
257
size_t CameraPointGrey::getFrameWidth(){
249
 
258
 
250
    // How do we poll this from the camera?
259
    // How do we poll this from the camera?
Line 260... Line 269...
260
}
269
}
261
 
270
 
262
 
271
 
263
CameraPointGrey::~CameraPointGrey(){
272
CameraPointGrey::~CameraPointGrey(){
264
 
273
 
265
    if(capturing && triggerMode == triggerModeHardware){
274
    if(capturing){
266
        // Stop camera transmission
275
        // Stop camera transmission
267
        cam.StopCapture();
276
        stopCapture();
268
    }
277
    }
269
 
278
 
270
    // Gracefulle destruct the camera
279
    // Gracefulle destruct the camera
271
    cam.Disconnect();
280
    cam.Disconnect();
272
 
281
 
-
 
282
    std::cout << "Closed camera!" << std::endl << std::flush;
273
}
283
}
274
 
284
 
275
 
285
 
276
 
286