Skip to content

Commit e0e5833

Browse files
committed
files changed for successful build of openpose and caffe
1 parent e03ad73 commit e0e5833

File tree

9 files changed

+61
-8
lines changed

9 files changed

+61
-8
lines changed

3rdparty/caffe/CMakeLists.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
set(CMAKE_CXX_STANDARD 17)
2+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
3+
set(CMAKE_CXX_EXTENSIONS OFF)
4+
set(CMAKE_VERBOSE_MAKEFILE ON)
5+
16
cmake_minimum_required(VERSION 2.8.7)
27
if(POLICY CMP0046)
38
cmake_policy(SET CMP0046 NEW)
@@ -50,7 +55,7 @@ include(cmake/Dependencies.cmake)
5055

5156
# ---[ Flags
5257
if(UNIX OR APPLE)
53-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -std=c++11")
58+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall")
5459
endif()
5560

5661
caffe_set_caffe_link()

3rdparty/caffe/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ DYNAMIC_VERSIONED_NAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR).$
4141
DYNAMIC_NAME := $(LIB_BUILD_DIR)/$(DYNAMIC_VERSIONED_NAME_SHORT)
4242
COMMON_FLAGS += -DCAFFE_VERSION=$(DYNAMIC_VERSION_MAJOR).$(DYNAMIC_VERSION_MINOR).$(DYNAMIC_VERSION_REVISION)
4343
# OpenPose: added C++11 flag to avoid crashing in some old GCC compilers
44-
COMMON_FLAGS += -std=c++11
44+
#COMMON_FLAGS += -std=c++11
4545
# OpenPose: end modified
4646

4747
##############################

3rdparty/caffe/cmake/Modules/FindvecLib.cmake

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ find_path(vecLib_INCLUDE_DIR vecLib.h
2020
${CMAKE_XCODE_DEVELOPER_DIR}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Headers/
2121
NO_DEFAULT_PATH)
2222

23+
set(vecLib_INCLUDE_DIR "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Headers/")
24+
2325
include(FindPackageHandleStandardArgs)
2426
find_package_handle_standard_args(vecLib DEFAULT_MSG vecLib_INCLUDE_DIR)
2527

3rdparty/caffe/src/caffe/layers/hdf5_data_layer.cpp

+28-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include <fstream> // NOLINT(readability/streams)
1111
#include <string>
1212
#include <vector>
13+
#include <algorithm>
14+
#include <random>
1315

1416
#include "hdf5.h"
1517
#include "hdf5_hl.h"
@@ -62,7 +64,13 @@ void HDF5DataLayer<Dtype>::LoadHDF5FileData(const char* filename) {
6264

6365
// Shuffle if needed.
6466
if (this->layer_param_.hdf5_data_param().shuffle()) {
67+
#if __cplusplus < 201703L
6568
std::random_shuffle(data_permutation_.begin(), data_permutation_.end());
69+
#else
70+
std::random_device rd;
71+
std::mt19937 g(rd());
72+
std::shuffle(data_permutation_.begin(), data_permutation_.end(), g);
73+
#endif
6674
DLOG(INFO) << "Successfully loaded " << hdf_blobs_[0]->shape(0)
6775
<< " rows (shuffled)";
6876
} else {
@@ -105,7 +113,13 @@ void HDF5DataLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom,
105113

106114
// Shuffle if needed.
107115
if (this->layer_param_.hdf5_data_param().shuffle()) {
116+
#if __cplusplus < 201703L
108117
std::random_shuffle(file_permutation_.begin(), file_permutation_.end());
118+
#else
119+
std::random_device rd;
120+
std::mt19937 g(rd());
121+
std::shuffle(file_permutation_.begin(), file_permutation_.end(), g);
122+
#endif
109123
}
110124

111125
// Load the first HDF5 file and initialize the line counter.
@@ -144,17 +158,30 @@ void HDF5DataLayer<Dtype>::Next() {
144158
if (current_file_ == num_files_) {
145159
current_file_ = 0;
146160
if (this->layer_param_.hdf5_data_param().shuffle()) {
161+
#if __cplusplus < 201703L
147162
std::random_shuffle(file_permutation_.begin(),
148163
file_permutation_.end());
164+
#else
165+
std::random_device rd;
166+
std::mt19937 g(rd());
167+
std::shuffle(file_permutation_.begin(), file_permutation_.end(), g);
168+
#endif
149169
}
150170
DLOG(INFO) << "Looping around to first file.";
151171
}
152172
LoadHDF5FileData(
153173
hdf_filenames_[file_permutation_[current_file_]].c_str());
154174
}
155175
current_row_ = 0;
156-
if (this->layer_param_.hdf5_data_param().shuffle())
176+
if (this->layer_param_.hdf5_data_param().shuffle()){
177+
#if __cplusplus < 201703L
157178
std::random_shuffle(data_permutation_.begin(), data_permutation_.end());
179+
#else
180+
std::random_device rd;
181+
std::mt19937 g(rd());
182+
std::shuffle(data_permutation_.begin(), data_permutation_.end(), g);
183+
#endif
184+
}
158185
}
159186
offset_++;
160187
}

