Skip to content

Commit

Permalink
added npz-save, removed surf and mrogh
Browse files Browse the repository at this point in the history
  • Loading branch information
ducha-aiki committed Feb 3, 2021
1 parent e8569ff commit 4b06495
Show file tree
Hide file tree
Showing 71 changed files with 14,723 additions and 3,398 deletions.
26 changes: 12 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ cmake_minimum_required(VERSION 2.8)
PROJECT(MODS)

add_definitions(-DA64)
#add_definitions(-std=gnu++11)
add_definitions(-std=c++11)
add_definitions(-std=gnu++11)
#add_definitions(-std=c++11)
add_definitions(-fpermissive)


SET(WITH_CAFFE FALSE)

message("Looking for OpenCV")
SET (OpenCV_DIR "C:/opencv-2.4.8/opencv-2.4.8/build/install")
SET (OpenCV_DIR "c:/opencv-2.4.8/opencv-2.4.8/new_build/install/")
#set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "/windows/mods/mods-video/binary_desc/brisk/")
FIND_PACKAGE( OpenCV REQUIRED core imgproc highgui)
FIND_PACKAGE( OpenCV)
if (OPENCV_FOUND)
message("Found!")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenCV_CXX_FLAGS}")
Expand All @@ -29,7 +30,7 @@ endif (OPENCV_FOUND)
#FIND_PACKAGE(CUDA REQUIRED)

enable_language (Fortran)
# set(LAPACK_DIR "${CMAKE_SOURCE_DIR}/lapack_for_windows")
set(LAPACK_DIR "${CMAKE_SOURCE_DIR}/lapack_for_windows")

FIND_PACKAGE(LAPACK)
if (LAPACK_FOUND)
Expand All @@ -42,6 +43,7 @@ endif (LAPACK_FOUND)

FIND_PACKAGE(OpenMP)
if (OPENMP_FOUND)
message("OpenMP found")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
Expand All @@ -68,9 +70,10 @@ add_subdirectory( ./matutls)
add_subdirectory( ./detectors)
add_subdirectory( ./detectors/affinedetectors)
add_subdirectory( ./detectors/mser )
add_subdirectory( ./opensurf )
add_subdirectory( ./libMatch)
add_subdirectory( ./libNumerics)
add_subdirectory( ./cnpy)


####### DEGENSAC
include_directories(
Expand Down Expand Up @@ -122,12 +125,8 @@ include_directories(.)
link_directories(c:/opencv-2.4.8/opencv-2.4.8/build/install/x86/mingw/lib)
add_library(synth-detection ${synth-detection_srcs})

TARGET_LINK_LIBRARIES(synth-detection matching opensurf
mser affinedetectors helpers opencv_features2d opencv_core opencv_highgui)
TARGET_LINK_LIBRARIES(synth-detection matching mser affinedetectors helpers opencv_features2d opencv_core opencv_highgui)

#include_directories(.
#./dali)
#./smsld)

link_directories(${CMAKE_SOURCE_DIR}/lapack_for_windows/lib)
link_directories(c:/opencv-2.4.8/opencv-2.4.8/build/install/x86/mingw/lib)
Expand All @@ -136,9 +135,8 @@ io_mods.cpp ssdesc-cpp-1.1.1/ssdesc.cc)#smsld/wzhlib.cpp smsld/descriptor.cpp s

link_directories(${CMAKE_SOURCE_DIR}/lapack_for_windows/lib)
TARGET_LINK_LIBRARIES(mods inih matching synth-detection mser affinedetectors
opencv_features2d opencv_core opencv_highgui m )
opencv_features2d opencv_core opencv_highgui m cnpy-static zlib)

