Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions camera_model/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ find_package(catkin REQUIRED COMPONENTS
find_package(Boost REQUIRED COMPONENTS filesystem program_options system)
include_directories(${Boost_INCLUDE_DIRS})

find_package(OpenCV 3.4.5 REQUIRED)
find_package(OpenCV REQUIRED)

# set(EIGEN_INCLUDE_DIR "/usr/local/include/eigen3")
find_package(Ceres REQUIRED)
Expand All @@ -34,7 +34,7 @@ include_directories(
include_directories("include")


add_executable(Calibration
add_executable(Calibration
src/intrinsic_calib.cc
src/chessboard/Chessboard.cc
src/calib/CameraCalibration.cc
Expand Down
8 changes: 4 additions & 4 deletions camera_model/src/calib/CameraCalibration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ CameraCalibration::drawResults(std::vector<cv::Mat>& images) const
cv::Mat& image = images.at(i);
if (image.channels() == 1)
{
cv::cvtColor(image, image, CV_GRAY2RGB);
cv::cvtColor(image, image, cv::COLOR_GRAY2RGB);
}

std::vector<cv::Point2f> estImagePoints;
Expand All @@ -250,12 +250,12 @@ CameraCalibration::drawResults(std::vector<cv::Mat>& images) const
cv::circle(image,
cv::Point(cvRound(pObs.x * drawMultiplier),
cvRound(pObs.y * drawMultiplier)),
5, green, 2, CV_AA, drawShiftBits);
5, green, 2, cv::LINE_AA, drawShiftBits);

cv::circle(image,
cv::Point(cvRound(pEst.x * drawMultiplier),
cvRound(pEst.y * drawMultiplier)),
5, red, 2, CV_AA, drawShiftBits);
5, red, 2, cv::LINE_AA, drawShiftBits);

float error = cv::norm(pObs - pEst);

Expand All @@ -272,7 +272,7 @@ CameraCalibration::drawResults(std::vector<cv::Mat>& images) const

cv::putText(image, oss.str(), cv::Point(10, image.rows - 10),
cv::FONT_HERSHEY_COMPLEX, 0.5, cv::Scalar(255, 255, 255),
1, CV_AA);
1, cv::LINE_AA);
}
}

Expand Down
44 changes: 22 additions & 22 deletions camera_model/src/chessboard/Chessboard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@ Chessboard::Chessboard(cv::Size boardSize, cv::Mat& image)
{
if (image.channels() == 1)
{
cv::cvtColor(image, mSketch, CV_GRAY2BGR);
cv::cvtColor(image, mSketch, cv::COLOR_GRAY2BGR);
image.copyTo(mImage);
}
else
{
image.copyTo(mSketch);
cv::cvtColor(image, mImage, CV_BGR2GRAY);
cv::cvtColor(image, mImage, cv::COLOR_BGR2GRAY);
}
}

