Skip to content

Commit

Permalink
Fixed issue #17
Browse files Browse the repository at this point in the history
  • Loading branch information
Simone Guscetti committed Jul 22, 2016
1 parent 84c9640 commit b163211
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 26 deletions.
51 changes: 28 additions & 23 deletions include/uvc_ros_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
#include <vector>
#include <utility> // std::pair
#include <string>
#include <algorithm>

namespace uvc
{
Expand Down Expand Up @@ -229,30 +230,34 @@ class uvcROSDriver
void setNumberOfCameras(int n_cameras)
{
n_cameras_ = n_cameras;
switch (n_cameras) {
case 8:
camera_config_ = 0x0F;
break;
case 6:
camera_config_ = 0x07;
break;
case 4:
camera_config_ = 0x03;
break;
case 2:
default:
camera_config_ = 0x01;
break;
}

switch (n_cameras) {
case 8:
camera_config_ = 0x0F;
break;

case 6:
camera_config_ = 0x07;
break;

case 4:
camera_config_ = 0x03;
break;

case 2:
default:
camera_config_ = 0x01;
break;
}
};
int getCameraConfig()
{
return camera_config_;
};
int getCameraConfig()
{
return camera_config_;
};
// void setCameraConfig(int camera_config)
// {
// camera_config_ = camera_config;
// };
// void setCameraConfig(int camera_config)
// {
// camera_config_ = camera_config;
// };
CameraParameters getCameraParams()
{
return camera_params_;
Expand Down
2 changes: 2 additions & 0 deletions params/homography_mapping.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# place here the mapping between cameras from low to high numbers
# ex: [[0,1],[2,3],[4,5]]
homography_mapping: [[0,1]]
24 changes: 21 additions & 3 deletions src/uvc_ros_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ static void callback(uvc_frame *frame, void *arg)
obj->uvc_cb(frame);
}

static bool myPairMax(std::pair<int, int> p, std::pair<int, int> p1)
{
// gratest value is supposed be on the second index
return p.second < p1.second;
}

uvcROSDriver::~uvcROSDriver()
{
setParam("CAMERA_ENABLE", 0.0f);
Expand Down Expand Up @@ -342,10 +348,22 @@ void uvcROSDriver::setCalibration(CameraParameters camParams)
H_.resize(n_cameras_);
// pointer at camera info
sensor_msgs::CameraInfo *ci;
size_t homography_size;

// TODO: reimplment this part for multiple stereo base line based systems
if (set_calibration_) {
for (size_t i = 0; i < homography_mapping_.size(); i++) {
std::vector<std::pair<int, int> >::iterator it_homography =
std::max_element(homography_mapping_.begin(), homography_mapping_.end(),
myPairMax);

if ((*it_homography).second > n_cameras_) {
homography_size = std::distance(homography_mapping_.begin(), it_homography);

} else {
homography_size = homography_mapping_.size();
}

// TODO: reimplment this part for multiple stereo base line based systems
for (size_t i = 0; i < homography_size; i++) {
// temp structures
Eigen::Matrix3d H0;
Eigen::Matrix3d H1;
Expand Down Expand Up @@ -621,7 +639,7 @@ void uvcROSDriver::uvc_cb(uvc_frame_t *frame)
unsigned frame_size = frame->height * frame->width * 2;

// read the IMU data
int16_t zero = 0;
// int16_t zero = 0;
uint16_t cam_id = 0;
static uint16_t count_prev;

Expand Down

0 comments on commit b163211

Please sign in to comment.