Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++17 fixes and opencv4 fixes #42

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef ASLAM_COMMON_FEATURE_DESCRIPTOR_REF_H_
#define ASLAM_COMMON_FEATURE_DESCRIPTOR_REF_H_
#include <algorithm>
#include <random>
#include <cstdint>
#include <glog/logging.h>
#include <stdlib.h>
Expand Down Expand Up @@ -135,7 +136,9 @@ inline void FlipNRandomBits(size_t num_bits_to_flip, FeatureDescriptorRef* descr
std::generate_n(
std::back_inserter(bits_to_flip), descriptor_size_bits, [n]()mutable {return n++;});
CHECK_LT(num_bits_to_flip, bits_to_flip.size()) << "Cannot flip more than everything.";
std::random_shuffle(bits_to_flip.begin(), bits_to_flip.end());
std::random_device rd;
std::mt19937 g(rd());
std::shuffle(bits_to_flip.begin(), bits_to_flip.end(), g);
for (size_t i = 0; i < num_bits_to_flip; ++i) {
FlipBit(bits_to_flip[i], descriptor);
}
Expand Down
4 changes: 2 additions & 2 deletions aslam_cv_common/include/aslam/common/occupancy-grid-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,15 +318,15 @@ cv::Mat WeightedOccupancyGrid<PointType>::getOccupancyMask(
// Mask out the individual keypoints in the cell.
for (const PointType& point : cell) {
cv::circle(mask, cv::Point(point.v_cols, point.u_rows), radius_mask_around_points,
cv::Scalar(0), CV_FILLED);
cv::Scalar(0), cv::FILLED);
}

// Mask the entire cell if the cell is full.
if (cell.size() >= max_points_per_cell) {
cv::Point top_left(j_col * cell_size_cols_, i_row * cell_size_rows_);
cv::Point bottom_right((j_col + 1) * cell_size_cols_ - 1,
(i_row + 1) * cell_size_rows_ - 1);
cv::rectangle(mask, top_left, bottom_right, cv::Scalar(0), CV_FILLED);
cv::rectangle(mask, top_left, bottom_right, cv::Scalar(0), cv::FILLED);
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions aslam_cv_common/include/aslam/common/undistort-helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/calib3d/calib3d.hpp>
#include <opencv2/core/eigen.hpp>
#include <opencv2/core/types_c.h>
#include <opencv2/core/mat.hpp>

// This file contains modified opencv routines which use aslam's distort and project functionality.
// Original functions can be found here:
Expand All @@ -29,8 +31,9 @@ static void getUndistortRectangles(const DerivedCameraType& input_camera, bool u
cv::Rect_<float>& inner, cv::Rect_<float>& outer) {
const int N = 9;
int x, y, k;
cv::Ptr<CvMat> _pts(cvCreateMat(1, N * N, CV_32FC2));
CvPoint2D32f* pts = (CvPoint2D32f*) (_pts->data.ptr);
cv::Mat *m = new cv::Mat(1, N * N, CV_32FC2);
cv::Ptr<cv::Mat> _pts(m);
CvPoint2D32f* pts = (CvPoint2D32f*) (_pts->data);

for (y = k = 0; y < N; y++) {
for (x = 0; x < N; x++) {
Expand Down
4 changes: 2 additions & 2 deletions aslam_cv_matcher/src/match-visualization.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ void drawKeyPointsAndMatches(const cv::Mat& image_A,
LOG(FATAL) << "Unknown FeatureVisualizationType: "
<< static_cast<int>(type);
}
cvtColor(image_A, sub_image_A, CV_GRAY2BGR);
cvtColor(image_B, sub_image_B, CV_GRAY2BGR);
cvtColor(image_A, sub_image_A, cv::COLOR_GRAY2BGR);
cvtColor(image_B, sub_image_B, cv::COLOR_GRAY2BGR);

// Draw keypoints.
cv::drawKeypoints(sub_image_A, key_points_A, sub_image_A, kRed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void visualizeMatches(const aslam::VisualFrame& frame_kp1,
cv::Mat* image) {
CHECK_NOTNULL(image);

cv::cvtColor(frame_kp1.getRawImage(), *image, CV_GRAY2BGR);
cv::cvtColor(frame_kp1.getRawImage(), *image, cv::COLOR_GRAY2BGR);

VLOG(4) << "Converted raw image from grayscale to color.";

Expand Down
14 changes: 7 additions & 7 deletions aslam_cv_visualization/src/basic-visualization.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void drawKeypoints(const aslam::VisualFrame& frame, cv::Mat* image) {
keypoint = frame.getKeypointMeasurement(keypoint_idx);
}
cv::circle(*image, cv::Point(keypoint[0], keypoint[1]), 1,
cv::Scalar(0, 255, 255), 1, CV_AA);
cv::Scalar(0, 255, 255), 1, cv::LINE_AA);
}
}

Expand Down Expand Up @@ -125,7 +125,7 @@ void assembleMultiImage(const aslam::VisualNFrame::ConstPtr& nframe,
}

cv::cvtColor(nframe->getFrame(frame_idx).getRawImage(), individual_images[frame_idx],
CV_GRAY2BGR);
cv::COLOR_GRAY2BGR);

CHECK(nframe->getFrame(frame_idx).getCameraGeometry());
const size_t image_width =
Expand Down Expand Up @@ -217,10 +217,10 @@ void drawFeatureTrackPatches(const aslam::FeatureTrack& track, size_t keypoint_n

// Draw the keypoint.
cv::Mat keypoint_neighbourhood_image;
cv::cvtColor(keypoint_image(roi_keypoint), keypoint_neighbourhood_image, CV_GRAY2BGR);
cv::cvtColor(keypoint_image(roi_keypoint), keypoint_neighbourhood_image, cv::COLOR_GRAY2BGR);
cv::Point keypoint_coords_subimage(keypoint[0] - roi_keypoint.x, keypoint[1] - roi_keypoint.y);
cv::circle(keypoint_neighbourhood_image, keypoint_coords_subimage, 1,
cv::Scalar(0, 255, 255), 1, CV_AA);
cv::Scalar(0, 255, 255), 1, cv::LINE_AA);

keypoint_neighbourhood_image.copyTo((*image)(roi_subimage));
++keypoint_index;
Expand Down Expand Up @@ -264,7 +264,7 @@ bool drawFeatureTracks(const aslam::FeatureTracks& tracks, cv::Mat* image) {

// Draw the tracks in the image of the last keypoint of the first track.
const cv::Mat& frame_image = tracks.front().getLastKeypointIdentifier().getFrame().getRawImage();
cv::cvtColor(frame_image, *image, CV_GRAY2BGR);
cv::cvtColor(frame_image, *image, cv::COLOR_GRAY2BGR);

// Draw all keypoints on the tracks.
for (const aslam::FeatureTrack& track : tracks) {
Expand All @@ -275,7 +275,7 @@ bool drawFeatureTracks(const aslam::FeatureTracks& tracks, cv::Mat* image) {
const cv::Point keypoint_cv(keypoint(0), keypoint(1));
const size_t kRadiusPx = 1u;
const size_t kThicknessPx = 1u;
cv::circle(*image, keypoint_cv, kRadiusPx, kYellow, kThicknessPx, CV_AA);
cv::circle(*image, keypoint_cv, kRadiusPx, kYellow, kThicknessPx, cv::LINE_AA);
if (is_first_keypoint_drawn) {
cv::line(*image, keypoint_cv, last_keypoint_cv, kYellow);
} else {
Expand All @@ -286,5 +286,5 @@ bool drawFeatureTracks(const aslam::FeatureTracks& tracks, cv::Mat* image) {
}
return true;
}

} // namespace aslam_cv_visualization
6 changes: 3 additions & 3 deletions aslam_cv_visualization/src/feature-track-visualizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,16 @@ void VisualFrameFeatureTrackVisualizer::drawContinuousFeatureTracks(
cv::Point point_end_line((*measurement_it)(0), (*measurement_it)(1));
if (terminated) {
cv::line(*image, point_start_line, point_end_line, cv::Scalar(0, 0, 255), kLineWidth,
CV_AA);
cv::LINE_AA);
} else {
cv::line(*image, point_start_line, point_end_line, track_it->second.color, kLineWidth,
CV_AA);
cv::LINE_AA);
}
point_start_line = point_end_line;
}
if (!terminated) {
cv::circle(*image, point_start_line, kCircleRadius, cv::Scalar(0.0, 255.0, 255.0, 20),
kLineWidth, CV_AA);
kLineWidth, cv::LINE_AA);
}
}

Expand Down