2 #include <Image/Camera.hh>
3 #include <Base/Image/ImageConvert.hh>
4 #include <Base/Image/ImageIO.hh>
5 #include <VideoSource/VideoSource_DCAM.hh>
7 #include <Gui/GuiCV.hh>
10 # include<Base/Common/getopt_W32.h>
21 #ifdef BUILD_IMAGE_USHORT
22 #define StorageType unsigned char
24 #include <Base/Debug/TimeMeasure.hh>
26 float rgain=-31.0/32.0, bgain=31.0/32.0;
28 unsigned savecounter=0;
32 unsigned int shift = 0)
38 for (
unsigned int i=0;i<pc; i++) {
40 if (t> 255) uc[i] = 255;
41 else uc[i] = (
unsigned char)(t & 255);
55 unsigned int shift = 2;
57 bool color, pause, autosave=
false;
64 sprintf(title,
"MyWindow");
83 gettimeofday(&now, NULL);
85 start = (now.tv_sec % 1000) * 1000 + (now.tv_usec / 1000);
86 fps = 1.0f / (float)(start-end) * 1000.0f;
95 cam->
AutoMode(DC1394_FEATURE_GAIN,DC1394_FEATURE_MODE_AUTO);
96 cerr <<
"\nauto gain on"<<endl;
99 cout <<endl<<
"Shutter: "<<cam->
GetShutter()<<endl;
104 cerr <<
"\nwhite balance"<<endl;
113 cerr <<
"\nstarted saving sequence at frame "<<i<<
" into frame"
114 <<setfill(
'0')<<setw(5)<<savecounter<<
".mip"<<endl;
116 cerr <<
"\nstopped saving sequence at frame "<<i<<
" into frame"
117 <<setfill(
'0')<<setw(5)<<savecounter<<
".mip"<<endl;
124 if (color) cerr <<
"\nshowing color image" << endl;
125 else cerr <<
"\nshowing grey image" << endl;
128 cam->
AutoMode(DC1394_FEATURE_GAIN,DC1394_FEATURE_MODE_MANUAL);
129 cerr <<
"\nauto gain off"<<endl;
132 if (shift >0) shift--;
133 cout <<endl<<
"shift: "<<shift<<endl;
136 if (shift <4) shift++;
137 cout <<endl<<
"shift: "<<shift<<endl;
142 cout<<
"Overall gain :"<<gain<<endl;
147 cout<<
"Overall gain :"<<gain<<endl;
150 if (c!=-1) cerr <<
"unknown key "<<c<<endl;
158 unsigned short min, max;
160 cout <<
"min: "<<min<<
"\tmax: "<<max<<
" "<<endl;
162 Get8bitsfrom16(pic,pic1,shift);
169 os <<
"frame" << setfill(
'0') << setw(5) << savecounter;
176 cerr <<
"\nsaved frame "<<i<<
" in "<<os.str()<<endl;
188 os <<
"frame" << setfill(
'0') << setw(5) << savecounter;
191 BIASERR(
"error saving frame "<<i<<
" at file "<<os.str()<<
".mip");
198 cout <<
"Frame: "<<i<<
" Showing fps: "<<fps<<
"\r";
212 int main(
int argc,
char *argv[])
229 cout <<
"Openresult: "<<res<<endl;
232 cerr<<
" Can not open camera"<<endl;
238 cout <<
" g : Auto Gain ON\n";
239 cout <<
" G : Auto Gain OFF\n";
240 cout <<
"123 : Gamma mode"<<endl;
241 cout <<
" w : OnePushWhitebalance (not for PointGrey DragonFly)\n";
242 cout <<
" 7/8: decr/incr blue gain (for white balancing manual)\n";
243 cout <<
" 4/5: decr/incr red gain (for white balancing manual)\n";
244 cout <<
" c : Color/Grey \n";
245 cout <<
"SPC : save an image \n";
246 cout <<
" s : save sequence\n";
247 cout <<
" p : Stop/Resume\n";
248 cout <<
" e : toggle between fast and normal conversion\n";
249 cout <<
" q : Quit \n";
265 int main(
int argc,
char *argv[])
267 BIASERR(
"showdcam16 can only work if BIAS was compiled with BUILD_IMAGE_USHORT");
virtual int InitImage(BIAS::ImageBase &Image)
virtual void SetTitle(std::string const &Title)
int GrabSingle(BIAS::Camera< unsigned char > &image)
Select the port (bus-id) to use, only valid before OpenDevice()
void SetColorModel(EColorModel Model)
Bayer_RGGB, 1 channel RGB image Bayer tile.
Gui based on OpenCV is a simple windowing environment...
This class VideoSource_DCAM implements access to IEEE1394 (Firewire, iLink) cameras following the DCa...
int SetGain(float g)
set value for gain
void GetMinMaxPixelValue(StorageType &min, StorageType &max, unsigned short int channel=0, unsigned int *mincoo=NULL, unsigned int *maxcoo=NULL) const
returns the minimal and maximal pixel value in channel only Finds minimum and maximum pixel value in ...
int OpenDevice()
Opens a dc1394 device.
unsigned int GetWidth() const
void SetBytesPerPixel(unsigned char bpp)
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
void SetDebugLevel(const long int lv)
unsigned int GetHeight() const
int AutoMode(dc1394feature_t feature, dc1394feature_mode_t mode)
Set a camera feature to auto or to manual mode.
The image template class for specific storage types.
static int Save(const std::string &filename, const ImageBase &img, const enum TFileFormat FileFormat=FF_auto, const bool sync=BIAS_DEFAULT_SYNC, const int c_jpeg_quality=BIAS_DEFAULT_IMAGE_QUALITY, const bool forceNewID=BIAS_DEFAULT_FORCENEWID, const bool &writeMetaData=true)
Export image as file using extrnal libs.
int OnePushAuto(dc1394feature_t feature)
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
const StorageType * GetImageData() const
overloaded GetImageData() from ImageBase
int CloseDevice()
closes a camera device and cleans up
int PostGrab()
stops iso transmission of a camera.
int PreGrab()
initializes the iso transmission of a camera.
unsigned long int GetPixelCount() const
returns number of pixels in image
virtual int ShowImage(ImageBase &image, float min=0.0, float max=255.0)
shows/updates the image shown in window.
virtual char CheckForKeyEvent()
checks if any key is pressed and returns it returns -1 if no key is pressed
class TimeMeasure contains functions for timing real time and cpu time.
float GetShutter()
get the value of the shutter feature