Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Added exposure, colormodes and fixed destructor
  • Loading branch information
MPIBR-kretschmerf committed Jun 1, 2017
1 parent 7665372 commit 33f4a79
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 29 deletions.
52 changes: 23 additions & 29 deletions SpinnakerCapture.cpp
Expand Up @@ -45,6 +45,8 @@ SpinnakerCapture::SpinnakerCapture(QObject *parent)
width = ptrWidth->GetValue();
CIntegerPtr ptrHeight = nodeMap->GetNode("Height");
height = ptrHeight->GetValue();
CFloatPtr ptrExposureTime = nodeMap->GetNode("ExposureTime");
exposureTime = ptrExposureTime->GetValue();

qDebug()<< "Initialized Spinnaker compatible camera (" << width << "x" << height << ")";
isInitialized = true;
Expand Down Expand Up @@ -127,36 +129,16 @@ int SpinnakerCapture::configureExposure(double exposureTimeToSet)
return result;
}

// This function acquires and saves 10 images from a device.
// This function acquires images from a device.
int SpinnakerCapture::acquireImages(unsigned int nImagesToCapture)
{
int result = 0;

qDebug() << "*** IMAGE ACQUISITION ***";

try{
//
// Set acquisition mode to continuous
//
// *** NOTES ***
// Because the example acquires and saves 10 images, setting acquisition
// mode to continuous lets the example finish. ifset to single frame
// or multiframe (at a lower number of images), the example would just
// hang. This would happen because the example has been written to
// acquire 10 images while the camera would have been programmed to
// retrieve less than that.
//
// Setting the value of an enumeration node is slightly more complicated
// than other node types. Two nodes must be retrieved: first, the
// enumeration node is retrieved from the nodemap; and second, the entry
// node is retrieved from the enumeration node. The integer value of the
// entry node is then set as the new value of the enumeration node.
//
// Notice that both the enumeration and the entry nodes are checked for
// availability and readability/writability. Enumeration nodes are
// generally readable and writable whereas their entry nodes are only
// ever readable.
//

// Retrieve enumeration node from nodemap
CEnumerationPtr ptrAcquisitionMode = nodeMap->GetNode("AcquisitionMode");
if(!IsAvailable(ptrAcquisitionMode) || !IsWritable(ptrAcquisitionMode)){
Expand Down Expand Up @@ -197,18 +179,30 @@ int SpinnakerCapture::acquireImages(unsigned int nImagesToCapture)
// name a few.
//

ImagePtr convertedImage = pResultImage->Convert(PixelFormat_BGR8, NEAREST_NEIGHBOR);
ImagePtr convertedImage = pResultImage->Convert(pixelFormat, NEAREST_NEIGHBOR);

unsigned int XPadding = convertedImage->GetXPadding();
unsigned int YPadding = convertedImage->GetYPadding();
unsigned int rowsize = convertedImage->GetWidth();
unsigned int colsize = convertedImage->GetHeight();

//image data contains padding. When allocating Mat container size, you need to account for the X,Y image data padding.
cv::Mat cvMat = cv::Mat(colsize + YPadding, rowsize + XPadding, CV_8UC3, convertedImage->GetData(), convertedImage->GetStride());

emit(sendFrame(cvMat.clone()));
int cvFormat;
switch(pixelFormat){
case PixelFormat_BGR8:
cvFormat = CV_8UC3;
break;
case PixelFormat_Mono16:
cvFormat = CV_16U;
break;
default:
cvFormat = CV_8UC3;
}

cv::Mat cvMat = cv::Mat(colsize + YPadding, rowsize + XPadding, cvFormat, convertedImage->GetData(), convertedImage->GetStride());

emit(sendFrame(cvMat.clone()));
}

// Images retrieved directly from the camera (i.e. non-converted
Expand Down Expand Up @@ -278,11 +272,11 @@ SpinnakerCapture::~SpinnakerCapture()
{
// Deinitialize camera
pCam->DeInit();
delete nodeMapTLDevice;
delete nodeMap;
pCam = NULL;
nodeMapTLDevice = NULL;
nodeMap = NULL;
// Clear camera list before releasing system
camList.Clear();
// // Release system
// Release system
system->ReleaseInstance();
}

2 changes: 2 additions & 0 deletions SpinnakerCapture.h
Expand Up @@ -20,6 +20,8 @@ class SpinnakerCapture : public QObject
bool isInitialized = false;
unsigned int width = 0;
unsigned int height = 0;
float exposureTime = 0;
PixelFormatEnums pixelFormat = PixelFormat_Mono16; //PixelFormat_BGR8
~SpinnakerCapture();
private:
CameraPtr pCam;
Expand Down

0 comments on commit 33f4a79

Please sign in to comment.