8 #ifndef _CAMGIGEPROSILICA_H 9 #define _CAMGIGEPROSILICA_H 11 #include <camera_interface/CamInterface.h> 21 std::vector<uint8_t> data;
28 resize(frame_size_in_byte);
32 inline void swap(base::samples::frame::Frame &other)
34 if(data.size() != other.image.size())
35 throw std::runtime_error(
"Frame size mismatch. " 36 " Can not swap data.");
37 other.image.swap(data);
38 frame.ImageBuffer = &data[0];
40 other.attributes.clear();
41 if(frame.Status == ePvErrSuccess)
42 other.setStatus(base::samples::frame::STATUS_VALID);
44 other.setStatus(base::samples::frame::STATUS_INVALID);
48 other.setAttribute<uint16_t>(
"FrameCount",frame.FrameCount);
57 switch (frame.BayerPattern)
60 if(other.getFrameMode() != base::samples::frame::MODE_BAYER_RGGB)
62 if(other.getFrameMode() == base::samples::frame::MODE_BAYER)
63 other.frame_mode = base::samples::frame::MODE_BAYER_RGGB;
65 throw std::runtime_error(
"Bayer Pattern is MODE_BAYER_RGGB but frame has a " 66 "different format. Use MODE_BAYER if you want to use auto discover.");
71 if(other.getFrameMode() != base::samples::frame::MODE_BAYER_GBRG)
73 if(other.getFrameMode() == base::samples::frame::MODE_BAYER)
74 other.frame_mode = base::samples::frame::MODE_BAYER_GBRG;
76 throw std::runtime_error(
"Bayer Pattern is MODE_BAYER_GBRG but frame has a " 77 "different format. Use MODE_BAYER if you want to use auto discover.");
82 if(other.getFrameMode() != base::samples::frame::MODE_BAYER_GRBG)
84 if(other.getFrameMode() == base::samples::frame::MODE_BAYER)
85 other.frame_mode = base::samples::frame::MODE_BAYER_GRBG;
87 throw std::runtime_error(
"Bayer Pattern is MODE_BAYER_GRBG but frame has a " 88 "different format. Use MODE_BAYER if you want to use auto discover.");
93 if(other.getFrameMode() != base::samples::frame::MODE_BAYER_BGGR)
95 if(other.getFrameMode() == base::samples::frame::MODE_BAYER)
96 other.frame_mode = base::samples::frame::MODE_BAYER_BGGR;
98 throw std::runtime_error(
"Bayer Pattern is MODE_BAYER_BGGR but frame has a " 99 "different format. Use MODE_BAYER if you want to use auto discover.");
104 throw std::runtime_error(
"Unknown Bayer Patter");
110 if(other.getFrameMode() != base::samples::frame::MODE_GRAYSCALE)
111 throw std::runtime_error(
"Color format is MONO but frame has a different format.");
116 if(other.getFrameMode() != base::samples::frame::MODE_RGB)
117 throw std::runtime_error(
"Color format is RGB but frame has a different format.");
122 if(other.getFrameMode() != base::samples::frame::MODE_UNDEFINED)
123 throw std::runtime_error(
"Unknown frame color format!!!");
128 inline void resize(
int frame_size_in_byte)
130 data.resize(frame_size_in_byte);
131 frame.ImageBuffer = &data[0];
132 frame.ImageBufferSize = frame_size_in_byte;
133 frame.AncillaryBuffer = NULL;
141 frame.AncillaryBufferSize = 0;
148 tPvHandle camera_handle_;
150 static int instance_count_;
151 std::list<ProFrame*> frame_queue_;
152 int frame_size_in_byte_;
153 AccessMode access_mode_;
154 void (*pcallback_function_)(
const void* p);
155 void *pass_through_pointer_;
156 double timestamp_factor;
157 uint64_t timestamp_offset_camera_system;
159 uint32_t max_package_size_t;
166 int listCameras(std::vector<CamInfo>&cam_infos)
const;
167 bool open(
const CamInfo &cam,
const AccessMode mode);
168 bool open(
const std::string &ip,
const AccessMode mode);
171 const CamInfo *getCameraInfo()
const;
173 bool grab(
const GrabMode mode,
const int buffer_len);
174 bool retrieveFrame(base::samples::frame::Frame &
frame,
const int timeout);
175 bool setFrameSettings(
const base::samples::frame::frame_size_t size,
176 const base::samples::frame::frame_mode_t mode,
177 const uint8_t color_depth,
178 const bool resize_frames);
179 bool isFrameAvailable();
182 bool setAttrib(
const int_attrib::CamAttrib attrib,
const int value);
183 bool setAttrib(
const double_attrib::CamAttrib attrib,
const double value);
184 bool setAttrib(
const enum_attrib::CamAttrib attrib);
185 bool setAttrib(
const str_attrib::CamAttrib attrib,
const std::string &
string);
187 bool isAttribAvail(
const int_attrib::CamAttrib attrib);
188 bool isAttribAvail(
const str_attrib::CamAttrib attrib);
189 bool isAttribAvail(
const double_attrib::CamAttrib attrib);
190 bool isAttribAvail(
const enum_attrib::CamAttrib attrib);
192 int getAttrib(
const int_attrib::CamAttrib attrib);
193 double getAttrib(
const double_attrib::CamAttrib attrib);
194 std::string getAttrib(
const str_attrib::CamAttrib attrib);
195 bool isAttribSet(
const enum_attrib::CamAttrib attrib);
197 bool getFrameSettings(base::samples::frame::frame_size_t &size,
198 base::samples::frame::frame_mode_t &mode,
199 uint8_t &color_depth);
203 bool setCallbackFcn(
void (*pcallback_function)(
const void* p),
void *p);
204 void callUserCallbackFcn()
const;
205 void synchronizeWithSystemTime(uint32_t time_interval);
206 void saveConfiguration(uint8_t index);
207 void loadConfiguration(uint8_t index);
209 void getRange(
const double_attrib::CamAttrib attrib,
double &dmin,
double &dmax);
210 void getRange(
const int_attrib::CamAttrib attrib,
int &imin,
int &imax);
214 void copy_tPvCameraInfo_To_tCamInfo
215 (
const tPvCameraInfo& source, CamInfo& dest)
const;
216 bool fillCameraIpSettings(CamInfo& cam)
const;
217 bool prepareQueueForGrabbing(
const int queue_len);
218 inline bool isFrameQueued(
const ProFrame* frame);
219 inline bool queueFrame(
ProFrame* frame);
220 static void callBack(tPvFrame * frame);
221 static void callBack2(tPvFrame * frame);
223 void checkCameraStatus()
const;
224 void setConfigFileIndex(uint8_t index);
ProFrame(int frame_size_in_byte)
Definition: CamGigEProsilica.h:26
tPvFrame frame
Definition: CamGigEProsilica.h:23
Definition: CamGigEProsilica.cpp:31
Definition: CamGigEProsilica.h:145
void resize(int frame_size_in_byte)
Definition: CamGigEProsilica.h:128
void swap(base::samples::frame::Frame &other)
Definition: CamGigEProsilica.h:32
base::Time timestamp_received
Definition: CamGigEProsilica.h:24
Definition: CamGigEProsilica.h:18