Skip to content

Commit

Permalink
Add files
Browse files Browse the repository at this point in the history
  • Loading branch information
helloall1900 committed Mar 2, 2024
0 parents commit 1f18f2d
Show file tree
Hide file tree
Showing 71 changed files with 46,921 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/ci_macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: macOS

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: macos-latest

steps:
- uses: actions/checkout@v3

- name: Install dependencies
run: |
brew install opencv@4 ffmpeg@5 fftw sqlite spdlog
brew link ffmpeg@5
brew install googletest google-benchmark
- name: Make vhash
run: |
make dev
- name: Test vhash
run: |
make test
31 changes: 31 additions & 0 deletions .github/workflows/ci_ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Ubuntu

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Install dependencies
run: |
sudo add-apt-repository ppa:savoury1/ffmpeg4 -y
sudo add-apt-repository ppa:savoury1/ffmpeg5 -y
sudo apt-get update
sudo apt install libopencv-dev libavformat-dev libavcodec-dev libavdevice-dev libavutil-dev libswscale-dev
sudo apt install libfftw3-dev libsqlite3-dev libspdlog-dev
sudo apt install libgtest-dev libbenchmark-dev
- name: Make vhash
run: |
make dev
- name: Test vhash
run: |
make test
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.idea
.vscode

bin
build
cmake-build-*
__pycache__

*.o
*.a
*.so
*.dylib
*.dll
*.exe
.DS_Store*
*.pyc
169 changes: 169 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
cmake_minimum_required(VERSION 3.11)
project(vhash)

set(CMAKE_CXX_STANDARD 14)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake" CACHE INTERNAL "")

# options
option(BUILD_TEST "Build Unit Test" OFF)
option(BUILD_BENCH "Build Benchmark" OFF)
option(FFMPEG5 "Build with FFmpeg@5" ON)

# dependencies
## opencv
find_package(OpenCV REQUIRED core imgproc highgui)
include_directories(${OpenCV_INCLUDE_DIRS})

## ffmpeg
find_package(FFMPEG REQUIRED)
include_directories("${FFMPEG_INCLUDE_DIRS}")
if (FFMPEG5)
add_definitions(-DFFMPEG5)
endif(FFMPEG5)

## spdlog
find_package(spdlog REQUIRED)

## fftw
find_package(FFTW REQUIRED)
include_directories(PkgConfig::FFTW)

## sqlite3
find_package(SQLite3 REQUIRED)

## wavelib
add_subdirectory("${CMAKE_SOURCE_DIR}/third_party/wavelib")
include_directories("${CMAKE_SOURCE_DIR}/third_party/wavelib/header")

## sqlite_orm
include_directories("${CMAKE_SOURCE_DIR}/third_party/sqlite_orm/include")

## cpptqdm
include_directories("${CMAKE_SOURCE_DIR}/third_party/cpptqdm/include")

## CLI11
include_directories("${CMAKE_SOURCE_DIR}/third_party/CLI11/include")

# directory
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)

# include
include_directories(${CMAKE_SOURCE_DIR}/include)

# source
file(GLOB APP_SRC ${CMAKE_SOURCE_DIR}/src/app/*.cpp)
file(GLOB CACHE_SRC ${CMAKE_SOURCE_DIR}/src/cache/*.cpp)
file(GLOB HASH_SRC ${CMAKE_SOURCE_DIR}/src/hash/*.cpp)
file(GLOB SCAN_SRC ${CMAKE_SOURCE_DIR}/src/scan/*.cpp)
file(GLOB UTIL_SRC ${CMAKE_SOURCE_DIR}/src/util/*.cpp)
set(ALL_SRC ${APP_SRC} ${CACHE_SRC} ${HASH_SRC} ${SCAN_SRC} ${UTIL_SRC})

# libraries
set(DEP_LIBRARIES ${OpenCV_LIBS} spdlog::spdlog PkgConfig::FFTW ${FFTW_DOUBLE_THREADS_LIB} wavelib SQLite::SQLite3 ${FFMPEG_LIBS})

# cmd
add_executable(
vhash
${CMAKE_SOURCE_DIR}/cmd/vhash.cpp
${ALL_SRC}
)
target_link_libraries(
vhash
${DEP_LIBRARIES}
)

install(TARGETS vhash DESTINATION bin)

# test
if (BUILD_TEST)
find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIRS})

add_executable(
imagehash_test
${CMAKE_SOURCE_DIR}/tests/imagehash_test.cpp
${ALL_SRC}
)
target_link_libraries(
imagehash_test
${GTEST_BOTH_LIBRARIES}
${DEP_LIBRARIES}
)

add_executable(
hash_test
${CMAKE_SOURCE_DIR}/tests/hash_test.cpp
${ALL_SRC}
)
target_link_libraries(
hash_test
${GTEST_BOTH_LIBRARIES}
${DEP_LIBRARIES}
)

add_executable(
cache_test
${CMAKE_SOURCE_DIR}/tests/cache_test.cpp
${ALL_SRC}
)
target_link_libraries(
cache_test
${GTEST_BOTH_LIBRARIES}
${DEP_LIBRARIES}
)

add_executable(
scan_test
${CMAKE_SOURCE_DIR}/tests/scan_test.cpp
${ALL_SRC}
)
target_link_libraries(
scan_test
${GTEST_BOTH_LIBRARIES}
${DEP_LIBRARIES}
)

add_test(Test imagehash_test hash_test)
enable_testing()
endif(BUILD_TEST)

# benchmark
if(BUILD_BENCH)
find_package(benchmark REQUIRED)

add_executable(
imagehash_bench
${CMAKE_SOURCE_DIR}/tests/imagehash_bench.cpp
${ALL_SRC}
)
target_link_libraries(
imagehash_bench
benchmark::benchmark
${DEP_LIBRARIES}
)

add_executable(
hash_bench
${CMAKE_SOURCE_DIR}/tests/hash_bench.cpp
${ALL_SRC}
)
target_link_libraries(
hash_bench
benchmark::benchmark
${DEP_LIBRARIES}
)

add_executable(
cache_bench
${CMAKE_SOURCE_DIR}/tests/cache_bench.cpp
${ALL_SRC}
)
target_link_libraries(
cache_bench
benchmark::benchmark
${DEP_LIBRARIES}
)
endif(BUILD_BENCH)
15 changes: 15 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Copyright (c) 2022 Leo

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of
the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 changes: 34 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
.PHONY: all debug release dev install clean test bench pytest pybench

all: release

debug:
@mkdir -p build && cd build && cmake .. && make

release:
@mkdir -p build && cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && make

dev:
@mkdir -p build && cd build && cmake -DBUILD_TEST=ON -DBUILD_BENCH=ON .. && make

install:
@mkdir -p build && cd build && make install

clean:
@rm -rf build

test:
@bin/imagehash_test
@bin/hash_test
@bin/cache_test

bench:
@bin/imagehash_bench
@bin/hash_bench
@bin/cache_bench

pytest:
@python3 tests/python/pyimagehash.py

pybench:
@python3 tests/python/pyimagehash.py bench
Loading

0 comments on commit 1f18f2d

Please sign in to comment.