| 1 |
/* +------------------------------------------------------------------------+ |
| 2 |
| Mobile Robot Programming Toolkit (MRPT) | |
| 3 |
| https://www.mrpt.org/ | |
| 4 |
| | |
| 5 |
| Copyright (c) 2005-2026, Individual contributors, see AUTHORS file | |
| 6 |
| See: https://www.mrpt.org/Authors - All rights reserved. | |
| 7 |
| Released under BSD License. See: https://www.mrpt.org/License | |
| 8 |
+------------------------------------------------------------------------+ */ |
| 9 |
|
| 10 |
#include "hwdrivers-precomp.h" // Only for precomp. headers, include all libmrpt-core headers. |
| 11 |
// |
| 12 |
#include <mrpt/hwdrivers/CStereoGrabber_Bumblebee_libdc1394.h> |
| 13 |
|
| 14 |
#include <map> |
| 15 |
|
| 16 |
using namespace std; |
| 17 |
using namespace mrpt; |
| 18 |
using namespace mrpt::obs; |
| 19 |
using namespace mrpt::hwdrivers; |
| 20 |
|
| 21 |
CStereoGrabber_Bumblebee_libdc1394::CStereoGrabber_Bumblebee_libdc1394( |
| 22 |
uint64_t cameraGUID, uint16_t cameraUnit, double frameRate) : |
| 23 |
m_firewire_capture(nullptr), m_bInitialized(false) |
| 24 |
{ |
| 25 |
MRPT_TRY_START |
| 26 |
|
| 27 |
TCaptureOptions_dc1394 opt1394; |
| 28 |
opt1394.mode7 = 3; // stereo cameras are captured with MODE7-3 |
| 29 |
opt1394.deinterlace_stereo = true; // It is stereo. |
| 30 |
|
| 31 |
std::map<double, grabber_dc1394_framerate_t> Rs; |
| 32 |
Rs[1.875] = FRAMERATE_1_875; |
| 33 |
Rs[3.75] = FRAMERATE_3_75; |
| 34 |
Rs[7.5] = FRAMERATE_7_5; |
| 35 |
Rs[15] = FRAMERATE_15; |
| 36 |
Rs[30] = FRAMERATE_30; |
| 37 |
Rs[60] = FRAMERATE_60; |
| 38 |
Rs[120] = FRAMERATE_120; |
| 39 |
Rs[240] = FRAMERATE_240; |
| 40 |
|
| 41 |
if (Rs.find(frameRate) != Rs.end()) |
| 42 |
opt1394.framerate = Rs[frameRate]; |
| 43 |
else |
| 44 |
cerr << "[CStereoGrabber_Bumblebee_libdc1394] Ignoring unknown " |
| 45 |
"framerate: " |
| 46 |
<< frameRate << "\n"; |
| 47 |
|
| 48 |
m_firewire_capture = new CImageGrabber_dc1394(cameraGUID, cameraUnit, opt1394); |
| 49 |
|
| 50 |
if (!m_firewire_capture->isOpen()) |
| 51 |
cerr << "[CStereoGrabber_Bumblebee] The camera couldn't be open" << endl; |
| 52 |
|
| 53 |
MRPT_TRY_END |
| 54 |
} |
| 55 |
|
| 56 |
/*------------------------------------------------------------- |
| 57 |
Destructor |
| 58 |
-------------------------------------------------------------*/ |
| 59 |
CStereoGrabber_Bumblebee_libdc1394::~CStereoGrabber_Bumblebee_libdc1394() |
| 60 |
{ |
| 61 |
if (m_firewire_capture) |
| 62 |
{ |
| 63 |
delete m_firewire_capture; |
| 64 |
m_firewire_capture = nullptr; |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
/*------------------------------------------------------------- |
| 69 |
get the image |
| 70 |
-------------------------------------------------------------*/ |
| 71 |
bool CStereoGrabber_Bumblebee_libdc1394::getStereoObservation( |
| 72 |
mrpt::obs::CObservationStereoImages& out_observation) |
| 73 |
{ |
| 74 |
if (!m_firewire_capture->isOpen()) |
| 75 |
{ |
| 76 |
cerr << "[CStereoGrabber_Bumblebee] The camera couldn't be open" << endl; |
| 77 |
return false; |
| 78 |
} |
| 79 |
|
| 80 |
if (!m_firewire_capture->getObservation(out_observation)) return false; |
| 81 |
|
| 82 |
return true; // All ok |
| 83 |
} |