Skip to content
Snippets Groups Projects
Commit 977d2350 authored by Sergi Hernandez's avatar Sergi Hernandez
Browse files

Solved some bugs in the bumblebee driver.

Added the possibility to change the framerate in the bumblebee camera.
parent 7cc92aae
No related branches found
No related tags found
No related merge requests found
...@@ -44,6 +44,9 @@ void CBumblebee::set_config(unsigned int *left_off,unsigned int *top_off,unsigne ...@@ -44,6 +44,9 @@ void CBumblebee::set_config(unsigned int *left_off,unsigned int *top_off,unsigne
uint64_t total_bytes; uint64_t total_bytes;
dc1394color_coding_t dc1394_coding; dc1394color_coding_t dc1394_coding;
dc1394error_t error; dc1394error_t error;
uint32_t min_bpp;
uint32_t max_bpp;
unsigned int bpp; unsigned int bpp;
// set the operation mode // set the operation mode
...@@ -56,13 +59,36 @@ void CBumblebee::set_config(unsigned int *left_off,unsigned int *top_off,unsigne ...@@ -56,13 +59,36 @@ void CBumblebee::set_config(unsigned int *left_off,unsigned int *top_off,unsigne
this->mode=DC1394_VIDEO_MODE_FORMAT7_3; this->mode=DC1394_VIDEO_MODE_FORMAT7_3;
// configure the camera // configure the camera
if(coding==MONO) if(coding==MONO)
{
this->coding=MONO;
dc1394_coding=DC1394_COLOR_CODING_MONO16; dc1394_coding=DC1394_COLOR_CODING_MONO16;
}
else else
{
this->coding=RAW;
dc1394_coding=DC1394_COLOR_CODING_RAW16; 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, error=dc1394_format7_set_roi(this->camera_handle,
this->mode, this->mode,
dc1394_coding, dc1394_coding,
DC1394_USE_MAX_AVAIL, bpp,//DC1394_USE_MAX_AVAIL,
0, 0,
0, 0,
*width, *width,
...@@ -72,12 +98,11 @@ void CBumblebee::set_config(unsigned int *left_off,unsigned int *top_off,unsigne ...@@ -72,12 +98,11 @@ void CBumblebee::set_config(unsigned int *left_off,unsigned int *top_off,unsigne
// handle exceptions // handle exceptions
throw CFirewireInternalException(_HERE_,error); throw CFirewireInternalException(_HERE_,error);
} }
this->left_offset=*left_off; this->left_offset=0;
this->top_offset=*top_off; this->top_offset=0;
this->width=*width; this->width=*width;
this->height=*height; this->height=*height;
this->coding=coding; this->depth=DEPTH16;
this->depth=depth;
// compute the actual framerate // compute the actual framerate
error = dc1394_format7_get_total_bytes(this->camera_handle,this->mode,&total_bytes); error = dc1394_format7_get_total_bytes(this->camera_handle,this->mode,&total_bytes);
if ( error != DC1394_SUCCESS ) if ( error != DC1394_SUCCESS )
...@@ -97,6 +122,15 @@ void CBumblebee::set_config(unsigned int *left_off,unsigned int *top_off,unsigne ...@@ -97,6 +122,15 @@ void CBumblebee::set_config(unsigned int *left_off,unsigned int *top_off,unsigne
this->set_num_DMA_buffers(4); 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) void CBumblebee::get_stereo_image(char **left,char **right)
{ {
int depth; int depth;
...@@ -142,7 +176,7 @@ void CBumblebee::get_stereo_image(char **left,char **right) ...@@ -142,7 +176,7 @@ void CBumblebee::get_stereo_image(char **left,char **right)
if(this->stereo_coding==RGB) if(this->stereo_coding==RGB)
{ {
depth = (int)ceil((float)this->stereo_depth/8.0); 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 // extract color from the bayer tile image
// note: this will alias colors on the top and bottom rows // note: this will alias colors on the top and bottom rows
dc1394_bayer_decoding_8bit( de_interleaved, dc1394_bayer_decoding_8bit( de_interleaved,
...@@ -197,7 +231,7 @@ void CBumblebee::get_stereo_image(char **left,char **right) ...@@ -197,7 +231,7 @@ void CBumblebee::get_stereo_image(char **left,char **right)
if(this->stereo_coding==RGB) if(this->stereo_coding==RGB)
{ {
depth = (int)ceil((float)this->stereo_depth/8.0); 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 // extract color from the bayer tile image
// note: this will alias colors on the top and bottom rows // note: this will alias colors on the top and bottom rows
dc1394_bayer_decoding_8bit( de_interleaved, dc1394_bayer_decoding_8bit( de_interleaved,
......
...@@ -34,6 +34,11 @@ class CBumblebee : public CPTGCamera ...@@ -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); 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 // stereo camera operation functions
/**
* \brief
*
*/
void get_stereo_config(unsigned int *width,unsigned int *height, float *framerate, depths_t *depth, codings_t *coding);
/** /**
* \brief * \brief
* *
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include <sstream> #include <sstream>
#include <iostream> #include <iostream>
const int num_frames=100; const int num_frames=10;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
...@@ -24,8 +24,7 @@ int main(int argc, char *argv[]) ...@@ -24,8 +24,7 @@ int main(int argc, char *argv[])
char *left=NULL,*right=NULL; char *left=NULL,*right=NULL;
std::string new_frame,filename; std::string new_frame,filename;
std::stringstream text; std::stringstream text;
uint64_t guid=0x0000b09d01006b6fb5; //uint64_t guid=0x0000b09d01006b6fb5;
// uint64_t guid=0x00B09D01007D6D85LL;
std::list<std::string> events; std::list<std::string> events;
try try
...@@ -36,13 +35,16 @@ int main(int argc, char *argv[]) ...@@ -36,13 +35,16 @@ int main(int argc, char *argv[])
server->init(); server->init();
std::cout << "Num. Cam. : " << server->get_num_cameras() << std::endl; std::cout << "Num. Cam. : " << server->get_num_cameras() << std::endl;
/* get the new camera with index 0 */ /* 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); server->get_bumblebee_camera(0,&bumblebee);
/* get the reference to the event server */ /* get the reference to the event server */
event_server=CEventServer::instance(); event_server=CEventServer::instance();
bumblebee->get_config(&left_off,&top_off,&width,&height,&framerate,&depth,&coding); 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 << "Fremerate: " << framerate << std::endl;
std::cout << "Color coding: " << (int)coding << "-" << (int)depth << std::endl;
bumblebee->get_new_frame_event_id(new_frame); bumblebee->get_new_frame_event_id(new_frame);
events.push_back(new_frame); events.push_back(new_frame);
bumblebee->start(); bumblebee->start();
......
...@@ -45,8 +45,6 @@ int main(int argc, char *argv[]) ...@@ -45,8 +45,6 @@ int main(int argc, char *argv[])
event_list.push_back(new_frame); event_list.push_back(new_frame);
/* configure the camera */ /* configure the camera */
camera1->get_config(&left_off,&top_off,&width,&height,&framerate,&depth,&coding); 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); camera1->set_config(&left_off,&top_off,&width,&height,&framerate,depth,coding);
std::cout << framerate << std::endl; std::cout << framerate << std::endl;
/* start continuous acquisition */ /* start continuous acquisition */
......
...@@ -44,7 +44,7 @@ int main(int argc, char *argv[]) ...@@ -44,7 +44,7 @@ int main(int argc, char *argv[])
ladybug->get_config(&left_off,&top_off,&width,&height,&framerate,&depth,&coding); ladybug->get_config(&left_off,&top_off,&width,&height,&framerate,&depth,&coding);
std::cout << "Fremerate: " << framerate << std::endl; std::cout << "Fremerate: " << framerate << std::endl;
// coding=MONO; // coding=MONO;
framerate=30; framerate=10;
ladybug->set_config(&left_off,&top_off,&width,&height,&framerate,depth,coding); ladybug->set_config(&left_off,&top_off,&width,&height,&framerate,depth,coding);
ladybug->get_new_frame_event_id(new_frame); ladybug->get_new_frame_event_id(new_frame);
events.push_back(new_frame); events.push_back(new_frame);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment