-
Sergi Hernandez authored
Added a class for the bumblebee camera. Added a class for the ladybug camera. Added examples of both cameras.
Sergi Hernandez authoredAdded a class for the bumblebee camera. Added a class for the ladybug camera. Added examples of both cameras.
bumblebee.cpp 2.32 KiB
#include "firewireserver.h"
#include "bumblebee.h"
#include "firewireexceptions.h"
#include "eventserver.h"
#include <sys/time.h>
#include <string>
#include <sstream>
#include <iostream>
const int num_frames=100;
int main(int argc, char *argv[])
{
CFirewireServer *server;
CEventServer *event_server;
timeval start_time,end_time;
CBumblebee *bumblebee=NULL;
long elapsed_time[num_frames];
unsigned int left_off,top_off,width,height;
float framerate;
codings_t coding;
depths_t depth;
int i=0;
char *left=NULL,*right=NULL;
std::string new_frame,filename;
std::stringstream text;
uint64_t guid=0x0000b09d01006b6fb5;
// uint64_t guid=0x00B09D01007D6D85LL;
std::list<std::string> events;
try
{
/* get the reference to the firewire camera server */
server=CFirewireServer::instance();
/* initialize the camera server */
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);
std::cout << "Fremerate: " << framerate << std::endl;
bumblebee->get_new_frame_event_id(new_frame);
events.push_back(new_frame);
bumblebee->start();
for ( i=0 ; i<num_frames ; i++ )
{
text.str("");
gettimeofday(&start_time,NULL);
event_server->wait_all(events,0);
bumblebee->get_stereo_image(&left,&right);
filename="image_";
text << i;
filename+=text.str();
filename+=".ppm";
bumblebee->save_stereo_image(filename,left,right);
if(left!=NULL)
{
delete[] left;
left=NULL;
}
if(right!=NULL)
{
delete[] right;
right=NULL;
}
gettimeofday(&end_time,NULL);
elapsed_time[i]=(end_time.tv_sec-start_time.tv_sec)*1000000+end_time.tv_usec-start_time.tv_usec;
std::cout << "Elapsed time: " << elapsed_time[i] << "s" << std::endl;
}
bumblebee->stop();
delete bumblebee;
server->close();
}
catch(CException& e)
{
std::cout << e.what() << std::endl;
}
}