27 #include <Base/Common/W32Compat.hh>
34 #include "VideoSource_DcamPMD.hh"
35 #include <Base/Image/ImageIO.hh>
36 #include <Image/Camera.hh>
38 #include <Base/Common/BIASpragma.hh>
39 #include <Base/Common/FileHandling.hh>
63 if (pmdConnectFireWire(&handle_) != PMD_OK) {
64 BIASERR(
"Connection of PMD-Camera via FireWire failed!");
67 unsigned int width, height;
68 if (pmdGetWidth(handle_, &width) != PMD_OK) {
69 BIASERR(
"Error in pmdGetWidth!");
72 if (pmdGetHeight(handle_, &height) != PMD_OK) {
73 BIASERR(
"Error in pmdGetWith!");
76 if (pmdGetPixelOrigin(handle_, &pixori_) != PMD_OK) {
77 BIASERR(
"Error in pmdGetPixelOrigin!");
94 if (pmdDisconnect(handle_) != PMD_OK) {
95 BIASERR(
"Disonnection of PMD-Camera via FireWire failed!");
116 BIASERR(
"VideoSource::InitImage() should be called with uninitialized image");
124 return pmdSetIntegrationTime(handle_, dIntegrationTime);
128 unsigned int time =0;
129 int ret = pmdGetIntegrationTime(handle_,&time);
137 return pmdSetModulationFrequency(handle_, dModulationFrequency);
142 unsigned int frequency =0;
143 int ret = pmdGetModulationFrequency(handle_,&frequency);
145 return (
int)frequency;
154 BIASERR(
"Setting gain not supported for PMD cam");
160 BIASERR(
"Setting shutter not supported for PMD cam");
165 BIASERR(
"Getting shutter not supported for PMD cam");
170 BIASERR(
"Getting gain not supported for PMD cam");
178 if ((res=pmdUpdate(handle_)) != PMD_OK) {
179 BIASERR(
"Error in pmdUpdate! Error: " << res);
184 if ((res=pmdGetIntensities(handle_, (
void**)&data)) != PMD_OK) {
185 BIASERR(
"Error in pmdGetIntensities! Error: " << res);
188 ImageUcharFromDouble_(data, image);
191 gettimeofday(&tv, NULL);
192 image.
SetTime(tv.tv_sec,tv.tv_usec);
194 if ((res=pmdGetDistances(handle_, (
void**)&data)) != PMD_OK) {
195 BIASERR(
"Error in pmdGetDistances! Error: " << res);
198 ImageFloatFromDouble_(data, DepthImg_);
199 DepthImg_.SetUID(image.
GetUID());
201 if ((res=pmdGetAmplitudes(handle_, (
void**)&data)) != PMD_OK) {
202 BIASERR(
"Error in pmdGetAmplitudes! Error: " << res);
205 ImageFloatFromDouble_(data, ModCoeffImg_);
206 ModCoeffImg_.SetUID(image.
GetUID());
214 if (pmdGetInternalFrameRate(handle_, fps) != PMD_OK) {
215 BIASERR(
"Error in pmdGetInternalFrameRate!");
229 double min = DBL_MAX;
230 double max = DBL_MIN;
232 if (*pus<min) min = *pus;
233 if (*pus>max) max = *pus;
238 unsigned char* pucrow;
239 for (
unsigned int x=0; x<dst.
GetHeight(); x++) {
241 case 1: pucrow=puc[x];
break;
242 case 2: pucrow=puc[x]+dst.
GetWidth()-1;
break;
243 case 3: pucrow=puc[dst.
GetHeight()-x];
break;
245 default: BIASERR(
"Unknown Pixel Origin"); BIASABORT;
247 for (
unsigned int y=0; y<dst.
GetWidth(); y++) {
248 (*pucrow) = (
unsigned char)((
double)((*pus)-min)/(
double)(max-min)*255.0);
251 case 3: pucrow++;
break;
253 case 4: pucrow--;
break;
254 default: BIASERR(
"Unknown Pixel Origin"); BIASABORT;
271 for (
unsigned int x=0; x<dst.
GetHeight(); x++) {
273 case 1: pucrow=puc[x];
break;
274 case 2: pucrow=puc[x]+dst.
GetWidth()-1;
break;
275 case 3: pucrow=puc[dst.
GetHeight()-x];
break;
277 default: BIASERR(
"Unknown Pixel Origin"); BIASABORT;
279 for (
unsigned int y=0; y<dst.
GetWidth(); y++) {
280 (*pucrow) = (float)(*pus);
283 case 3: pucrow++;
break;
285 case 4: pucrow--;
break;
286 default: BIASERR(
"Unknown Pixel Origin"); BIASABORT;
virtual int GrabSingle(Camera< unsigned char > &image)
Returns the 2D image, and reads depth and modulation coefficients.
virtual void SetSize(int w, int h, int bytesperpixel=1)
Set image size and number of bytes per pixel (e.g.
(16bit) unsigned integer image storage type
Defines a common interface to different devices.
virtual int PostGrab()
Stop anything started in PreGrab()
virtual int SetShutter(float exptime)
Set shutter (exposure time) to exptime in seconds.
bool IsEmpty() const
check if ImageData_ points to allocated image buffer or not
double GetFPS()
Returns current framerate.
void SetColorModel(EColorModel Model)
unsigned int GetWidth() const
void ImageFloatFromDouble_(double *data, Image< float > &dst)
virtual int SetGain(float g)
Set gain to g with g[dB].
virtual int OpenDevice()
selects the first available device to open (e.g.
const BIAS::UUID & GetUID() const
returns the UUID of the image
virtual int SetColorModel(BIAS::ImageBase::EColorModel mode)
Select colormodel to use.
virtual float GetShutter()
Get shutter (exposure time) in seconds.
void ImageUcharFromDouble_(double *data, Image< unsigned char > &dst)
unsigned int GetHeight() const
virtual float GetGain()
Get gain in dB.
void Init(unsigned int Width, unsigned int Height, unsigned int channels=1, enum EStorageType storageType=ST_unsignedchar, const bool interleaved=true)
calls Init from ImageBase storageType is ignored, just dummy argument
int SetIntegrationTime(int dIntegrationTime)
void Init(unsigned int width, unsigned int height, unsigned int nChannels=1, enum EStorageType storageType=ST_unsignedchar, const bool interleaved=true)
Initialize image size and channels.
virtual int CloseDevice()
virtual int PreGrab()
Do last preparations before grabbing (e.g. start ISO transfer)
(8bit) unsigned char image storage type
int GetModulationFrequency()
void SetTime(unsigned long long int sec, unsigned long long int usec)
Set time and ensure correct format (seconds and useconds after 'sec')
This is the base class for images in BIAS.
virtual int InitImage(ImageBase &img)
int SetModulationFrequency(int dModulationFrequency)
const StorageType ** GetImageDataArray() const
overloaded GetImageDataArray() from ImageBase