Skip to content

Commit d3f013c

Browse files
Add all
1 parent 79dd71e commit d3f013c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+4234
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@
3030
*.exe
3131
*.out
3232
*.app
33+
build

CMakeLists.txt

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
## CMake configuration file of Ellipsedetcet project
2+
3+
cmake_minimum_required (VERSION 2.4)
4+
5+
if (POLICY CMP0048)
6+
cmake_policy (SET CMP0048 NEW)
7+
endif ()
8+
9+
10+
if (COMMAND cmake_policy)
11+
cmake_policy (SET CMP0003 NEW)
12+
endif (COMMAND cmake_policy)
13+
14+
15+
set (PACKAGE_NAME "ellipse_detection")
16+
set (PACKAGE_VERSION "1.0")
17+
18+
19+
project (${PACKAGE_NAME} VERSION ${PACKAGE_VERSION} LANGUAGES CXX)
20+
21+
set (OpenCV_FOUND 1)
22+
find_package (OpenCV REQUIRED)
23+
24+
set (OTHER_LIBS -llapack)
25+
26+
set (CMAKE_CXX_STANDARD 11)
27+
set (CMAKE_CXX_STANDARD_REQUIRE ON)
28+
29+
set (EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin")
30+
set (LIBRARY_OUTPUT_PATH "${PROJECT_BINARY_DIR}/lib")
31+
32+
include_directories ("${PROJECT_SOURCE_DIR}/include")
33+
34+
add_definitions ("-Wall")
35+
36+
set (DEPEND_FILE
37+
"src/unitily.cpp"
38+
"src/detect.cpp"
39+
"src/compute.cpp"
40+
"src/lsd.cpp"
41+
"src/cvcannyapi.cpp"
42+
)
43+
44+
add_library (${PACKAGE_NAME} ${DEPEND_FILE})
45+
46+
target_link_libraries(${PACKAGE_NAME} ${Opencv_LIBS} ${OTHER_LIBS})
47+
48+
set (PUBLIC_HDRS
49+
include/types.hpp
50+
include/unitily.h
51+
include/defines.h
52+
include/detect.h
53+
include/compute.h
54+
)
55+
56+
set (INCLUDE_INSTALL_DIR "include/${PACKAGE_NAME}")
57+
set (RUNTIME_INSTALL_DIR "bin")
58+
set (LIBRARY_INSTALL_DIR "lib")
59+
60+
install (FILES ${PUBLIC_HDRS} DESTINATION ${INCLUDE_INSTALL_DIR}/${GFLAGS_INCLUDE_DIR})
61+
62+
install (TARGETS ${PACKAGE_NAME}
63+
RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR}
64+
LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR}
65+
ARCHIVE DESTINATION ${LIBRARY_INSTALL_DIR}
66+
)
67+
68+
if (BUILD_TESTING)
69+
add_subdirectory (test)
70+
endif ()

README.md

+23-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,23 @@
1-
# standard-ellipse-detection
1+
# ellipsedetect
2+
3+
An Efficient High-quality Ellipse Detection.
4+
5+
## references
6+
7+
paper : https://arxiv.org/pdf/1810.03243v4.pdf
8+
9+
code : https://github.com/AlanLuSun/High-quality-ellipse-detection
10+
11+
## USAGE
12+
13+
```
14+
cd ellipsedetect
15+
16+
mkdir build && cd build
17+
18+
cmake ..
19+
20+
make
21+
22+
make install
23+
```

images/test1.jpg

6.85 KB
Loading

images/test10.jpg

30.1 KB
Loading

images/test10_result.jpg

72.9 KB
Loading

images/test11.jpg

31.1 KB
Loading

images/test11_result.jpg

33.7 KB
Loading

images/test12.jpg

45.3 KB
Loading

images/test12_result.jpg

125 KB
Loading

images/test1_result.jpg

16.6 KB
Loading

images/test2.jpg

23.1 KB
Loading

images/test2_result.jpg

49.3 KB
Loading

images/test3.jpg

16.2 KB
Loading

images/test3_result.jpg

38.9 KB
Loading

images/test4.jpg

12.5 KB
Loading

images/test4_result.jpg

27.2 KB
Loading

images/test5.jpg

158 KB
Loading

images/test5_result.jpg

43.2 KB
Loading

images/test6.jpg

51.2 KB
Loading

images/test6_result.jpg

104 KB
Loading

images/test7.jpg

21.6 KB
Loading

images/test7_result.jpg

49.5 KB
Loading

images/test8.jpg

168 KB
Loading

images/test8_result.jpg

82.5 KB
Loading

images/test9.jpg

65.4 KB
Loading

images/test9_result.jpg

86.5 KB
Loading

