8000 Disable noisy MSVC warnings and fix remaining relevant ones by ahojnnes · Pull Request #2328 · colmap/colmap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Disable noisy MSVC warnings and fix remaining relevant ones #2328

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

Merged
merged 6 commits into from
Jan 7, 2024
Merged
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
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ if(IS_MSVC)
add_definitions("-DGL_GLEXT_PROTOTYPES")
add_definitions("-DNOMINMAX")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
# Disable warning: 'initializing': conversion from 'X' to 'Y', possible loss of data
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4244 /wd4267 /wd4305")
# Enable object level parallel builds in Visual Studio.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
Expand Down
2 changes: 1 addition & 1 deletion src/colmap/controllers/feature_matching.cc
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ class SequentialFeatureMatcher : public Thread {
if (image_idx2 < image_ids.size()) {
image_pairs.emplace_back(image_id1, image_ids.at(image_idx2));
if (options_.quadratic_overlap) {
const size_t image_idx2_quadratic = image_idx1 + (1 << i);
const size_t image_idx2_quadratic = image_idx1 + (1ull << i);
if (image_idx2_quadratic < image_ids.size()) {
image_pairs.emplace_back(image_id1,
image_ids.at(image_idx2_quadratic));
Expand Down
10 changes: 9 additions & 1 deletion src/colmap/math/graph_cut.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,17 @@
#include <boost/graph/stoer_wagner_min_cut.hpp>
#include <boost/property_map/property_map.hpp>

#ifdef _MSC_VER
#pragma warning(push)
// Disable warning C4005: 'PRId32': macro redefinition
#pragma warning(disable : 4005)
#endif
extern "C" {
#include "metis.h"
#include <metis.h>
}
#ifdef _MSC_VER
#pragma warning(pop)
#endif

#include "colmap/util/logging.h"

Expand Down
14 changes: 12 additions & 2 deletions src/colmap/retrieval/visual_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,12 @@ void VisualIndex<kDescType, kDescDim, kEmbeddingDim>::Read(
flann::AutotunedIndex<flann::L2<kDescType>>(visual_words_);

{
FILE* fin = fopen(path.c_str(), "rb");
FILE* fin = nullptr;
#ifdef _MSC_VER
CHECK_EQ(fopen_s(&fin, path.c_str(), "rb"), 0);
#else
fin = fopen(path.c_str(), "rb");
#endif
CHECK_NOTNULL(fin);
fseek(fin, file_offset, SEEK_SET);
visual_word_index_.loadIndex(fin);
Expand Down Expand Up @@ -623,7 +628,12 @@ void VisualIndex<kDescType, kDescDim, kEmbeddingDim>::Write(
// Write the visual words search index.

{
FILE* fout = fopen(path.c_str(), "ab");
FILE* fout = nullptr;
#ifdef _MSC_VER
CHECK_EQ(fopen_s(&fout, path.c_str(), "ab"), 0);
#else
fout = fopen(path.c_str(), "ab");
#endif
CHECK_NOTNULL(fout);
visual_word_index_.saveIndex(fout);
fclose(fout);
Expand Down
4 changes: 2 additions & 2 deletions src/colmap/retrieval/vote_and_verify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ int VoteAndVerify(const VoteAndVerifyOptions& options,

const float trans_norm = 1.0f / (2.0f * max_trans);
const float scale_norm = 1.0f / (2.0f * max_log_scale);
const float angle_norm = 1.0f / (2.0f * M_PI);
const float angle_norm = 1.0f / (2.0f * static_cast<float>(M_PI));

//////////////////////////////////////////////////////////////////////////////
// Fill the multi-resolution voting histogram.
Expand All @@ -271,7 +271,7 @@ int VoteAndVerify(const VoteAndVerifyOptions& options,
const float x = (T.tx + max_trans) * trans_norm;
const float y = (T.ty + max_trans) * trans_norm;
const float s = (log_scale + max_log_scale) * scale_norm;
const float a = (T.angle + M_PI) * angle_norm;
const float a = (T.angle + static_cast<float>(M_PI)) * angle_norm;

int n_x = std::min(static_cast<int>(x * options.num_trans_bins),
static_cast<int>(options.num_trans_bins - 1));
Expand Down
2 changes: 1 addition & 1 deletion src/colmap/sensor/bitmap_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ TEST(Bitmap, BitmapGrayColor) {
}

TEST(Bitmap, BitmapColorCast) {
BitmapColor<float> color1(1.1, 2.9, -3.0);
BitmapColor<float> color1(1.1f, 2.9f, -3.0f);
BitmapColor<uint8_t> color2 = color1.Cast<uint8_t>();
EXPECT_EQ(color2.r, 1);
EXPECT_EQ(color2.g, 3);
Expand Down
12 changes: 4 additions & 8 deletions src/colmap/util/endian_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ void TestIntNativeToLitteBigEndian() {
std::default_random_engine prng;
std::uniform_int_distribution<T> distribution(
std::numeric_limits<T>::lowest(), std::numeric_limits<T>::max());
constexpr int kNumTrials = 100;
for (int i = 0; i < kNumTrials; ++i) {
for (int i = 0; i < 100; ++i) {
const T x = distribution(prng);
EXPECT_EQ(LittleEndianToNative<T>(NativeToLittleEndian<T>(x)), x);
EXPECT_EQ(BigEndianToNative<T>(NativeToBigEndian<T>(x)), x);
Expand All @@ -111,8 +110,7 @@ void TestRealNativeToLitteBigEndian() {
std::default_random_engine prng;
std::uniform_real_distribution<T> distribution(
std::numeric_limits<T>::lowest(), std::numeric_limits<T>::max());
constexpr int kNumTrials = 100;
for (int i = 0; i < kNumTrials; ++i) {
for (int i = 0; i < 100; ++i) {
const T x = distribution(prng);
EXPECT_EQ(LittleEndianToNative<T>(NativeToLittleEndian<T>(x)), x);
EXPECT_EQ(BigEndianToNative<T>(NativeToBigEndian<T>(x)), x);
Expand Down Expand Up @@ -143,8 +141,7 @@ void TestIntReadWriteBinaryLittleEndian() {
std::default_random_engine prng;
std::uniform_int_distribution<T> distribution(
std::numeric_limits<T>::lowest(), std::numeric_limits<T>::max());
constexpr int kNumTrials = 100;
for (int i = 0; i < kNumTrials; ++i) {
for (int i = 0; i < 100; ++i) {
std::stringstream file;
const T orig_value = distribution(prng);
WriteBinaryLittleEndian<T>(&file, orig_value);
Expand All @@ -170,8 +167,7 @@ void TestFloatReadWriteBinaryLittleEndian() {
std::default_random_engine prng;
std::uniform_real_distribution<T> distribution(
std::numeric_limits<T>::lowest(), std::numeric_limits<T>::max());
constexpr int kNumTrials = 100;
for (int i = 0; i < kNumTrials; ++i) {
for (int i = 0; i < 100; ++i) {
std::stringstream file;
const T orig_value = distribution(prng);
WriteBinaryLittleEndian<T>(&file, orig_value);
Expand Down
0