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);
173 bool grab(
const GrabMode mode,
const int buffer_len);
174 bool retrieveFrame(base::samples::frame::Frame &frame,
const int timeout);
176 const base::samples::frame::frame_mode_t mode,
177 const uint8_t color_depth,
178 const bool resize_frames);
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);
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);
198 base::samples::frame::frame_mode_t &mode,
199 uint8_t &color_depth);
203 bool setCallbackFcn(
void (*pcallback_function)(
const void* p),
void *p);
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
bool setCallbackFcn(void(*pcallback_function)(const void *p), void *p)
Definition: CamGigEProsilica.cpp:112
tPvFrame frame
Definition: CamGigEProsilica.h:23
void synchronizeWithSystemTime(uint32_t time_interval)
Definition: CamGigEProsilica.cpp:1023
void loadConfiguration(uint8_t index)
Definition: CamGigEProsilica.cpp:972
bool isAttribSet(const enum_attrib::CamAttrib attrib)
Definition: CamGigEProsilica.cpp:884
bool setAttrib(const int_attrib::CamAttrib attrib, const int value)
Definition: CamGigEProsilica.cpp:709
void saveConfiguration(uint8_t index)
Definition: CamGigEProsilica.cpp:964
int listCameras(std::vector< CamInfo > &cam_infos) const
Definition: CamGigEProsilica.cpp:78
bool getFrameSettings(base::samples::frame::frame_size_t &size, base::samples::frame::frame_mode_t &mode, uint8_t &color_depth)
Definition: CamGigEProsilica.cpp:939
bool isAttribAvail(const int_attrib::CamAttrib attrib)
Definition: CamGigEProsilica.cpp:773
void callUserCallbackFcn() const
Definition: CamGigEProsilica.cpp:125
Definition: CamGigEProsilica.h:145
bool triggerFrame()
Definition: CamGigEProsilica.cpp:929
bool isFrameAvailable()
Definition: CamGigEProsilica.cpp:335
bool retrieveFrame(base::samples::frame::Frame &frame, const int timeout)
Definition: CamGigEProsilica.cpp:363
bool setFrameSettings(const base::samples::frame::frame_size_t size, const base::samples::frame::frame_mode_t mode, const uint8_t color_depth, const bool resize_frames)
Definition: CamGigEProsilica.cpp:568
void resize(int frame_size_in_byte)
Definition: CamGigEProsilica.h:128
int skipFrames()
Definition: CamGigEProsilica.cpp:342
void swap(base::samples::frame::Frame &other)
Definition: CamGigEProsilica.h:32
int getAttrib(const int_attrib::CamAttrib attrib)
Definition: CamGigEProsilica.cpp:845
base::Time timestamp_received
Definition: CamGigEProsilica.h:24
bool close()
Definition: CamGigEProsilica.cpp:427
Definition: CamGigEProsilica.h:18
const CamInfo * getCameraInfo() const
Definition: CamGigEProsilica.cpp:130
bool isOpen() const
Definition: CamGigEProsilica.cpp:271
bool grab(const GrabMode mode, const int buffer_len)
Definition: CamGigEProsilica.cpp:278
CamGigEProsilica(uint32_t max_package_size=16110)
Definition: CamGigEProsilica.cpp:35
void getRange(const double_attrib::CamAttrib attrib, double &dmin, double &dmax)
Definition: CamGigEProsilica.cpp:903
bool open(const CamInfo &cam, const AccessMode mode)
Definition: CamGigEProsilica.cpp:165
~CamGigEProsilica()
Definition: CamGigEProsilica.cpp:66