add_executable(extract_features extract_features.cpp correspondencebank.cpp imagerepresentation.cpp
io_mods.cpp ssdesc-cpp-1.1.1/ssdesc.cc) # smsld/wzhlib.cpp smsld/descriptor.cpp smsld/Match.cpp smsld/Image.cpp)
TARGET_LINK_LIBRARIES(extract_features inih matching synth-detection mser affinedetectors
opencv_features2d opencv_core opencv_highgui m )
TARGET_LINK_LIBRARIES(extract_features inih matching synth-detection mser affinedetectors opencv_features2d opencv_core opencv_highgui m cnpy-static zlib)
16 changes: 16 additions & 0 deletions build/iters_load.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Iterations]
Steps=1; max number of steps
minMatches=10
[HessianAffine0]
initSigma=0.2
TiltSet=1; floating numbers separated with comma
ScaleSet=1;no need of scale sampling
Phi=360;
Descriptors=RootSIFT;RootSIFT; //
FGINNThreshold=0.8 ; The same order, as in "Descriptors"!
DistanceThreshold=0; The same order, as in "Descriptors"!
[Matching0]
SeparateDetectors=HessianAffine;FAST; Or "All"
GroupDetectors=;HessianAffine;, DoG
SeparateDescriptors=RootSIFT;RootSIFT;h
GroupDescriptors=;RootSIFT;[MSER3]
28 changes: 28 additions & 0 deletions cnpy/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.0 FATAL_ERROR)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)

project(CNPY)

add_definitions(-std=c++11)

option(ENABLE_STATIC "Build static (.a) library" ON)
add_subdirectory(./zlib)
include_directories(${ZLIB_INCLUDE_DIRS})

add_library(cnpy SHARED "cnpy.cpp")
target_link_libraries(cnpy zlib)
#install(TARGETS "cnpy" LIBRARY DESTINATION lib PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)

if(ENABLE_STATIC)
add_library(cnpy-static STATIC "cnpy.cpp")
set_target_properties(cnpy-static PROPERTIES OUTPUT_NAME "cnpy")
install(TARGETS "cnpy-static" ARCHIVE DESTINATION lib)
endif(ENABLE_STATIC)

#install(FILES "cnpy.h" DESTINATION include)
#install(FILES "mat2npz" "npy2mat" "npz2mat" DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)

#add_executable(example1 example1.cpp)
#target_link_libraries(example1 cnpy)
21 changes: 21 additions & 0 deletions cnpy/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License

Copyright (c) Carl Rogers, 2011

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.
55 changes: 55 additions & 0 deletions cnpy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Purpose:

NumPy offers the `save` method for easy saving of arrays into .npy and `savez` for zipping multiple .npy arrays together into a .npz file.

`cnpy` lets you read and write to these formats in C++.

The motivation comes from scientific programming where large amounts of data are generated in C++ and analyzed in Python.

Writing to .npy has the advantage of using low-level C++ I/O (fread and fwrite) for speed and binary format for size.
The .npy file header takes care of specifying the size, shape, and data type of the array, so specifying the format of the data is unnecessary.

Loading data written in numpy formats into C++ is equally simple, but requires you to type-cast the loaded data to the type of your choice.

# Installation:

Default installation directory is /usr/local.
To specify a different directory, add `-DCMAKE_INSTALL_PREFIX=/path/to/install/dir` to the cmake invocation in step 4.

1. get [cmake](www.cmake.org)
2. create a build directory, say $HOME/build
3. cd $HOME/build
4. cmake /path/to/cnpy
5. make
6. make install

# Using:

To use, `#include"cnpy.h"` in your source code. Compile the source code mycode.cpp as

```bash
g++ -o mycode mycode.cpp -L/path/to/install/dir -lcnpy -lz --std=c++11
```

# Description:

There are two functions for writing data: `npy_save` and `npz_save`.

There are 3 functions for reading:
- `npy_load` will load a .npy file.
- `npz_load(fname)` will load a .npz and return a dictionary of NpyArray structues.
- `npz_load(fname,varname)` will load and return the NpyArray for data varname from the specified .npz file.

The data structure for loaded data is below.
Data is accessed via the `data<T>()`-method, which returns a pointer of the specified type (which must match the underlying datatype of the data).
The array shape and word size are read from the npy header.

```c++
struct NpyArray {
std::vector<size_t> shape;
size_t word_size;
template<typename T> T* data();
};
```
See [example1.cpp](example1.cpp) for examples of how to use the library. example1 will also be build during cmake installation.
Loading

0 comments on commit 4b06495

Please sign in to comment.