Skip to content

Commit

Permalink
cache params instead of asking for them during acquisition
Browse files Browse the repository at this point in the history
  • Loading branch information
Chao Qu committed Sep 11, 2014
1 parent e93f816 commit 0cfac9c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 20 deletions.
7 changes: 7 additions & 0 deletions include/flir_gige/flir_gige.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class FlirGige {
void OpenStream();
void ConfigureStream();
void CreatePipeline();
void CacheParams();

void SetAoi(int *width, int *height) const;
void SetPixelFormat(bool raw) const;
Expand All @@ -75,6 +76,12 @@ class FlirGige {
PvStreamPtr stream_;
PvPipelinePtr pipeline_;
PvGenParameterArray *param_array_;
struct {
int height;
int width;
double B, F, O, R;
int bit;
} cache_;
};

} // namespace flir_gige
Expand Down
52 changes: 32 additions & 20 deletions src/flir_gige/flir_gige.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ void FlirGige::StartAcquisition() {
pipeline_->Start();
device_->StreamEnable();
param_array_->ExecuteCommand("AcquisitionStart");
CacheParams();
}

void FlirGige::StopAcquisition() {
Expand Down Expand Up @@ -208,29 +209,16 @@ bool FlirGige::GrabImage(sensor_msgs::Image &image_msg,
PvImage *image = buffer->GetImage();

// Get device parameters need to control streaming
int64_t width, height;
param_array_->GetIntegerValue("Width", width);
param_array_->GetIntegerValue("Height", height);

int64_t bit;
param_array_->GetEnumValue("DigitalOutput", bit);

int64_t R;
double F, B, O;
param_array_->GetIntegerValue("R", R);
param_array_->GetFloatValue("F", F);
param_array_->GetFloatValue("B", B);
param_array_->GetFloatValue("O", O);
// Assemble cinfo msg
cinfo_msg.R[0] = B;
cinfo_msg.R[1] = F;
cinfo_msg.R[2] = O;
cinfo_msg.R[3] = R;
cinfo_msg.R[0] = cache_.B;
cinfo_msg.R[1] = cache_.F;
cinfo_msg.R[2] = cache_.O;
cinfo_msg.R[3] = cache_.R;

// Assemble image msg
image_msg.height = height;
image_msg.width = width;
if (bit == 2) {
image_msg.height = cache_.height;
image_msg.width = cache_.width;
if (cache_.bit == 2) {
image_msg.encoding = sensor_msgs::image_encodings::MONO8;
image_msg.step = image_msg.width;
} else {
Expand All @@ -249,6 +237,30 @@ bool FlirGige::GrabImage(sensor_msgs::Image &image_msg,
return true;
}

void FlirGige::CacheParams() {
int64_t width, height;
param_array_->GetIntegerValue("Width", width);
param_array_->GetIntegerValue("Height", height);

int64_t bit;
param_array_->GetEnumValue("DigitalOutput", bit);

int64_t R;
double F, B, O;
param_array_->GetIntegerValue("R", R);
param_array_->GetFloatValue("F", F);
param_array_->GetFloatValue("B", B);
param_array_->GetFloatValue("O", O);

cache_.B = B;
cache_.F = F;
cache_.O = O;
cache_.R = R;
cache_.height = height;
cache_.width = width;
cache_.bit = bit;
}

bool FlirGige::GrabTemprature(sensor_msgs::Temperature &temp_msg) {
temp_msg.variance = 0;
return param_array_->GetFloatValue("Spot", temp_msg.temperature).IsOK();
Expand Down

0 comments on commit 0cfac9c

Please sign in to comment.