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

build_for_macos #16

Merged
merged 1 commit into from
Apr 26, 2021
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
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
Loading