diff --git a/src/bumblebee.cpp b/src/bumblebee.cpp index 27bcd0b2357c0151235701f45f6e3e2c7f33b886..0ced744e34499723205850980ecee36ce99a88bc 100755 --- a/src/bumblebee.cpp +++ b/src/bumblebee.cpp @@ -44,6 +44,9 @@ void CBumblebee::set_config(unsigned int *left_off,unsigned int *top_off,unsigne uint64_t total_bytes; dc1394color_coding_t dc1394_coding; dc1394error_t error; + uint32_t min_bpp; + uint32_t max_bpp; + unsigned int bpp; // set the operation mode @@ -56,13 +59,36 @@ void CBumblebee::set_config(unsigned int *left_off,unsigned int *top_off,unsigne this->mode=DC1394_VIDEO_MODE_FORMAT7_3; // configure the camera if(coding==MONO) + { + this->coding=MONO; dc1394_coding=DC1394_COLOR_CODING_MONO16; + } else + { + this->coding=RAW; dc1394_coding=DC1394_COLOR_CODING_RAW16; + } + + // compute the desired frame rate + total_bytes=(*width)*(*height)*((int)DEPTH16/8); + error = dc1394_format7_get_packet_parameters(this->camera_handle,this->mode,&min_bpp,&max_bpp); + if ( error != DC1394_SUCCESS ) + { + DEBUG_INFO("failed.\n"); + /* handle the error */ + throw CFirewireInternalException(_HERE_,error); + } + bpp=(int)((*framerate)*total_bytes/(this->iso_rate*2)); + if(bpp<min_bpp || bpp>max_bpp) + { + DEBUG_INFO("failed.\n"); + /* handle exception */ + throw CFirewireCameraException(_HERE_,"Unsupported packet size. Please change the desired framerate."); + } error=dc1394_format7_set_roi(this->camera_handle, this->mode, dc1394_coding, - DC1394_USE_MAX_AVAIL, + bpp,//DC1394_USE_MAX_AVAIL, 0, 0, *width, @@ -72,12 +98,11 @@ void CBumblebee::set_config(unsigned int *left_off,unsigned int *top_off,unsigne // handle exceptions throw CFirewireInternalException(_HERE_,error); } - this->left_offset=*left_off; - this->top_offset=*top_off; + this->left_offset=0; + this->top_offset=0; this->width=*width; this->height=*height; - this->coding=coding; - this->depth=depth; + this->depth=DEPTH16; // compute the actual framerate error = dc1394_format7_get_total_bytes(this->camera_handle,this->mode,&total_bytes); if ( error != DC1394_SUCCESS ) @@ -97,6 +122,15 @@ void CBumblebee::set_config(unsigned int *left_off,unsigned int *top_off,unsigne this->set_num_DMA_buffers(4); } +void CBumblebee::get_stereo_config(unsigned int *width,unsigned int *height, float *framerate, depths_t *depth, codings_t *coding) +{ + (*width)=this->width; + (*height)=this->height; + (*framerate)=this->framerate; + (*depth)=this->stereo_depth; + (*coding)=this->stereo_coding; +} + void CBumblebee::get_stereo_image(char **left,char **right) { int depth; @@ -142,7 +176,7 @@ void CBumblebee::get_stereo_image(char **left,char **right) if(this->stereo_coding==RGB) { depth = (int)ceil((float)this->stereo_depth/8.0); - RGB_image=new unsigned char[this->width*this->height*depth]; + RGB_image=new unsigned char[this->width*2*this->height*depth]; // extract color from the bayer tile image // note: this will alias colors on the top and bottom rows dc1394_bayer_decoding_8bit( de_interleaved, @@ -197,7 +231,7 @@ void CBumblebee::get_stereo_image(char **left,char **right) if(this->stereo_coding==RGB) { depth = (int)ceil((float)this->stereo_depth/8.0); - RGB_image=new unsigned char[this->width*this->height*depth]; + RGB_image=new unsigned char[this->width*2*this->height*depth]; // extract color from the bayer tile image // note: this will alias colors on the top and bottom rows dc1394_bayer_decoding_8bit( de_interleaved, diff --git a/src/bumblebee.h b/src/bumblebee.h index d3663daa958fc5c32e8785813398f8e958434f91..b7b9c598cabc424c9e52c75c82a227613a359dfd 100755 --- a/src/bumblebee.h +++ b/src/bumblebee.h @@ -34,6 +34,11 @@ class CBumblebee : public CPTGCamera */ void set_config(unsigned int *left_off,unsigned int *top_off,unsigned int *width,unsigned int *height, float *framerate, depths_t depth, codings_t coding); // stereo camera operation functions + /** + * \brief + * + */ + void get_stereo_config(unsigned int *width,unsigned int *height, float *framerate, depths_t *depth, codings_t *coding); /** * \brief * diff --git a/src/examples/bumblebee.cpp b/src/examples/bumblebee.cpp index afe0d15e8c68aa8d7f7bf93d58556be27351b3a1..982fc0fa45a2901f0173cbe5d33fe107de08ba42 100755 --- a/src/examples/bumblebee.cpp +++ b/src/examples/bumblebee.cpp @@ -7,7 +7,7 @@ #include <sstream> #include <iostream> -const int num_frames=100; +const int num_frames=10; int main(int argc, char *argv[]) { @@ -24,8 +24,7 @@ int main(int argc, char *argv[]) char *left=NULL,*right=NULL; std::string new_frame,filename; std::stringstream text; - uint64_t guid=0x0000b09d01006b6fb5; -// uint64_t guid=0x00B09D01007D6D85LL; + //uint64_t guid=0x0000b09d01006b6fb5; std::list<std::string> events; try @@ -36,13 +35,16 @@ int main(int argc, char *argv[]) server->init(); std::cout << "Num. Cam. : " << server->get_num_cameras() << std::endl; /* get the new camera with index 0 */ - /* get the new camera with guid = 0x00B09D01007D6D85 */ -// server->get_pgr_stereo_camera_guid(guid,&camera1); server->get_bumblebee_camera(0,&bumblebee); /* get the reference to the event server */ event_server=CEventServer::instance(); bumblebee->get_config(&left_off,&top_off,&width,&height,&framerate,&depth,&coding); + framerate=20; + bumblebee->set_config(&left_off,&top_off,&width,&height,&framerate,depth,coding); + bumblebee->get_stereo_config(&width,&height,&framerate,&depth,&coding); + std::cout << "Image size: " << width << "x" << height << std::endl; std::cout << "Fremerate: " << framerate << std::endl; + std::cout << "Color coding: " << (int)coding << "-" << (int)depth << std::endl; bumblebee->get_new_frame_event_id(new_frame); events.push_back(new_frame); bumblebee->start(); diff --git a/src/examples/firewire_camera_cont.cpp b/src/examples/firewire_camera_cont.cpp index 47c58cbff807abc4dd2be9a15eba59b6b9927d93..e8fca35c7c3a3e12d57a572a1e8d568fffcdd4c8 100644 --- a/src/examples/firewire_camera_cont.cpp +++ b/src/examples/firewire_camera_cont.cpp @@ -45,8 +45,6 @@ int main(int argc, char *argv[]) event_list.push_back(new_frame); /* configure the camera */ camera1->get_config(&left_off,&top_off,&width,&height,&framerate,&depth,&coding); - framerate=3.75; - height=4608; camera1->set_config(&left_off,&top_off,&width,&height,&framerate,depth,coding); std::cout << framerate << std::endl; /* start continuous acquisition */ diff --git a/src/examples/ladybug.cpp b/src/examples/ladybug.cpp index e0476451133e1796e17a1ea926253180195c1164..965fe9cb4937846bfba78e2b24e0f0f00413fc40 100755 --- a/src/examples/ladybug.cpp +++ b/src/examples/ladybug.cpp @@ -44,7 +44,7 @@ int main(int argc, char *argv[]) ladybug->get_config(&left_off,&top_off,&width,&height,&framerate,&depth,&coding); std::cout << "Fremerate: " << framerate << std::endl; // coding=MONO; - framerate=30; + framerate=10; ladybug->set_config(&left_off,&top_off,&width,&height,&framerate,depth,coding); ladybug->get_new_frame_event_id(new_frame); events.push_back(new_frame);