include/compute.h

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
*Copyright: Copyright (c) 2019
3+
*Created on 2019-5-21
4+
5+
*Version 1.0.1
6+
*/
7+
8+
9+
#ifndef _INCLUDE_COMPUTE_H_
10+
#define _INCLUDE_COMPUTE_H_
11+
12+
#include "types.hpp"
13+
14+
namespace MINI {
15+
16+
bool calculateGradient(const uint8_t *image, int row, int col, double *angles);
17+
18+
std::shared_ptr<Ellipse> calcElliseParam(const std::shared_ptr<Arc> &arc1,
19+
const std::shared_ptr<Arc> &arc2,
20+
const double *angles,
21+
int row,
22+
int col);
23+
24+
bool regionLimitation(const std::shared_ptr<Arc> &arc1, const std::shared_ptr<Arc> &arc2);
25+
26+
bool gaussianSampler(const uint8_t *ori_data, int ori_row, int ori_col,
27+
double *data, int row, int col,
28+
double scale, double sigma_scale);
29+
30+
std::shared_ptr<Ellipse> fitEllipse(const std::vector<Pixel> &points);
31+
32+
} // namespace MINI
33+
34+
#endif // _INCLUDE_COMPUTE_H_

include/cvcannyapi.h

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
*Copyright: Copyright (c) 2019
3+
*Created on 2019-5-27
4+
5+
*Version 1.0.1
6+
*/
7+
8+
9+
#ifndef _INCLUDE_CVCANNYAPI_H_
10+
#define _INCLUDE_CVCANNYAPI_H_
11+
#include <stdint.h>
12+
13+
namespace MINI {
14+
15+
bool calculateGradient3(const uint8_t *image, int row, int col, double * angles);
16+
17+
} // namespace MINI
18+
19+
20+
#endif // _INCLUDE_CVCANNYAPI_H_

include/defines.h

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
*Copyright: Copyright (c) 2019
3+
*Created on 2019-5-21
4+
5+
*Version 1.0.1
6+
*/
7+
8+
9+
#ifndef _INCLUDE_DEFINES_H_
10+
#define _INCLUDE_DEFINES_H_
11+
12+
#include <cmath>
13+
14+
namespace MINI {
15+
16+
#ifndef M_LN10
17+
#define M_LN10 2.30258509299404568402 // ln10
18+
#endif /* !M_LN10 */
19+
20+
21+
#define ANGLE_NOT_DEF -1024.0
22+
23+
#define NOTUSED 0
24+
25+
#define USED 1
26+
27+
#define RELATIVE_ERROR_FACTOR 100.0
28+
29+
#define NONE_POL 0
30+
31+
#define SAME_POL 1
32+
33+
#define OPP_POL -1
34+
35+
#define TABSIZE 100000
36+
37+
#define log_gamma(x) ((x) > 15.0? log_gamma_windschitl(x) : log_gamma_lanczos(x))
38+
39+
#define PI 3.14159265358979323846
40+
41+
#define PI_2 1.57079632679489661923
42+
43+
#define PI_4 0.78539816339744830962
44+
45+
#define PI_8 0.392699081
46+
47+
const double DEPS = 1e-8;
48+
49+
const double EPS = DEPS;
50+
51+
const float FEPS = 1e-4;
52+
53+
const double ANGLE_TH = 22.5;
54+
55+
const double GRAD_THRESHOLD = 2.0 / sin(PI * ANGLE_TH / 180.0);
56+
57+
const double MIN_ELLIPSE_THRESHOLD_LENGTH = 2.0;
58+
59+
const double REGION_LIMITATION_DIS_TOLERACE = -3.0 * MIN_ELLIPSE_THRESHOLD_LENGTH;
60+
61+
} // namespace MINI
62+
63+
#endif // _INCLUDE_DEFINES_H_

include/detect.h

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
*Copyright: Copyright (c) 2019
3+
*Created on 2019-5-22
4+
5+
*Version 1.0.1
6+
*/
7+
8+
#ifndef _INCLUDE_DETECT_H_
9+
#define _INCLUDE_DETECT_H_
10+
11+
#include "types.hpp"
12+
13+
14+
namespace MINI {
15+
16+
bool lineSegmentDetection(const double *image, int row, int col,
17+
std::vector<std::shared_ptr<Lined> > &lines);
18+
19+
bool lsdgroups(const double *image, int row, int col, double scale,
20+
std::vector<std::shared_ptr<Arc> >& arcs);
21+
22+
bool getValidInitialEllipseSet(const uint8_t *image,
23+
const double *angles,
24+
int row, int col,
25+
std::vector<std::shared_ptr<Ellipse> > &ells,
26+
int polarity = 0);
27+
28+
29+
bool generateEllipseCandidates(const uint8_t *image,
30+
const double *angles,
31+
int row, int col,
32+
std::vector<std::shared_ptr<Ellipse> > &ells, int polarity);
33+
34+
35+
bool detectEllipse(const uint8_t *image, int row, int col,
36+
std::vector<std::shared_ptr<Ellipse> > &ells,
37+
int polarity = 0, double width = 2.0);
38+
39+
}
40+
//namespace MINI
41+
42+
43+
#endif // _INCLUDE_DETECT_H_

0 commit comments

Comments
 (0)