diff --git a/Makefile b/Makefile index d6d2704..7245a2d 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,8 @@ OBJS := hand.o TARGET := hand CFLAGS := -Wall -LDFLAGS := -lm -lcv -lhighgui -lcvaux +#LDFLAGS := -lm -lcv -lhighgui -lcvaux +LDFLAGS := -lm -lstdc++ -I/usr/include/opencv -I/usr/include/opencv2 -lopencv_calib3d -lopencv_imgproc -lopencv_contrib -lopencv_legacy -lopencv_core -lopencv_ml -lopencv_features2d -lopencv_objdetect -lopencv_flann -lopencv_video -lopencv_highgui all: $(OBJS) $(CC) -o $(TARGET) $(OBJS) $(LDFLAGS) diff --git a/hand.c b/hand.cpp similarity index 96% rename from hand.c rename to hand.cpp index ffb28b6..d16e816 100644 --- a/hand.c +++ b/hand.cpp @@ -1,7 +1,7 @@ #include -#include -#include +#import +#include #define VIDEO_FILE "video.avi" #define VIDEO_FORMAT CV_FOURCC('M','J','P','G') @@ -84,8 +84,8 @@ void init_ctx(struct ctx *ctx) ctx->contour_st = cvCreateMemStorage(0); ctx->hull_st = cvCreateMemStorage(0); ctx->temp_st = cvCreateMemStorage(0); - ctx->fingers = calloc(NUM_FINGERS + 1, sizeof(CvPoint)); - ctx->defects = calloc(NUM_DEFECTS, sizeof(CvPoint)); + ctx->fingers = new CvPoint[NUM_FINGERS + 1](); + ctx->defects = new CvPoint[NUM_DEFECTS](); } void filter_and_threshold(struct ctx *ctx) @@ -164,8 +164,7 @@ void find_convex_hull(struct ctx *ctx) ctx->defects_st); if (defects && defects->total) { - defect_array = calloc(defects->total, - sizeof(CvConvexityDefect)); + defect_array = new CvConvexityDefect[defects->total](); cvCvtSeqToArray(defects, defect_array, CV_WHOLE_SEQ); /* Average depth points to get hand center */ @@ -215,7 +214,8 @@ void find_fingers(struct ctx *ctx) return; n = ctx->contour->total; - points = calloc(n, sizeof(CvPoint)); +// TODO CHECK points = calloc(n, sizeof(CvPoint)); + points = new CvPoint[n](); cvCvtSeqToArray(ctx->contour, points, CV_WHOLE_SEQ);