Created
May 28, 2015 16:27
-
-
Save junk-labs/c3e22bd0c81aa8f66057 to your computer and use it in GitHub Desktop.
https://github.com/kazukioishi/waifu2x-converter-cpp をWindowsでビルド出来るようにするパッチ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CMakeLists.txt | 33 ++++++++++++++++++++++++++++----- | |
src/main.cpp | 13 +++++++------ | |
2 files changed, 35 insertions(+), 11 deletions(-) | |
diff --git a/CMakeLists.txt b/CMakeLists.txt | |
index cc7c421..3d09501 100644 | |
--- a/CMakeLists.txt | |
+++ b/CMakeLists.txt | |
@@ -1,7 +1,30 @@ | |
cmake_minimum_required(VERSION 2.8) | |
-project(waifu2x-converter-cpp) | |
+ | |
+include(CheckCXXCompilerFlag) | |
+project(waifu2x-converter-cpp CXX) | |
+ | |
+if(NOT (MSVC_VERSION LESS 1600)) #1600 == VS 10 == Visual Studio 2010, this logic is actually >= | |
+ message(STATUS "Using MSVC 2010+ compiler. C++11 support is native.") | |
+else(NOT (MSVC_VERSION LESS 1600)) | |
+ message(STATUS "Checking C++11 support...") | |
+ include(CheckCXXCompilerFlag) | |
+ CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) | |
+ CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) | |
+ if(COMPILER_SUPPORTS_CXX11) | |
+ set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++11") | |
+ message(STATUS "Full support of C++11 found.") | |
+ elseif(COMPILER_SUPPORTS_CXX0X) | |
+ set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++0x") | |
+ message(STATUS "Support for C++0x found.") | |
+ else(COMPILER_SUPPORTS_CXX11) | |
+ add_definitions(-D_STONEAGECplusplus) | |
+ message(STATUS "Stoneage C++ mode enabled.") | |
+ endif(COMPILER_SUPPORTS_CXX11) | |
+endif(NOT (MSVC_VERSION LESS 1600)) | |
+ | |
+set(CMAKE_PREFIX_PATH "opencv-install") | |
find_package(OpenCV REQUIRED) | |
-include_directories("./include") | |
-add_executable(waifu2x src/main.cpp src/modelHandler.cpp) | |
-TARGET_LINK_LIBRARIES(waifu2x opencv_core opencv_imgproc opencv_imgcodecs opencv_features2d) | |
-set_property(TARGET waifu2x PROPERTY CXX_STANDARD 11) | |
+include_directories(include ${OpenCV_INCLUDE_DIRS}) | |
+add_executable(waifu2x-converter-cpp src/modelHandler.cpp src/main.cpp) | |
+target_link_libraries(waifu2x-converter-cpp ${OpenCV_LIBS}) | |
+ | |
diff --git a/src/main.cpp b/src/main.cpp | |
index 4918bee..6dd86af 100644 | |
--- a/src/main.cpp | |
+++ b/src/main.cpp | |
@@ -14,7 +14,6 @@ | |
#include <fstream> | |
#include <string> | |
#include <cmath> | |
-#include <sys/time.h> | |
#include "picojson.h" | |
#include "tclap/CmdLine.h" | |
@@ -75,13 +74,15 @@ int main(int argc, char** argv) { | |
} | |
//set useOpenCL | |
- if(cmdUseCL.getValue()){ | |
+ if (cmdUseCL.getValue() && cv::ocl::haveOpenCL()){ | |
std::cout << "Using OpenCL...." << std::endl; | |
UseOpenCL = true; | |
} | |
+ else { | |
+ std::cout << "Using CPU...." << std::endl; | |
+ } | |
//timer | |
- struct timeval startTime, finishTime; | |
- gettimeofday(&startTime, NULL); | |
+ double time = (double)cv::getTickCount(); | |
// load image file | |
cv::Mat image = cv::imread(cmdInputFile.getValue(), cv::IMREAD_COLOR); | |
@@ -254,8 +255,8 @@ int main(int argc, char** argv) { | |
} | |
cv::imwrite(outputFileName, image); | |
- gettimeofday(&finishTime, NULL); | |
- std::cout << (finishTime.tv_sec - startTime.tv_sec) * 1000 + (finishTime.tv_usec - startTime.tv_usec) / 1000 << "msec." << std::endl; | |
+ time = ((double)cv::getTickCount() - time) / cv::getTickFrequency(); | |
+ std::cout << time << "sec." << std::endl; | |
std::cout << "process successfully done!" << std::endl; | |
return 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment