Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
8e4caa1
Init node module with yo napi-module object warp template
lamhoangtung Apr 20, 2021
19280a9
Minor
lamhoangtung Apr 20, 2021
61d3838
Minor
lamhoangtung Apr 20, 2021
4e220ff
Initial binding with cmake-js build
lamhoangtung Apr 20, 2021
70ab891
Various bugs fixed
lamhoangtung Apr 20, 2021
7bf294d
More bugs related to Napi::Object::PropertyLValue<unsigned int> fixed
lamhoangtung Apr 20, 2021
a13114c
Minor
lamhoangtung Apr 20, 2021
820ab49
Seems working if disable env.SetInstanceData(constructor);
lamhoangtung Apr 21, 2021
b1d6e6a
Proper testing
lamhoangtung Apr 21, 2021
b85414a
Minor bug fixed
lamhoangtung Apr 21, 2021
64e943b
Test less data
lamhoangtung Apr 21, 2021
93ec623
Drop boost
lamhoangtung Apr 21, 2021
225da8f
Strip dockerfile
lamhoangtung Apr 21, 2021
5c547b1
Update README
lamhoangtung Apr 21, 2021
b70b75d
Minor
lamhoangtung Apr 21, 2021
fd5ae8c
Minor name fixed
lamhoangtung Apr 21, 2021
afd3e77
Use yarn
lamhoangtung Apr 21, 2021
4c06ca0
Init CI with Github Action
lamhoangtung Apr 21, 2021
25baf0f
Run CI on every push
lamhoangtung Apr 21, 2021
932cd51
Try to install eigen and opencv for all OS
lamhoangtung Apr 21, 2021
f8a72d3
Attemp to set missing eigen on MacOS
lamhoangtung Apr 21, 2021
6bb3fd8
Include Eigen path bug fixed for MacOS
lamhoangtung Apr 21, 2021
e6caed2
Minor
lamhoangtung Apr 21, 2021
355f534
Fix wrong license code
lamhoangtung Apr 21, 2021
08aa991
Focus CI Windows
lamhoangtung Apr 21, 2021
f27fa00
Hmmm
lamhoangtung Apr 21, 2021
66518cf
Attemp to build opencv from source
lamhoangtung Apr 21, 2021
9157798
Syntax fixed
lamhoangtung Apr 21, 2021
a58760e
Syntax fixed again
lamhoangtung Apr 21, 2021
819abd8
hmmm 2
lamhoangtung Apr 21, 2021
ccc0063
hmmm 3
lamhoangtung Apr 21, 2021
8200303
Minor
lamhoangtung Apr 22, 2021
fe31117
Set opencv to 3.4.14 on windows
lamhoangtung Apr 22, 2021
3d75f32
Hmmm 3
lamhoangtung Apr 22, 2021
8c6dc70
Minimize OpenCV build config
lamhoangtung Apr 22, 2021
d8948e3
Simpify install OpenCV script
lamhoangtung Apr 22, 2021
517f8f7
Fix missing env var on Windows + cache OpenCV build windows
lamhoangtung Apr 22, 2021
016c628
Hmm cache seem not working yet
lamhoangtung Apr 22, 2021
9d8bab5
Minor OPENCV_DIR change
lamhoangtung Apr 22, 2021
a59fab8
Cache opencv only first lol Github
lamhoangtung Apr 22, 2021
825cb9c
Full flow back online
lamhoangtung Apr 22, 2021
fd49eb9
Hmmm 4
lamhoangtung Apr 22, 2021
2ba0c51
Hmmm 5
lamhoangtung Apr 22, 2021
94c2bde
Hmmm 5
lamhoangtung Apr 22, 2021
3079f4f
Hmmm 6
lamhoangtung Apr 22, 2021
0530331
Hmmm 7
lamhoangtung Apr 22, 2021
8d62e00
Hmmmm 8
lamhoangtung Apr 22, 2021
6c6b9ba
Haizzz
lamhoangtung Apr 22, 2021
738fa54
Haizzz 2
lamhoangtung Apr 22, 2021
bdd305a
Haizz 3
lamhoangtung Apr 22, 2021
90ac04f
Haizzz 4
lamhoangtung Apr 22, 2021
acdb5f7
Haizz 5
lamhoangtung Apr 22, 2021
5922cbe
lol ?
lamhoangtung Apr 22, 2021
423a845
lol 2 ?
lamhoangtung Apr 22, 2021
4252ee8
lol 3 ?
lamhoangtung Apr 22, 2021
199c8bf
lol 4 ?
lamhoangtung Apr 22, 2021
95105c5
lol 5 ?
lamhoangtung Apr 22, 2021
9e152ed
Fix missing M_PI for windows
lamhoangtung Apr 22, 2021
e4aebe6
Minor
lamhoangtung Apr 22, 2021
1e1b902
Trim \r for ground truth on Windows test
lamhoangtung Apr 22, 2021
88edea6
Minor bug fixed
lamhoangtung Apr 22, 2021
f5b2216
Turn on all 3 OS, cache openCV install for linux as well
lamhoangtung Apr 22, 2021
35a6c0a
Update prebuild process
lamhoangtung Apr 22, 2021
1c16962
Minor bug fixed
lamhoangtung Apr 22, 2021
dbd6328
hmmm ubuntu cache fail ?
lamhoangtung Apr 22, 2021
bba8186
why ubuntu cache fail ???
lamhoangtung Apr 22, 2021
6930e13
Minor
lamhoangtung Apr 22, 2021
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
107 changes: 107 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: CI

on:
push:
branches:
- '**'
pull_request:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
if: "!contains(github.event.head_commit.message, 'ci skip')"

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install node
uses: actions/setup-node@v1
with:
node-version: "14"

- name: Cache OpenCV for Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions/cache@v2
id: cache-opencv-linux
with:
path: /home/runner/work/sort-node/sort-node/opencv/build
key: cache-opencv-linux

- name: Install OpenCV for Linux
if: matrix.os == 'ubuntu-latest'
uses: Dovyski/setup-opencv-action@v1
with:
opencv-version: '3.4.2'
opencv-extra-modules: false

- name: Install Eigen for Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt-get update && sudo apt-get install -y libeigen3-dev

- name: Install OpenCV and Eigen for Mac
if: ${{ matrix.os == 'macos-latest'}}
run: brew install opencv3 eigen

- name: Cache OpenCV for Windows
if: ${{ matrix.os == 'windows-latest' }}
uses: actions/cache@v2
id: cache-opencv-windows
with:
path: .github\workflows\scripts\opencv-3.4.14
key: ${{ runner.os }}-${{ hashFiles('.github/workflows/scripts/installOpenCV.bat') }}

- name: Install OpenCV for Windows
if: matrix.os == 'windows-latest' && steps.cache-opencv-windows.outputs.cache-hit != 'true'
run: |
cd .github/workflows/scripts
./installOpenCV.bat

- name: Install Eigen for Windows
if: ${{ matrix.os == 'windows-latest' }}
run: |
curl https://gitlab.com/libeigen/eigen/-/archive/3.3.9/eigen-3.3.9.zip -o eigen-3.3.9.zip -s
mkdir "C:\eigen"
unzip eigen-3.3.9.zip -d "C:\eigen"
mv C:\eigen\eigen-3.3.9 C:\eigen\Eigen3
setx EIGEN3_INCLUDE_DIR C:\eigen

- name: Install packages
run: yarn upgrade --dev

- name: Prebuild for Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
env:
OpenCV_DIR: /home/runner/work/sort-node/sort-node/opencv/build
run: yarn build-prebuild

- name: Prebuild for Mac
if: ${{ matrix.os == 'macos-latest' }}
run: yarn build-prebuild

- name: Prebuild for Windows
if: ${{ matrix.os == 'windows-latest' }}
env:
OpenCV_DIR: D:/a/sort-node/sort-node/.github/workflows/scripts/opencv-3.4.14/opencv/build/
EIGEN3_INCLUDE_DIR: C:/eigen
run: yarn build-prebuild

- name: Build
run: yarn install

- name: Run test suite
run: yarn test

- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: artifact-${{ matrix.os }}
path: prebuilds/**/*.tar.gz
36 changes: 36 additions & 0 deletions .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: publish-npm

on:
push:
tags:
- "v*.*.*"

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'publish-npm skip')"

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install node
uses: actions/setup-node@v1
with:
node-version: "14"
registry-url: "https://registry.npmjs.org"

- name: Install packages
run: yarn upgrade --dev

- name: Build
run: yarn install

- name: Publish
run: yarn publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
94 changes: 94 additions & 0 deletions .github/workflows/publish-prebuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: publish-prebuild

on:
push:
tags:
- "v*.*.*"

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
if: "!contains(github.event.head_commit.message, 'ci skip')"

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install node
uses: actions/setup-node@v1
with:
node-version: "14"

- name: Cache OpenCV for Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions/cache@v2
id: cache-opencv-linux
with:
path: /home/runner/work/sort-node/sort-node/opencv/build
key: cache-opencv-linux

- name: Install OpenCV for Linux
if: matrix.os == 'ubuntu-latest'
uses: Dovyski/setup-opencv-action@v1
with:
opencv-version: '3.4.2'
opencv-extra-modules: false

- name: Install Eigen for Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt-get update && sudo apt-get install -y libeigen3-dev

- name: Install OpenCV and Eigen for Mac
if: ${{ matrix.os == 'macos-latest'}}
run: brew install opencv3 eigen

- name: Cache OpenCV for Windows
if: ${{ matrix.os == 'windows-latest' }}
uses: actions/cache@v2
id: cache-opencv-windows
with:
path: .github\workflows\scripts\opencv-3.4.14
key: ${{ runner.os }}-${{ hashFiles('.github/workflows/scripts/installOpenCV.bat') }}

- name: Install OpenCV for Windows
if: matrix.os == 'windows-latest' && steps.cache-opencv-windows.outputs.cache-hit != 'true'
run: |
cd .github/workflows/scripts
./installOpenCV.bat

- name: Install Eigen for Windows
if: ${{ matrix.os == 'windows-latest' }}
run: |
curl https://gitlab.com/libeigen/eigen/-/archive/3.3.9/eigen-3.3.9.zip -o eigen-3.3.9.zip -s
mkdir "C:\eigen"
unzip eigen-3.3.9.zip -d "C:\eigen"
mv C:\eigen\eigen-3.3.9 C:\eigen\Eigen3
setx EIGEN3_INCLUDE_DIR C:\eigen

- name: Install packages
run: yarn upgrade --dev

- name: Prebuild for Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
env:
OpenCV_DIR: /home/runner/work/sort-node/sort-node/opencv/build
run: yarn build-prebuild -u ${{ secrets.ACCESS_GITHUB_TOKEN }}

- name: Prebuild for Mac
if: ${{ matrix.os == 'macos-latest' }}
run: yarn build-prebuild -u ${{ secrets.ACCESS_GITHUB_TOKEN }}

- name: Prebuild for Windows
if: ${{ matrix.os == 'windows-latest' }}
env:
OpenCV_DIR: D:/a/sort-node/sort-node/.github/workflows/scripts/opencv-3.4.14/opencv/build/
EIGEN3_INCLUDE_DIR: C:/eigen
run: yarn build-prebuild -u ${{ secrets.ACCESS_GITHUB_TOKEN }}
35 changes: 35 additions & 0 deletions .github/workflows/scripts/installOpenCV.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
::@echo off
setlocal enabledelayedexpansion
::DO_NOT_CHANGE::
::============================================::
set cvVersion=3.4.14
echo Installing OpenCV-%cvVersion%
::============================================::
mkdir opencv-%cvVersion%
cd opencv-%cvVersion%
mkdir Installation
set count=1
set cwd=%cd%
::============================================::
echo Downloading opencv from github
::download opencv from git
git clone https://github.com/opencv/opencv.git
cd opencv
::checkout appropriate cv version
git checkout %cvVersion%
cd ..
::============================================::
echo Compiling using cmake
cd opencv
mkdir build
cd build
::xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx::
::DO_NOT_CHANGE::
cmake -G "Visual Studio 16 2019" -T host=x64 -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=%cwd%/Installation -D BUILD_opencv_java=OFF -D BUILD_opencv_python=OFF ..
::DO_NOT_CHANGE::
::============================================::
::Compile OpenCV in release mode
cmake.exe --build . --config Release --target INSTALL
cd ..
cd ..
cd ..
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ build/
cmake-*/
mot_benchmark/
output/
node_modules/
package-lock.json
.DS_Store
prebuilds/
20 changes: 20 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/include/"
],
"defines": [],
"macFrameworkPath": [
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++98",
"intelliSenseMode": "macos-clang-x64"
}
],
"version": 4
}
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"files.associations": {
"memory": "cpp",
"utility": "cpp",
"chrono": "cpp",
"locale": "cpp",
"string": "cpp"
}
}
54 changes: 40 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.9)
cmake_policy(SET CMP0042 NEW)
set (CMAKE_CXX_STANDARD 11)

project(sort-cpp)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)

if (WIN32)
# This help to find OpenCV and Eigen, some how cmake on
# Windows doesn't use ENV variables so I had to re-set it here
set(OpenCV_DIR $ENV{OpenCV_DIR})
set(EIGEN3_INCLUDE_DIR $ENV{EIGEN3_INCLUDE_DIR})
endif()

# Try to find OpenCV
find_package(OpenCV REQUIRED)
Expand All @@ -18,22 +27,39 @@ else ()
message(FATAL_ERROR "Could not locate OpenCV")
endif()

# Try to find Boost
find_package(Boost COMPONENTS program_options filesystem REQUIRED)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
else ()
message(FATAL_ERROR "Could not locate Boost")
if(APPLE)
# Trying to include path to Eigen that was installed by brew
include_directories("/usr/local/include")
elseif(WIN32)
include_directories(${EIGEN3_INCLUDE_DIR})
endif()

include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${CMAKE_JS_INC})

file(GLOB SOURCE_FILES src/*.cpp src/*.cc src/*.h)

file(GLOB SOURCE_FILES src/*.cpp)

add_executable(${CMAKE_PROJECT_NAME} ${SOURCE_FILES})
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${CMAKE_JS_SRC})
# add_executable(${CMAKE_PROJECT_NAME}-bin ${SOURCE_FILES})

set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")

target_link_libraries (
${CMAKE_PROJECT_NAME}
${OpenCV_LIBS}
${Boost_LIBRARIES}
${CMAKE_PROJECT_NAME}
${OpenCV_LIBS}
${Boost_LIBRARIES}
)

target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB})

# Include Node-API wrappers
execute_process(COMMAND node -p "require('node-addon-api').include"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE NODE_ADDON_API_DIR
)
string(REGEX REPLACE "[\r\n\"]" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR})

target_include_directories(${PROJECT_NAME} PRIVATE ${NODE_ADDON_API_DIR})

# define NPI_VERSION
add_definitions(-DNAPI_VERSION=3)
Loading