#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2\imgproc\imgproc.hpp>
#include <opencv/cv.h>
#include <iostream>
#include <string>


using namespace cv;
using namespace std;

// func: finds all contours of all blobs in a image 
// pre : binaryImage has depth 16 bits signed int. Contains only values 0 and 1.
// post: contourVec: contains the points of the contour of each blob.       
// return_value: the total number of objects.
int allContours(Mat	binaryImage, vector<vector<Point>> &contourVecVec);

// func: discover next b
// return_value: new direction
int discoverNext(Mat &binaryImage, const cv::Point &pos, int beginDirection);

// func: discover next c
// return_value : new direction
int discoverNextRelativeDirection(const cv::Point &pos, const cv::Point &target);

// func: get a point with a given position and direction
// return_value : new point
cv::Point getDirPos(const cv::Point &pos, int dir);

bool contains(vector<Point> vec, Point p);
void flip(vector<vector<Point>> &vec);
bool isInsideContours(vector<vector<Point>>& vec, Point point);

double getBendingEnergy(const vector<Point> &contour);