-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix android build and do some code refactoring (#3)
* fix android script * fix line break * reformat the code * move CMakeLists.txt to platforms/desktop * remove build folder * remove vs projects ' * added ios project * update readme * update format-code.sh permission
- Loading branch information
Showing
44 changed files
with
4,820 additions
and
5,254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
BasedOnStyle: LLVM | ||
IndentWidth: 4 | ||
TabWidth: 4 | ||
BreakBeforeBraces: Stroustrup | ||
AlwaysBreakTemplateDeclarations: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,10 @@ | |
# Executables | ||
*.exe | ||
*.out | ||
*.app | ||
*.app | ||
|
||
project.xcworkspace/ | ||
xcuserdata/ | ||
*~ | ||
.history | ||
xcshareddata/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,67 @@ | ||
## ezSIFT: An easy-to-use stanalone SIFT library. | ||
* Original URL: https://sourceforge.net/projects/ezsift | ||
* github URL: https://github.com/robertwgh/ezSIFT | ||
|
||
The SIFT (scale-invariant feature transform) algorithm is considered to be one of the most robust local feature detector and description methods. Most of the open-source SIFT implementations rely on some 3rd-party libraries. Some of them even rely on a few different large libraries. These dependencies make the installation, compilation and usage not easy. | ||
|
||
The ezSIFT library provides a standalone and lightweight SIFT implementation written in C/C++. The ezSIFT is self-contained, and does not require any other libraries. So it is easy to use and modify. Besides, the implementation of the ezSIFT is straightforward and easy to read. | ||
|
||
For this project, C/C++ source code, Visual Studio 2010、2012 project files, and Android NDK project files are provided. | ||
|
||
### Documentation | ||
Please read [ezSIFT Wiki page](https://github.com/robertwgh/ezSIFT/wiki) for details. | ||
|
||
### Versions | ||
* Created on 9/16/2013. | ||
* Modified on 3/27/2015. | ||
* Uploaded to github.com on 6/26/2018. | ||
|
||
### Examples | ||
I also provide two examples showing how to use this library: | ||
|
||
* `examples/feature_extract.cpp`: detect keypoints and extract feature descriptor from a single image. | ||
* `examples/image_match.cpp`: detect keypoints and extract features from two images and perform feature matching. | ||
|
||
### How to build | ||
#### For Mac OS | ||
Follow the following instructions: | ||
```Bash | ||
mkdir build | ||
cd build | ||
cmake .. | ||
make | ||
``` | ||
Then you can find the built binary under `build/bin` directory. | ||
|
||
Or, you can use the following instruction to generate Xcode project: | ||
```Bash | ||
mkdir build | ||
cd build | ||
cmake .. -GXcode | ||
``` | ||
Then, open `ezsift.xcodeproj` project to build. | ||
|
||
#### For Visual Studio 2010/2012 (currently VS project is broken, I will fix them soon.) | ||
1. Go to `build/vs2010` or `build/vs2012`, open `ezsift.sln`. | ||
2. Build solution. | ||
3. You will find executable files under `build/vs2010/bin` or `build/vs2012/bin`. | ||
|
||
#### For Android NDK native mode | ||
1. Please install Android NDK package, and add NDK root folder to your system environment PATH. | ||
2. Go to `build/android`. | ||
3. run `./build.sh` | ||
4. You will find the binaries under `build/android/bin/`. | ||
5. Connect an Android device to your computer using ADB. Use `install_and_run.sh` to install the binaries and run it on the devices. | ||
|
||
### License | ||
|
||
Copyright 2013 Guohui Wang | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
## ezSIFT: An easy-to-use stanalone SIFT library. | ||
* Original URL: https://sourceforge.net/projects/ezsift | ||
* github URL: https://github.com/robertwgh/ezSIFT | ||
|
||
The SIFT (scale-invariant feature transform) algorithm is considered to be one of the most robust local feature detector and description methods. Most of the open-source SIFT implementations rely on some 3rd-party libraries. Some of them even rely on a few different large libraries. These dependencies make the installation, compilation and usage not easy. | ||
|
||
The ezSIFT library provides a standalone and lightweight SIFT implementation written in C/C++. The ezSIFT is self-contained, and does not require any other libraries. So it is easy to use and modify. Besides, the implementation of the ezSIFT is straightforward and easy to read. | ||
|
||
For this project, C/C++ source code, Visual Studio 2010、2012 project files, and Android NDK project files are provided. | ||
|
||
### Documentation | ||
Please read [ezSIFT Wiki page](https://github.com/robertwgh/ezSIFT/wiki) for details. | ||
|
||
### Examples | ||
I also provide two examples showing how to use this library: | ||
|
||
* `examples/feature_extract`: detect keypoints and extract feature descriptor from a single image. | ||
* `examples/image_match`: detect keypoints and extract features from two images and perform feature matching. | ||
|
||
### How to build | ||
#### For Mac OS | ||
Follow the following instructions: | ||
```Bash | ||
cd platforms/desktop/ | ||
mkdir build | ||
cd build | ||
cmake .. | ||
make | ||
``` | ||
Then you can find the built binary under `build/bin` directory. Run the two demos like this: | ||
|
||
```bash | ||
./image_match img1.pgm img2.pgm | ||
./feature_extract img1.pgm | ||
``` | ||
|
||
Or, you can use the following instruction to generate Xcode project: | ||
```Bash | ||
cd platforms/desktop/ | ||
mkdir build | ||
cd build | ||
cmake .. -GXcode | ||
``` | ||
Then, open `ezsift.xcodeproj` project to build. | ||
|
||
#### For Android NDK native mode | ||
1. Please install Android NDK package, and add NDK root folder to your system environment PATH. | ||
2. Go to `platforms/android`. | ||
3. run `./build.sh` | ||
4. You will find the binaries under `build/android/bin/`. | ||
5. Connect an Android device to your computer using ADB. Use `install_and_run.sh` to install the binaries and run it on the devices. | ||
|
||
### License | ||
|
||
Copyright 2013 Guohui Wang | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
127 changes: 64 additions & 63 deletions
127
examples/feature_extract/feature_extract.cpp
100755 → 100644
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,64 @@ | ||
/* Copyright (c) 2013, Robert Wang, email: robertwgh (at) gmail.com | ||
All rights reserved. https://github.com/robertwgh/ezSIFT | ||
Description: Detect keypoints and extract descriptors from an input image. | ||
Revision history: | ||
September 15th, 2013: initial version. | ||
July 2nd, 2018: code refactor. | ||
*/ | ||
|
||
#include "ezsift.h" | ||
|
||
#include <iostream> | ||
#include <list> | ||
|
||
#define USE_FIX_FILENAME 0 | ||
int main(int argc, char * argv[]) | ||
{ | ||
|
||
#if USE_FIX_FILENAME | ||
char *file1 = "img1.pgm"; | ||
#else | ||
if (argc != 2) | ||
{ | ||
std::cerr << "Please input an input image name.\nUsage: feature_extract img" << std::endl; | ||
return -1; | ||
} | ||
char file1[255]; | ||
memcpy(file1, argv[1], sizeof(char) * strlen(argv[1])); | ||
file1[strlen(argv[1])] = 0; | ||
#endif | ||
|
||
ezsift::Image<unsigned char> image; | ||
if(ezsift::read_pgm(file1, image.data, image.w, image.h)!=0) | ||
{ | ||
std::cerr << "Failed to open input image." << std::endl; | ||
return -1; | ||
} | ||
std::cout << "Image size: " << image.w << "x" << image.h << std::endl; | ||
|
||
bool bExtractDescriptor = true; | ||
std::list<ezsift::SiftKeypoint> kpt_list; | ||
|
||
// Double the original image as the first octive. | ||
ezsift::double_original_image(true); | ||
|
||
// Perform SIFT computation on CPU. | ||
std::cout << "Start SIFT detection ..." << std::endl; | ||
ezsift::sift_cpu(image, kpt_list, bExtractDescriptor); | ||
|
||
// Generate output image with keypoints drawing | ||
char filename[255]; | ||
sprintf(filename, "%s_sift_output.ppm", file1); | ||
ezsift::draw_keypoints_to_ppm_file(filename, image, kpt_list); | ||
|
||
// Generate keypoints list | ||
sprintf(filename, "%s_sift_key.key", file1); | ||
ezsift::export_kpt_list_to_file(filename, kpt_list, bExtractDescriptor); | ||
|
||
std::cout << "\nTotal keypoints number: \t\t" << static_cast<unsigned int>(kpt_list.size()) << std::endl; | ||
|
||
return 0; | ||
} | ||
/* Copyright (c) 2013, Robert Wang, email: robertwgh (at) gmail.com | ||
All rights reserved. https://github.com/robertwgh/ezSIFT | ||
Description: Detect keypoints and extract descriptors from an input image. | ||
Revision history: | ||
September 15th, 2013: initial version. | ||
July 2nd, 2018: code refactor. | ||
*/ | ||
|
||
#include "ezsift.h" | ||
|
||
#include <iostream> | ||
#include <list> | ||
|
||
#define USE_FIX_FILENAME 0 | ||
int main(int argc, char *argv[]) | ||
{ | ||
|
||
#if USE_FIX_FILENAME | ||
char *file1 = "img1.pgm"; | ||
#else | ||
if (argc != 2) { | ||
std::cerr | ||
<< "Please input an input image name.\nUsage: feature_extract img" | ||
<< std::endl; | ||
return -1; | ||
} | ||
char file1[255]; | ||
memcpy(file1, argv[1], sizeof(char) * strlen(argv[1])); | ||
file1[strlen(argv[1])] = 0; | ||
#endif | ||
|
||
ezsift::Image<unsigned char> image; | ||
if (ezsift::read_pgm(file1, image.data, image.w, image.h) != 0) { | ||
std::cerr << "Failed to open input image." << std::endl; | ||
return -1; | ||
} | ||
std::cout << "Image size: " << image.w << "x" << image.h << std::endl; | ||
|
||
bool bExtractDescriptor = true; | ||
std::list<ezsift::SiftKeypoint> kpt_list; | ||
|
||
// Double the original image as the first octive. | ||
ezsift::double_original_image(true); | ||
|
||
// Perform SIFT computation on CPU. | ||
std::cout << "Start SIFT detection ..." << std::endl; | ||
ezsift::sift_cpu(image, kpt_list, bExtractDescriptor); | ||
|
||
// Generate output image with keypoints drawing | ||
char filename[255]; | ||
sprintf(filename, "%s_sift_output.ppm", file1); | ||
ezsift::draw_keypoints_to_ppm_file(filename, image, kpt_list); | ||
|
||
// Generate keypoints list | ||
sprintf(filename, "%s_sift_key.key", file1); | ||
ezsift::export_kpt_list_to_file(filename, kpt_list, bExtractDescriptor); | ||
|
||
std::cout << "\nTotal keypoints number: \t\t" | ||
<< static_cast<unsigned int>(kpt_list.size()) << std::endl; | ||
|
||
return 0; | ||
} |
Oops, something went wrong.