3rdparty/caffe/src/caffe/util/io.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ bool ReadProtoFromBinaryFile(const char* filename, Message* proto) {
5454
CHECK_NE(fd, -1) << "File not found: " << filename;
5555
ZeroCopyInputStream* raw_input = new FileInputStream(fd);
5656
CodedInputStream* coded_input = new CodedInputStream(raw_input);
57+
#if __cplusplus < 201703L
5758
coded_input->SetTotalBytesLimit(kProtoReadBytesLimit, 536870912);
59+
#else
60+
coded_input->SetTotalBytesLimit(kProtoReadBytesLimit);
61+
#endif
5862

5963
bool success = proto->ParseFromCodedStream(coded_input);
6064

CMakeLists.txt

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
set(CMAKE_CXX_STANDARD 17)
2+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
3+
set(CMAKE_CXX_EXTENSIONS OFF)
4+
set(CMAKE_VERBOSE_MAKEFILE ON)
5+
16
### VERSION INFO
27
set(OpenPose_VERSION_MAJOR 1)
38
set(OpenPose_VERSION_MINOR 7)
@@ -99,11 +104,11 @@ if (WIN32)
99104
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /LTCG:incremental /OPT:REF /OPT:ICF")
100105
elseif (UNIX)
101106
# Turn on C++11
102-
add_definitions(-std=c++11)
107+
add_definitions(-std=c++17)
103108
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
104109
elseif (APPLE)
105110
# Turn on C++11
106-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
111+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
107112
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
108113
endif (WIN32)
109114

@@ -867,6 +872,7 @@ endif (NOT ${WITH_EIGEN} MATCHES "NONE")
867872

868873
if (APPLE)
869874
include_directories("/usr/local/opt/openblas/include")
875+
include_directories("/opt/homebrew/opt/openblas/include")
870876
endif (APPLE)
871877

872878
if (USE_MKL)

scripts/osx/install_deps.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
brew_packages="openblas snappy leveldb gflags glog szip lmdb hdf5 opencv protobuf boost cmake viennacl"
2+
brew_packages="openblas snappy leveldb gflags glog szip lmdb hdf5 opencv protobuf boost viennacl"
33
for pkg in $brew_packages
44
do
55
echo "brew install $pkg || brew upgrade $pkg"
@@ -14,6 +14,6 @@ done
1414
pip_packages="numpy<1.17 opencv-python<4.3"
1515
for pkg in $pip_packages
1616
do
17-
echo "sudo -H python2 -m pip install $pkg"
18-
sudo -H python2 -m pip install "$pkg"
17+
echo "sudo -H python -m pip install $pkg"
18+
sudo -H python -m pip install "$pkg"
1919
done

src/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
set(CMAKE_CXX_STANDARD 17)
2+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
3+
set(CMAKE_CXX_EXTENSIONS OFF)
4+
set(CMAKE_VERBOSE_MAKEFILE ON)
15
add_subdirectory(openpose)

src/openpose/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
set(CMAKE_CXX_STANDARD 17)
2+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
3+
set(CMAKE_CXX_EXTENSIONS OFF)
4+
set(CMAKE_VERBOSE_MAKEFILE ON)
5+
16
include(${CMAKE_SOURCE_DIR}/cmake/Utils.cmake)
27
subdirlist(SUB_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
38
foreach (SUB_DIR ${SUB_DIRS})

0 commit comments

Comments
 (0)