memory fixes
This commit is contained in:
parent
d1ba152d62
commit
9fdd4ebbb1
3 changed files with 9 additions and 6 deletions
|
@ -15,7 +15,7 @@
|
|||
|
||||
// takes the two points that are more distant from the next, ie:
|
||||
// i st distance(hull[i], hull[i+1]) is maximum and 2nd maximum
|
||||
int* max2_distance(std::vector<cv::Point> hull)
|
||||
unsigned* max2_distance(std::vector<cv::Point> hull)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
std::cout << "Hull = ";
|
||||
|
@ -24,7 +24,7 @@ int* max2_distance(std::vector<cv::Point> hull)
|
|||
}
|
||||
#endif
|
||||
std::cout << std::endl;
|
||||
int *idx = (int*) calloc(2, sizeof(int));
|
||||
unsigned *idx = (unsigned*) calloc(2, sizeof(int));
|
||||
double distance[2] = {0};
|
||||
for( unsigned i=0; hull.size()>i; i++ )
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <opencv2/core/core.hpp> //Any Opencv2 code
|
||||
#endif
|
||||
|
||||
int* max2_distance(std::vector<cv::Point> hull);
|
||||
unsigned* max2_distance(std::vector<cv::Point> hull);
|
||||
|
||||
bool
|
||||
similar_fit(cv::Point a, cv::Point b, cv::Point newpoint);
|
||||
|
|
|
@ -21,8 +21,6 @@ auto MAGENTA = cv::Scalar(110,10,200);
|
|||
auto BROWN = cv::Scalar(90,100,60);
|
||||
|
||||
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char const *fname = "files/masckera.png";
|
||||
|
@ -66,7 +64,7 @@ int main(int argc, char *argv[])
|
|||
cv::convexHull(cv::Mat(contour),hull,false);
|
||||
|
||||
//these are the "horizontal" lines
|
||||
int *maxdistances = max2_distance(hull);
|
||||
unsigned *maxdistances = max2_distance(hull);
|
||||
cv::Point corn_1, corn_2, corn_3, corn_4;
|
||||
corn_1 = hull[maxdistances[0]];
|
||||
corn_2 = hull[(maxdistances[0]+1)%hull.size()];
|
||||
|
@ -88,7 +86,11 @@ int main(int argc, char *argv[])
|
|||
|
||||
std::vector<std::vector<cv::Point>> verticals;
|
||||
verticals.push_back(find_longest_line(hull, (maxdistances[0]+1)%hull.size(), maxdistances[1]));
|
||||
std::cout << maxdistances[1] << std::endl;
|
||||
std::cout << maxdistances[1]+1 << std::endl;
|
||||
std::cout << (maxdistances[1]+1)%hull.size() << std::endl;
|
||||
verticals.push_back(find_longest_line(hull, (maxdistances[1]+1)%hull.size(), maxdistances[0]));
|
||||
free(maxdistances);
|
||||
|
||||
#ifdef _DEBUG
|
||||
//img = cv::imread(fname,CV_LOAD_IMAGE_COLOR); // uncomment to this to display image with colors
|
||||
|
@ -111,6 +113,7 @@ int main(int argc, char *argv[])
|
|||
if( cv::waitKey(0) == 113 )
|
||||
break;
|
||||
}
|
||||
img.release();
|
||||
#endif
|
||||
|
||||
// theta is the angle of the line connecting point 1 and 2; it will be the
|
||||
|
|
Loading…
Reference in a new issue