Skip to content

Commit

Permalink
Merge pull request #16 from Sologala/build-for-macos
Browse files Browse the repository at this point in the history
build_for_macos
bbenligiray authored Apr 26, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 9d0a5cd + fa132ec commit 6ea0f3b
Showing 5 changed files with 981 additions and 742 deletions.
50 changes: 50 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

project(Stag)

IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release)
ENDIF()

MESSAGE("Build type: " ${CMAKE_BUILD_TYPE})

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -w ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -w ")

# Check C++11 or C++0x support
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

find_package(OpenCV REQUIRED)

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
file(GLOB SRC_FILE1 "src/*.c*")
file(GLOB SRC_FILE2 "src/ED/*.c*")

include_directories(
${OpenCV_INCLUDE_DIRS}
src/
src/ED/
)
add_library(
LibStag SHARED
${SRC_FILE1}
${SRC_FILE2}
)
target_link_libraries(
LibStag
${OpenCV_LIBS}
)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/app)

add_executable(
testrun
main.cpp
)

target_link_libraries(
testrun
LibStag
)
12 changes: 12 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "Stag.h"
#include "opencv2/opencv.hpp"

int main() {
cv::Mat image = cv::imread("1.png", CV_LOAD_IMAGE_GRAYSCALE);

Stag stag(15, 7, true);

stag.detectMarkers(image);
stag.logResults("");
return 0;
}
62 changes: 50 additions & 12 deletions src/ED/Timer.h
Original file line number Diff line number Diff line change
@@ -1,33 +1,71 @@
#ifndef TIMER_H
#define TIMER_H

#define BUILD_MACOS

#ifndef BUILD_MACOS

#include <windows.h>

class Timer {
private:
__int64 freq, tStart, tStop;

public:
Timer(){
Timer() {
// Get the frequency of the hi-res timer
QueryPerformanceFrequency((LARGE_INTEGER*)&freq);
} //end-TimerClass
QueryPerformanceFrequency((LARGE_INTEGER *)&freq);
} // end-TimerClass

void Start(){
void Start() {
// Use hi-res timer
QueryPerformanceCounter((LARGE_INTEGER*)&tStart);
} //end-Start
QueryPerformanceCounter((LARGE_INTEGER *)&tStart);
} // end-Start

void Stop(){
void Stop() {
// Perform operations that require timing
QueryPerformanceCounter((LARGE_INTEGER*)&tStop);
} //end-Stop
QueryPerformanceCounter((LARGE_INTEGER *)&tStop);
} // end-Stop

// Returns time in milliseconds
double ElapsedTime(){
double ElapsedTime() {
// Calculate time difference in milliseconds
return ((double)(tStop - tStart)/(double)freq)*1e3;
} //end-Elapsed
return ((double)(tStop - tStart) / (double)freq) * 1e3;
} // end-Elapsed
};
#else

#include <chrono>
#include <ctime>
#include <sys/_types/_int64_t.h>
#include <sys/_types/_timespec.h>

class Timer {
private:
std::chrono::steady_clock::time_point testTime_t1, testTime_t2;

public:
Timer() {} // end-TimerClass

void Start() {
// Use hi-res timer
testTime_t1 = std::chrono::steady_clock::now();
} // end-Start

void Stop() {
// Perform operations that require timing
testTime_t2 = std::chrono::steady_clock::now();
} // end-Stop

// Returns time in milliseconds
double ElapsedTime() {
// Calculate time difference in milliseconds
return std::chrono::duration_cast<std::chrono::duration<double>>(
testTime_t2 - testTime_t1)
.count();
} // end-Elapsed
};

#endif // !1

#endif
1,586 changes: 869 additions & 717 deletions src/ED/Utilities.cpp

Large diffs are not rendered by default.

13 changes: 0 additions & 13 deletions src/main.cpp

This file was deleted.

0 comments on commit 6ea0f3b

Please sign in to comment.