Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
14 changes: 7 additions & 7 deletions hand.c → hand.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stdio.h>

#include <opencv/cv.h>
#include <opencv/highgui.h>
#import <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>

#define VIDEO_FILE "video.avi"
#define VIDEO_FORMAT CV_FOURCC('M','J','P','G')
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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);

Expand Down