void
Chessboard::findCorners(bool useOpenCV)
{
mCornersFound = findChessboardCorners(mImage, mBoardSize, mCorners,
CV_CALIB_CB_ADAPTIVE_THRESH +
CV_CALIB_CB_NORMALIZE_IMAGE +
CV_CALIB_CB_FILTER_QUADS +
CV_CALIB_CB_FAST_CHECK,
cv::CALIB_CB_ADAPTIVE_THRESH +
cv::CALIB_CB_NORMALIZE_IMAGE +
cv::CALIB_CB_FILTER_QUADS +
cv::CALIB_CB_FAST_CHECK,
useOpenCV);

if (mCornersFound)
Expand Down Expand Up @@ -141,24 +141,24 @@ Chessboard::findChessboardCornersImproved(const cv::Mat& image,
// Image histogram normalization and
// BGR to Grayscale image conversion (if applicable)
// MARTIN: Set to "false"
if (image.channels() != 1 || (flags & CV_CALIB_CB_NORMALIZE_IMAGE))
if (image.channels() != 1 || (flags & cv::CALIB_CB_NORMALIZE_IMAGE))
{
cv::Mat norm_img(image.rows, image.cols, CV_8UC1);

if (image.channels() != 1)
{
cv::cvtColor(image, norm_img, CV_BGR2GRAY);
cv::cvtColor(image, norm_img, cv::COLOR_BGR2GRAY);
img = norm_img;
}

if (flags & CV_CALIB_CB_NORMALIZE_IMAGE)
if (flags & cv::CALIB_CB_NORMALIZE_IMAGE)
{
cv::equalizeHist(image, norm_img);
img = norm_img;
}
}

if (flags & CV_CALIB_CB_FAST_CHECK)
if (flags & cv::CALIB_CB_FAST_CHECK)
{
if (!checkChessboard(img, patternSize))
{
Expand Down Expand Up @@ -189,13 +189,13 @@ Chessboard::findChessboardCornersImproved(const cv::Mat& image,
cv::Mat thresh_img;

// convert the input grayscale image to binary (black-n-white)
if (flags & CV_CALIB_CB_ADAPTIVE_THRESH)
if (flags & cv::CALIB_CB_ADAPTIVE_THRESH)
{
int blockSize = lround(prevSqrSize == 0 ?
std::min(img.cols,img.rows)*(k%2 == 0 ? 0.2 : 0.1): prevSqrSize*2)|1;

// convert to binary
cv::adaptiveThreshold(img, thresh_img, 255, CV_ADAPTIVE_THRESH_MEAN_C, CV_THRESH_BINARY, blockSize, (k/2)*5);
cv::adaptiveThreshold(img, thresh_img, 255, cv::ADAPTIVE_THRESH_MEAN_C, cv::THRESH_BINARY, blockSize, (k/2)*5);
}
else
{
Expand All @@ -204,16 +204,16 @@ Chessboard::findChessboardCornersImproved(const cv::Mat& image,
int thresh_level = lround(mean - 10);
thresh_level = std::max(thresh_level, 10);

cv::threshold(img, thresh_img, thresh_level, 255, CV_THRESH_BINARY);
cv::threshold(img, thresh_img, thresh_level, 255, cv::THRESH_BINARY);
}

// MARTIN's Code
// Use both a rectangular and a cross kernel. In this way, a more
// homogeneous dilation is performed, which is crucial for small,
// distorted checkers. Use the CROSS kernel first, since its action
// on the image is more subtle
cv::Mat kernel1 = cv::getStructuringElement(CV_SHAPE_CROSS, cv::Size(3,3), cv::Point(1,1));
cv::Mat kernel2 = cv::getStructuringElement(CV_SHAPE_RECT, cv::Size(3,3), cv::Point(1,1));
cv::Mat kernel1 = cv::getStructuringElement(cv::MORPH_CROSS, cv::Size(3,3), cv::Point(1,1));
cv::Mat kernel2 = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3,3), cv::Point(1,1));

if (dilations >= 1)
cv::dilate(thresh_img, thresh_img, kernel1);
Expand Down Expand Up @@ -317,7 +317,7 @@ Chessboard::findChessboardCornersImproved(const cv::Mat& image,
}

cv::cornerSubPix(image, corners, cv::Size(11, 11), cv::Size(-1,-1),
cv::TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
cv::TermCriteria(cv::TermCriteria::EPS + cv::TermCriteria::MAX_ITER, 30, 0.1));

return true;
}
Expand Down Expand Up @@ -1172,7 +1172,7 @@ Chessboard::generateQuads(std::vector<ChessboardQuadPtr>& quads,
std::vector<cv::Vec4i> hierarchy;

// Initialize contour retrieving routine
cv::findContours(image, contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);
cv::findContours(image, contours, hierarchy, cv::RETR_CCOMP, cv::CHAIN_APPROX_SIMPLE);

std::vector< std::vector<cv::Point> > quadContours;

Expand Down Expand Up @@ -1238,7 +1238,7 @@ Chessboard::generateQuads(std::vector<ChessboardQuadPtr>& quads,
dp = pt[1] - pt[2];
double d4 = sqrt(dp.dot(dp));

if (!(flags & CV_CALIB_CB_FILTER_QUADS) ||
if (!(flags & cv::CALIB_CB_FILTER_QUADS) ||
(d3*4 > d4 && d4*4 > d3 && d3*d4 < area*1.5 && area > minSize &&
d1 >= 0.15 * p && d2 >= 0.15 * p))
{
Expand Down Expand Up @@ -1583,20 +1583,20 @@ Chessboard::checkChessboard(const cv::Mat& image, cv::Size patternSize) const
bool result = false;
for (float threshLevel = blackLevel; threshLevel < whiteLevel && !result; threshLevel += 20.0f)
{
cv::threshold(white, thresh, threshLevel + blackWhiteGap, 255, CV_THRESH_BINARY);
cv::threshold(white, thresh, threshLevel + blackWhiteGap, 255, cv::THRESH_BINARY);

std::vector< std::vector<cv::Point> > contours;
std::vector<cv::Vec4i> hierarchy;

// Initialize contour retrieving routine
cv::findContours(thresh, contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);
cv::findContours(thresh, contours, hierarchy, cv::RETR_CCOMP, cv::CHAIN_APPROX_SIMPLE);

std::vector<std::pair<float, int> > quads;
getQuadrangleHypotheses(contours, quads, 1);

cv::threshold(black, thresh, threshLevel, 255, CV_THRESH_BINARY_INV);
cv::threshold(black, thresh, threshLevel, 255, cv::THRESH_BINARY_INV);

cv::findContours(thresh, contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);
cv::findContours(thresh, contours, hierarchy, cv::RETR_CCOMP, cv::CHAIN_APPROX_SIMPLE);
getQuadrangleHypotheses(contours, quads, 0);

const size_t min_quads_count = patternSize.width * patternSize.height / 2;
Expand Down
2 changes: 1 addition & 1 deletion camera_model/src/intrinsic_calib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ int main(int argc, char** argv)
{
cv::putText(cbImages.at(i), cbImageFilenames.at(i), cv::Point(10,20),
cv::FONT_HERSHEY_COMPLEX, 0.5, cv::Scalar(255, 255, 255),
1, CV_AA);
1, cv::LINE_AA);
cv::imshow("Image", cbImages.at(i));
cv::waitKey(0);
}
Expand Down
4 changes: 2 additions & 2 deletions feature_tracker/src/feature_tracker_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void img_callback(const sensor_msgs::ImageConstPtr &img_msg)
{
// 一些常规的reset操作
ROS_WARN("image discontinue! reset the feature tracker!");
first_image_flag = true;
first_image_flag = true;
last_image_time = 0;
pub_count = 1;
std_msgs::Bool restart_flag;
Expand Down Expand Up @@ -184,7 +184,7 @@ void img_callback(const sensor_msgs::ImageConstPtr &img_msg)
for (int i = 0; i < NUM_OF_CAM; i++)
{
cv::Mat tmp_img = stereo_img.rowRange(i * ROW, (i + 1) * ROW);
cv::cvtColor(show_img, tmp_img, CV_GRAY2RGB);
cv::cvtColor(show_img, tmp_img, cv::COLOR_GRAY2RGB);

for (unsigned int j = 0; j < trackerData[i].cur_pts.size(); j++)
{
Expand Down
54 changes: 26 additions & 28 deletions pose_graph/src/ThirdParty/DVision/BRIEF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* File: BRIEF.cpp
* Author: Dorian Galvez
* Date: September 2010
* Description: implementation of BRIEF (Binary Robust Independent
* Elementary Features) descriptor by
* Description: implementation of BRIEF (Binary Robust Independent
* Elementary Features) descriptor by
* Michael Calonder, Vincent Lepetitand Pascal Fua
* + close binary tests (by Dorian Galvez-Lopez)
* License: see the LICENSE.txt file
Expand Down Expand Up @@ -36,49 +36,49 @@ BRIEF::~BRIEF()

// ---------------------------------------------------------------------------

void BRIEF::compute(const cv::Mat &image,
void BRIEF::compute(const cv::Mat &image,
const std::vector<cv::KeyPoint> &points,
vector<bitset> &descriptors,
bool treat_image) const
{
const float sigma = 2.f;
const cv::Size ksize(9, 9);

cv::Mat im;
if(treat_image)
{
cv::Mat aux;
if(image.depth() == 3)
{
cv::cvtColor(image, aux, CV_RGB2GRAY);
cv::cvtColor(image, aux, cv::COLOR_RGB2GRAY);
}
else
{
aux = image;
}

cv::GaussianBlur(aux, im, ksize, sigma, sigma);

}
else
{
im = image;
}

assert(im.type() == CV_8UC1);
assert(im.isContinuous());

// use im now
const int W = im.cols;
const int H = im.rows;

descriptors.resize(points.size());
std::vector<bitset>::iterator dit;

std::vector<cv::KeyPoint>::const_iterator kit;

int x1, y1, x2, y2;

dit = descriptors.begin();
for(kit = points.begin(); kit != points.end(); ++kit, ++dit)
{
Expand All @@ -91,24 +91,24 @@ void BRIEF::compute(const cv::Mat &image,
y1 = (int)(kit->pt.y + m_y1[i]);
x2 = (int)(kit->pt.x + m_x2[i]);
y2 = (int)(kit->pt.y + m_y2[i]);
if(x1 >= 0 && x1 < W && y1 >= 0 && y1 < H

if(x1 >= 0 && x1 < W && y1 >= 0 && y1 < H
&& x2 >= 0 && x2 < W && y2 >= 0 && y2 < H)
{
if( im.ptr<unsigned char>(y1)[x1] < im.ptr<unsigned char>(y2)[x2] )
{
dit->set(i);
}
}
} // if (x,y)_1 and (x,y)_2 are in the image

} // for each (x,y)
} // for each keypoint
}

// ---------------------------------------------------------------------------

void BRIEF::generateTestPoints()
{
{
m_x1.resize(m_bit_length);
m_y1.resize(m_bit_length);
m_x2.resize(m_bit_length);
Expand All @@ -117,31 +117,31 @@ void BRIEF::generateTestPoints()
const float g_mean = 0.f;
const float g_sigma = 0.2f * (float)m_patch_size;
const float c_sigma = 0.08f * (float)m_patch_size;

float sigma2;
if(m_type == RANDOM)
sigma2 = g_sigma;
else
sigma2 = c_sigma;

const int max_v = m_patch_size / 2;

DUtils::Random::SeedRandOnce();

for(int i = 0; i < m_bit_length; ++i)
{
int x1, y1, x2, y2;

do
{
x1 = DUtils::Random::RandomGaussianValue(g_mean, g_sigma);
} while( x1 > max_v || x1 < -max_v);

do
{
y1 = DUtils::Random::RandomGaussianValue(g_mean, g_sigma);
} while( y1 > max_v || y1 < -max_v);

float meanx, meany;
if(m_type == RANDOM)
meanx = meany = g_mean;
Expand All @@ -150,17 +150,17 @@ void BRIEF::generateTestPoints()
meanx = x1;
meany = y1;
}

do
{
x2 = DUtils::Random::RandomGaussianValue(meanx, sigma2);
} while( x2 > max_v || x2 < -max_v);

do
{
y2 = DUtils::Random::RandomGaussianValue(meany, sigma2);
} while( y2 > max_v || y2 < -max_v);

m_x1[i] = x1;
m_y1[i] = y1;
m_x2[i] = x2;
Expand All @@ -170,5 +170,3 @@ void BRIEF::generateTestPoints()
}

// ----------------------------------------------------------------------------


Loading