From 59138d087199dae189a65546743dc1b8f5768b21 Mon Sep 17 00:00:00 2001 From: mutantturkey Date: Fri, 20 Jul 2012 11:47:08 -0400 Subject: fixed formatting, removed cruft, fixed giant memory leak --- fly-tools/FlyTrackingMain.cpp | 162 ++++++------------------------------------ 1 file changed, 23 insertions(+), 139 deletions(-) (limited to 'fly-tools/FlyTrackingMain.cpp') diff --git a/fly-tools/FlyTrackingMain.cpp b/fly-tools/FlyTrackingMain.cpp index 5d1c73d..6c9c4ab 100644 --- a/fly-tools/FlyTrackingMain.cpp +++ b/fly-tools/FlyTrackingMain.cpp @@ -98,6 +98,8 @@ map centroidDistanceMap; map headDirAngleMap; map speedMap; +int barrier = 1000; + void initSequence(){ startOfATrackSequence = -1; endOfATrackSequence = -1; @@ -159,15 +161,6 @@ void writeHist(const char* filename, map dataMap) } for (unsigned int j = first; j<=last; j++) { - /*if ( roundT(j-first) >= int(hist.size()) ) - hist.resize(j-first,0); - hist[roundT(j-first)] = len[j]; - */ - - /*if ( roundT(j) >= int(hist.size()) ) - hist.resize(j,0); - hist[roundT(j)] = len[j]; - */ hist[j] = dataMap[j]; } } @@ -187,8 +180,6 @@ void writeHist(const char* filename, map dataMap) { cerr << "Bad memory loc for opening file" << endl; } } - - void findObj(Image* img, int x, int y, vector > & shape ,bool eightCon=true, bool colorLookingFor=true); void eightConnObj(Image* img, int x, int y, vector > & obj, bool color=true); void fourConnObj(Image* img, int x, int y, vector > & obj, bool color=true); @@ -691,10 +682,8 @@ void putPixel(Image* maskImage, int x, int y, int color) { pair temp(x,y); bresenhamLine.push_back(temp); } - } - int draw_line_bm(Image* maskImage, int x0, int y0, int x1, int y1) { isInFemaleBlob = false; @@ -744,7 +733,6 @@ int draw_line_bm(Image* maskImage, int x0, int y0, int x1, int y1) { switch (octant) { case 1: - //---------------------------- d = 2*dy - dx; delE = 2*dy; delNE = 2*(dy-dx); @@ -752,7 +740,6 @@ int draw_line_bm(Image* maskImage, int x0, int y0, int x1, int y1) { x = x0; y = y0; - putPixel(maskImage,x, y, 1); if (isInFemaleBlob == true) return 1; @@ -760,15 +747,11 @@ int draw_line_bm(Image* maskImage, int x0, int y0, int x1, int y1) { while (x < x1) { // if we choose E because midpoint is above the line if (d <= 0) { - d = d + delE; - x = x+1; - - } else { - + } + else { d = d + delNE; - x = x + 1; y = y + 1; } @@ -785,11 +768,9 @@ int draw_line_bm(Image* maskImage, int x0, int y0, int x1, int y1) { d = 2*dx - dy; delN = 2*dx; delNE = 2*(dx-dy); - x = x0; y = y0; - putPixel(maskImage,x, y, 2); if (isInFemaleBlob == true) return 1; @@ -797,24 +778,19 @@ int draw_line_bm(Image* maskImage, int x0, int y0, int x1, int y1) { while (y < y1) { // if we choose N because midpoint is above the line if (d<=0) { - d = d + delN; - y = y + 1; - - } else { - + } + else { d = d + delNE; - - x = x + 1; y = y + 1; } + putPixel(maskImage,x, y, 2); if (isInFemaleBlob == true) return 1; - } break; @@ -823,7 +799,6 @@ int draw_line_bm(Image* maskImage, int x0, int y0, int x1, int y1) { d = dy - 2*dx; delN = 2*dx; delNW = 2*(dx-dy); - x = x0; y = y0; @@ -835,27 +810,19 @@ int draw_line_bm(Image* maskImage, int x0, int y0, int x1, int y1) { while (y < y1) { if (d <= 0) { - d = d + delN; - y = y + 1; - - } else { - + } + else { d = d + delNW; - y = y + 1; - x = x - 1; - } + putPixel(maskImage,x, y, 3); if (isInFemaleBlob == true) return 1; - - } - break; case 4: @@ -875,78 +842,30 @@ int draw_line_bm(Image* maskImage, int x0, int y0, int x1, int y1) { while ( x > x1 ) { if (d <= 0) { - d = d + delW; - x = x - 1; - - - } else { + } + else { d = d + delNW; - - x = x - 1; y = y + 1; - } putPixel(maskImage,x, y, 4); if (isInFemaleBlob == true) return 1; - } break; - /*case 4: - - d = dx - 2*dy; - cout << "dx - 2*dy = "<<(dx-2*dy)< 0 "< x1) { if (d<=0) { - d = d + delW; - - x = x - 1; - - } else { - + } + else { d = d + delSW; - - x = x - 1; - y = y - 1; - - } putPixel(maskImage,x, y, 5); if (isInFemaleBlob == true) return 1; - - } break; - case 6: d = 2*dx - dy; @@ -992,7 +899,6 @@ int draw_line_bm(Image* maskImage, int x0, int y0, int x1, int y1) { x = x0; y = y0; - putPixel(maskImage,x,y,6); if (isInFemaleBlob == true) return 1; @@ -1002,13 +908,10 @@ int draw_line_bm(Image* maskImage, int x0, int y0, int x1, int y1) { if (d<=0) { d = d + delS; - y = y -1; } else { - d = d + delSW; - y = y -1; x = x -1; } @@ -1042,8 +945,6 @@ int draw_line_bm(Image* maskImage, int x0, int y0, int x1, int y1) { } else { d = d + delSE; - - y = y - 1; x = x + 1; } @@ -1074,21 +975,18 @@ int draw_line_bm(Image* maskImage, int x0, int y0, int x1, int y1) { if (d<=0) { d = d + delE; - x = x + 1; } else { d = d + delSE; - - y = y - 1; x = x + 1; } + cout << "putpixel "< > veloci startIndex = 0; endIndex = 0; } - } - } @@ -1889,7 +1781,6 @@ void objectCorrespondence(FrameInfo &prevFI, FrameInfo ¤tFI) { } } - } double euclideanDist(FlyObject a, FlyObject b) { @@ -1927,8 +1818,6 @@ void processASequence(int startOfATrackSequence, int endOfATrackSequence) { cout << endl; } - - } cout << "Maximum distance between the frame found at the index "<>fileName) { - // Image* img = new Image(argv[1]);// = new Image(argv[1]); - int fi = fileName.find("_"); // current sequence numbers spans from 0 - 18019, so 5 digits are needed int span = 5; @@ -2147,7 +2028,6 @@ int main(int argc, char **argv) // save the name in the vector fnVector.push_back(fileName); - //fileName = "output/filtered/final/"+fileName; fileName = maskImagePath + fileName; cout << "Reading file "< eigenVal = covariantDecomposition(shape); { - // objCount++; + //objCount++; double velocity_x=0.0, velocity_y=0.0; // save the object information @@ -2431,7 +2311,9 @@ int hitTheFly(Image* maskImage, int &intersectX, int &intersectY) { return 2; } else { - cout << "Going through "<write(outputFileName.c_str()); + img->write(outputFileName.c_str()); + delete img; } // overwrite the file now with axis //img->write(inputFileName.c_str()); @@ -2949,6 +2832,7 @@ void drawTheFlyObject(FrameInfo currentFI, string fileName, int isFirst, bool si // when do not want to identify on the original comment below line and uncomment the above one delete maskImage; + if (isHitting == 1 || isHittingFemaleToMale == 0) calculateStatistics(currentFI, fileName, isFirst, singleBlob, true, false, unprocessed); else if (isHitting == 0 || isHittingFemaleToMale == 1) @@ -2971,7 +2855,7 @@ void findObj(Image* img, int x, int y, vector > & shape ,bool eigh } } -int barrier = 1000; + void fourConnObj(Image* img, int x, int y, vector > & obj, bool color) { int width = img->columns(),height = img->rows(); -- cgit v1.2.3