diff --git a/.gitignore b/.gitignore index 6f5c6fc..7333f34 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ *.mat *.swp *.swo - +bin/ +*.sublime-project +*.sublime-workspace diff --git a/Makefile b/Makefile index be3f2d8..b3a132a 100644 --- a/Makefile +++ b/Makefile @@ -5,9 +5,11 @@ CFLAGS = -std=gnu99 -Wall -Wno-unused-parameter -Wno-unused-function -pthread -I LDFLAGS = -lpthread -lm APRILTAG_OBJS = apriltag.o apriltag_quad_thresh.o tag16h5.o tag25h7.o tag25h9.o tag36h10.o tag36h11.o tag36artoolkit.o g2d.o common/zarray.o common/zhash.o common/zmaxheap.o common/unionfind.o common/matd.o common/image_u8.o common/pnm.o common/image_f32.o common/image_u32.o common/workerpool.o common/time_util.o common/svd22.o common/homography.o common/string_util.o common/getopt.o +BIN_DIR = bin LIBAPRILTAG := libapriltag.a + all: $(LIBAPRILTAG) apriltag_demo @@ -17,7 +19,8 @@ $(LIBAPRILTAG): $(APRILTAG_OBJS) apriltag_demo: apriltag_demo.o @echo " [$@]" - @$(CC) -o $@ apriltag_demo.o $(APRILTAG_OBJS) $(LDFLAGS) + mkdir $(BIN_DIR) + @$(CC) -o $(BIN_DIR)/$@ apriltag_demo.o $(APRILTAG_OBJS) $(LDFLAGS) %.o: %.c @echo " $@" @@ -25,4 +28,4 @@ apriltag_demo: apriltag_demo.o .PHONY: clean clean: - @rm -rf *.o common/*.o $(LIBAPRILTAG) apriltag_demo + @rm -rf *.o common/*.o $(LIBAPRILTAG) bin diff --git a/common/image_u8.c b/common/image_u8.c index 3bc1c6b..ae9c0c8 100644 --- a/common/image_u8.c +++ b/common/image_u8.c @@ -163,6 +163,19 @@ image_u8_t *image_u8_create_from_f32(image_f32_t *fim) return im; } +image_u8_t *image_u8_create_from_gray(int w, int h, uint8_t *image_matrix) +{ + image_u8_t *im = image_u8_create(w, h); + + for (int y = 0; y < h; y++) { + for (int x = 0; x < w; x++) { + im->buf[y*im->stride + x] = image_matrix[y*im->stride + x]; + } + } + + return im; +} + int image_u8_write_pnm(const image_u8_t *im, const char *path) { diff --git a/common/image_u8.h b/common/image_u8.h index d9ffa4e..6c0e680 100644 --- a/common/image_u8.h +++ b/common/image_u8.h @@ -68,6 +68,7 @@ image_u8_t *image_u8_create(unsigned int width, unsigned int height); image_u8_t *image_u8_create_alignment(unsigned int width, unsigned int height, unsigned int alignment); image_u8_t *image_u8_create_from_rgb3(int width, int height, uint8_t *rgb, int stride); image_u8_t *image_u8_create_from_f32(image_f32_t *fim); +image_u8_t *image_u8_create_from_gray(int w, int h, uint8_t *image_matrix); image_u8_t *image_u8_create_from_pnm(const char *path); image_u8_t *image_u8_create_from_pnm_alignment(const char *path, int alignment);