mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Merge pull request #2135 from openmv/update_find_features
imlib: Add config options for find_features.
This commit is contained in:
commit
552fa2e808
@ -118,6 +118,11 @@
|
||||
// Enable find_barcodes() (42 KB)
|
||||
#define IMLIB_ENABLE_BARCODES
|
||||
|
||||
// Enable find_features() and built-in Haar cascades. (75KBs)
|
||||
#define IMLIB_ENABLE_FEATURES
|
||||
#define IMLIB_ENABLE_FEATURES_BUILTIN_FACE_CASCADE
|
||||
#define IMLIB_ENABLE_FEATURES_BUILTIN_EYES_CASCADE
|
||||
|
||||
// Enable CMSIS NN
|
||||
// #if !defined(CUBEAI)
|
||||
// #define IMLIB_ENABLE_CNN
|
||||
@ -158,5 +163,4 @@
|
||||
|
||||
// Stereo Imaging
|
||||
// #define IMLIB_ENABLE_STEREO_DISPARITY
|
||||
|
||||
#endif //__IMLIB_CONFIG_H__
|
||||
|
||||
@ -119,6 +119,11 @@
|
||||
// Enable find_barcodes() (42 KB)
|
||||
//#define IMLIB_ENABLE_BARCODES
|
||||
|
||||
// Enable find_features() and built-in Haar cascades. (75KBs)
|
||||
//#define IMLIB_ENABLE_FEATURES
|
||||
//#define IMLIB_ENABLE_FEATURES_BUILTIN_FACE_CASCADE
|
||||
//#define IMLIB_ENABLE_FEATURES_BUILTIN_EYES_CASCADE
|
||||
|
||||
// Enable CMSIS NN
|
||||
// #if !defined(CUBEAI)
|
||||
// #define IMLIB_ENABLE_CNN
|
||||
|
||||
@ -118,6 +118,11 @@
|
||||
// Enable find_barcodes() (42 KB)
|
||||
//#define IMLIB_ENABLE_BARCODES
|
||||
|
||||
// Enable find_features() and built-in Haar cascades. (75KBs)
|
||||
//#define IMLIB_ENABLE_FEATURES
|
||||
//#define IMLIB_ENABLE_FEATURES_BUILTIN_FACE_CASCADE
|
||||
//#define IMLIB_ENABLE_FEATURES_BUILTIN_EYES_CASCADE
|
||||
|
||||
// Enable CMSIS NN
|
||||
// #if !defined(CUBEAI)
|
||||
// #define IMLIB_ENABLE_CNN
|
||||
|
||||
@ -118,6 +118,11 @@
|
||||
// Enable find_barcodes() (42 KB)
|
||||
#define IMLIB_ENABLE_BARCODES
|
||||
|
||||
// Enable find_features() and built-in Haar cascades. (75KBs)
|
||||
#define IMLIB_ENABLE_FEATURES
|
||||
#define IMLIB_ENABLE_FEATURES_BUILTIN_FACE_CASCADE
|
||||
#define IMLIB_ENABLE_FEATURES_BUILTIN_EYES_CASCADE
|
||||
|
||||
// Enable CMSIS NN
|
||||
// #if !defined(CUBEAI)
|
||||
// #define IMLIB_ENABLE_CNN
|
||||
|
||||
@ -118,6 +118,11 @@
|
||||
// Enable find_barcodes() (42 KB)
|
||||
#define IMLIB_ENABLE_BARCODES
|
||||
|
||||
// Enable find_features() and built-in Haar cascades. (75KBs)
|
||||
#define IMLIB_ENABLE_FEATURES
|
||||
#define IMLIB_ENABLE_FEATURES_BUILTIN_FACE_CASCADE
|
||||
#define IMLIB_ENABLE_FEATURES_BUILTIN_EYES_CASCADE
|
||||
|
||||
// Enable CMSIS NN
|
||||
// #if !defined(CUBEAI)
|
||||
// #define IMLIB_ENABLE_CNN
|
||||
|
||||
@ -67,6 +67,11 @@
|
||||
// Enable find_barcodes() (42 KB)
|
||||
//#define IMLIB_ENABLE_BARCODES
|
||||
|
||||
// Enable find_features() and built-in Haar cascades. (75KBs)
|
||||
//#define IMLIB_ENABLE_FEATURES
|
||||
//#define IMLIB_ENABLE_FEATURES_BUILTIN_FACE_CASCADE
|
||||
//#define IMLIB_ENABLE_FEATURES_BUILTIN_EYES_CASCADE
|
||||
|
||||
// Enable Tensor Flow
|
||||
//#define IMLIB_ENABLE_TF
|
||||
|
||||
|
||||
@ -115,6 +115,11 @@
|
||||
// Enable find_barcodes() (42 KB)
|
||||
//#define IMLIB_ENABLE_BARCODES
|
||||
|
||||
// Enable find_features() and built-in Haar cascades. (75KBs)
|
||||
//#define IMLIB_ENABLE_FEATURES
|
||||
//#define IMLIB_ENABLE_FEATURES_BUILTIN_FACE_CASCADE
|
||||
//#define IMLIB_ENABLE_FEATURES_BUILTIN_EYES_CASCADE
|
||||
|
||||
// Enable Tensor Flow
|
||||
//#define IMLIB_ENABLE_TF
|
||||
|
||||
|
||||
@ -118,6 +118,11 @@
|
||||
// Enable find_barcodes() (42 KB)
|
||||
#define IMLIB_ENABLE_BARCODES
|
||||
|
||||
// Enable find_features() and built-in Haar cascades. (75KBs)
|
||||
#define IMLIB_ENABLE_FEATURES
|
||||
#define IMLIB_ENABLE_FEATURES_BUILTIN_FACE_CASCADE
|
||||
#define IMLIB_ENABLE_FEATURES_BUILTIN_EYES_CASCADE
|
||||
|
||||
// Enable CMSIS NN
|
||||
// #if !defined(CUBEAI)
|
||||
// #define IMLIB_ENABLE_CNN
|
||||
|
||||
@ -118,6 +118,11 @@
|
||||
// Enable find_barcodes() (42 KB)
|
||||
#define IMLIB_ENABLE_BARCODES
|
||||
|
||||
// Enable find_features() and built-in Haar cascades. (75KBs)
|
||||
#define IMLIB_ENABLE_FEATURES
|
||||
#define IMLIB_ENABLE_FEATURES_BUILTIN_FACE_CASCADE
|
||||
#define IMLIB_ENABLE_FEATURES_BUILTIN_EYES_CASCADE
|
||||
|
||||
// Enable CMSIS NN
|
||||
// #if !defined(CUBEAI)
|
||||
// #define IMLIB_ENABLE_CNN
|
||||
|
||||
@ -118,6 +118,11 @@
|
||||
// Enable find_barcodes() (42 KB)
|
||||
#define IMLIB_ENABLE_BARCODES
|
||||
|
||||
// Enable find_features() and built-in Haar cascades. (75KBs)
|
||||
#define IMLIB_ENABLE_FEATURES
|
||||
#define IMLIB_ENABLE_FEATURES_BUILTIN_FACE_CASCADE
|
||||
#define IMLIB_ENABLE_FEATURES_BUILTIN_EYES_CASCADE
|
||||
|
||||
// Enable CMSIS NN
|
||||
// #if !defined(CUBEAI)
|
||||
// #define IMLIB_ENABLE_CNN
|
||||
|
||||
@ -118,6 +118,11 @@
|
||||
// Enable find_barcodes() (42 KB)
|
||||
#define IMLIB_ENABLE_BARCODES
|
||||
|
||||
// Enable find_features() and built-in Haar cascades. (75KBs)
|
||||
#define IMLIB_ENABLE_FEATURES
|
||||
#define IMLIB_ENABLE_FEATURES_BUILTIN_FACE_CASCADE
|
||||
#define IMLIB_ENABLE_FEATURES_BUILTIN_EYES_CASCADE
|
||||
|
||||
// Enable CMSIS NN
|
||||
// #if !defined(CUBEAI)
|
||||
// #define IMLIB_ENABLE_CNN
|
||||
|
||||
@ -118,6 +118,11 @@
|
||||
// Enable find_barcodes() (42 KB)
|
||||
#define IMLIB_ENABLE_BARCODES
|
||||
|
||||
// Enable find_features() and built-in Haar cascades. (75KBs)
|
||||
#define IMLIB_ENABLE_FEATURES
|
||||
#define IMLIB_ENABLE_FEATURES_BUILTIN_FACE_CASCADE
|
||||
#define IMLIB_ENABLE_FEATURES_BUILTIN_EYES_CASCADE
|
||||
|
||||
// Enable CMSIS NN
|
||||
// #if !defined(CUBEAI)
|
||||
// #define IMLIB_ENABLE_CNN
|
||||
|
||||
@ -117,6 +117,11 @@
|
||||
// Enable find_barcodes() (42 KB)
|
||||
#define IMLIB_ENABLE_BARCODES
|
||||
|
||||
// Enable find_features() and built-in Haar cascades. (75KBs)
|
||||
#define IMLIB_ENABLE_FEATURES
|
||||
#define IMLIB_ENABLE_FEATURES_BUILTIN_FACE_CASCADE
|
||||
#define IMLIB_ENABLE_FEATURES_BUILTIN_EYES_CASCADE
|
||||
|
||||
// Enable CMSIS NN
|
||||
// #if !defined(CUBEAI)
|
||||
// #define IMLIB_ENABLE_CNN
|
||||
|
||||
@ -119,6 +119,11 @@
|
||||
// Enable find_barcodes() (42 KB)
|
||||
//#define IMLIB_ENABLE_BARCODES
|
||||
|
||||
// Enable find_features() and built-in Haar cascades. (75KBs)
|
||||
//#define IMLIB_ENABLE_FEATURES
|
||||
//#define IMLIB_ENABLE_FEATURES_BUILTIN_FACE_CASCADE
|
||||
//#define IMLIB_ENABLE_FEATURES_BUILTIN_EYES_CASCADE
|
||||
|
||||
// Enable CMSIS NN
|
||||
// #if !defined(CUBEAI)
|
||||
// #define IMLIB_ENABLE_CNN
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#include "cascade.h"
|
||||
#include "file_utils.h"
|
||||
|
||||
#ifdef IMLIB_ENABLE_FEATURES
|
||||
static int eval_weak_classifier(cascade_t *cascade, point_t pt, int t_idx, int w_idx, int r_idx) {
|
||||
int32_t sumw = 0;
|
||||
mw_image_t *sum = cascade->sum;
|
||||
@ -249,7 +250,9 @@ error:
|
||||
|
||||
int imlib_load_cascade(cascade_t *cascade, const char *path) {
|
||||
// built-in cascade
|
||||
if (strcmp(path, "frontalface") == 0) {
|
||||
if (0) {
|
||||
#ifdef IMLIB_ENABLE_FEATURES_BUILTIN_FACE_CASCADE
|
||||
} else if (strcmp(path, "frontalface") == 0) {
|
||||
cascade->window.w = frontalface_window_w;
|
||||
cascade->window.h = frontalface_window_h;
|
||||
cascade->n_stages = frontalface_n_stages;
|
||||
@ -261,6 +264,8 @@ int imlib_load_cascade(cascade_t *cascade, const char *path) {
|
||||
cascade->num_rectangles_array = (int8_t *) frontalface_num_rectangles_array;
|
||||
cascade->weights_array = (int8_t *) frontalface_weights_array;
|
||||
cascade->rectangles_array = (int8_t *) frontalface_rectangles_array;
|
||||
#endif
|
||||
#ifdef IMLIB_ENABLE_FEATURES_BUILTIN_EYES_CASCADE
|
||||
} else if (strcmp(path, "eye") == 0) {
|
||||
cascade->window.w = eye_window_w;
|
||||
cascade->window.h = eye_window_h;
|
||||
@ -273,6 +278,7 @@ int imlib_load_cascade(cascade_t *cascade, const char *path) {
|
||||
cascade->num_rectangles_array = (int8_t *) eye_num_rectangles_array;
|
||||
cascade->weights_array = (int8_t *) eye_weights_array;
|
||||
cascade->rectangles_array = (int8_t *) eye_rectangles_array;
|
||||
#endif
|
||||
} else {
|
||||
#if defined(IMLIB_ENABLE_IMAGE_FILE_IO)
|
||||
// xml cascade
|
||||
@ -294,3 +300,4 @@ int imlib_load_cascade(cascade_t *cascade, const char *path) {
|
||||
}
|
||||
return FR_OK;
|
||||
}
|
||||
#endif // IMLIB_ENABLE_FEATURES
|
||||
|
||||
@ -35,7 +35,6 @@
|
||||
#include "py_imageio.h"
|
||||
#endif
|
||||
|
||||
static const mp_obj_type_t py_cascade_type;
|
||||
static const mp_obj_type_t py_image_type;
|
||||
|
||||
#if defined(IMLIB_ENABLE_IMAGE_FILE_IO)
|
||||
@ -44,6 +43,9 @@ extern const char *ffs_strerror(FRESULT res);
|
||||
|
||||
// Haar Cascade ///////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef IMLIB_ENABLE_FEATURES
|
||||
static const mp_obj_type_t py_cascade_type;
|
||||
|
||||
typedef struct _py_cascade_obj_t {
|
||||
mp_obj_base_t base;
|
||||
struct cascade _cobj;
|
||||
@ -67,6 +69,8 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
|
||||
MP_TYPE_FLAG_NONE,
|
||||
print, py_cascade_print
|
||||
);
|
||||
#endif // IMLIB_ENABLE_FEATURES
|
||||
|
||||
// Keypoints object ///////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef IMLIB_ENABLE_FIND_KEYPOINTS
|
||||
@ -6209,6 +6213,7 @@ static mp_obj_t py_image_find_template(uint n_args, const mp_obj_t *args, mp_map
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_find_template_obj, 3, py_image_find_template);
|
||||
#endif // IMLIB_FIND_TEMPLATE
|
||||
|
||||
#ifdef IMLIB_ENABLE_FEATURES
|
||||
static mp_obj_t py_image_find_features(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
image_t *arg_img = py_helper_arg_to_image(args[0], ARG_IMAGE_MUTABLE);
|
||||
cascade_t *cascade = py_cascade_cobj(args[1]);
|
||||
@ -6243,6 +6248,7 @@ static mp_obj_t py_image_find_features(uint n_args, const mp_obj_t *args, mp_map
|
||||
return objects_list;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_find_features_obj, 2, py_image_find_features);
|
||||
#endif // IMLIB_ENABLE_FEATURES
|
||||
|
||||
static mp_obj_t py_image_find_eye(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
image_t *arg_img = py_helper_arg_to_image(args[0], ARG_IMAGE_GRAYSCALE);
|
||||
@ -6722,7 +6728,11 @@ static const mp_rom_map_elem_t locals_dict_table[] = {
|
||||
#else
|
||||
{MP_ROM_QSTR(MP_QSTR_find_template), MP_ROM_PTR(&py_func_unavailable_obj)},
|
||||
#endif
|
||||
#ifdef IMLIB_ENABLE_FEATURES
|
||||
{MP_ROM_QSTR(MP_QSTR_find_features), MP_ROM_PTR(&py_image_find_features_obj)},
|
||||
#else
|
||||
{MP_ROM_QSTR(MP_QSTR_find_features), MP_ROM_PTR(&py_func_unavailable_obj)},
|
||||
#endif
|
||||
{MP_ROM_QSTR(MP_QSTR_find_eye), MP_ROM_PTR(&py_image_find_eye_obj)},
|
||||
#ifdef IMLIB_ENABLE_FIND_LBP
|
||||
{MP_ROM_QSTR(MP_QSTR_find_lbp), MP_ROM_PTR(&py_image_find_lbp_obj)},
|
||||
@ -7084,6 +7094,7 @@ mp_obj_t py_image_load_image(uint n_args, const mp_obj_t *pos_args, mp_map_t *kw
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_load_image_obj, 1, py_image_load_image);
|
||||
|
||||
#ifdef IMLIB_ENABLE_FEATURES
|
||||
mp_obj_t py_image_load_cascade(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
cascade_t cascade;
|
||||
const char *path = mp_obj_str_get_str(args[0]);
|
||||
@ -7114,6 +7125,7 @@ mp_obj_t py_image_load_cascade(uint n_args, const mp_obj_t *args, mp_map_t *kw_a
|
||||
return o;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_load_cascade_obj, 1, py_image_load_cascade);
|
||||
#endif // IMLIB_ENABLE_FEATURES
|
||||
|
||||
#if defined(IMLIB_ENABLE_DESCRIPTOR)
|
||||
#if defined(IMLIB_ENABLE_IMAGE_FILE_IO)
|
||||
@ -7425,7 +7437,9 @@ static const mp_rom_map_elem_t globals_dict_table[] = {
|
||||
{MP_ROM_QSTR(MP_QSTR_yuv_to_rgb), MP_ROM_PTR(&py_image_yuv_to_rgb_obj)},
|
||||
{MP_ROM_QSTR(MP_QSTR_yuv_to_lab), MP_ROM_PTR(&py_image_yuv_to_lab_obj)},
|
||||
{MP_ROM_QSTR(MP_QSTR_Image), MP_ROM_PTR(&py_image_load_image_obj)},
|
||||
#ifdef IMLIB_ENABLE_FEATURES
|
||||
{MP_ROM_QSTR(MP_QSTR_HaarCascade), MP_ROM_PTR(&py_image_load_cascade_obj)},
|
||||
#endif
|
||||
#if defined(IMLIB_ENABLE_DESCRIPTOR) && defined(IMLIB_ENABLE_IMAGE_FILE_IO)
|
||||
{MP_ROM_QSTR(MP_QSTR_load_descriptor), MP_ROM_PTR(&py_image_load_descriptor_obj)},
|
||||
{MP_ROM_QSTR(MP_QSTR_save_descriptor), MP_ROM_PTR(&py_image_save_descriptor_obj)},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user