diff options
-rw-r--r-- | fly-tools/FlyTrackingMain.cpp | 110 | ||||
-rwxr-xr-x | process-video-beta | 3 |
2 files changed, 63 insertions, 50 deletions
diff --git a/fly-tools/FlyTrackingMain.cpp b/fly-tools/FlyTrackingMain.cpp index 4114a08..2e963a8 100644 --- a/fly-tools/FlyTrackingMain.cpp +++ b/fly-tools/FlyTrackingMain.cpp @@ -1976,7 +1976,7 @@ void processASequence(int startOfATrackSequence, int endOfATrackSequence) { vector<FlyObject > fOVector = currentFI.getFOVector(); FlyObject cFFirstFO = fOVector[0]; FlyObject cFSecondFO = fOVector[1]; - + sequenceFirstAverage += cFFirstFO.getArea(); sequenceSecondAverage += cFSecondFO.getArea(); @@ -2021,22 +2021,55 @@ ofstream foutSt; ofstream foutDebugCen; ofstream foutDebugSpeed; -int main(int argc, char* argv[]) +int main(int argc, char **argv) { - if (argc < 5) - { - cerr << "Usage: executablename <inputFile.txt> <originalImagePath> <finalOutputPath> <maskImagePath> <outputFilePrefix>" << endl; // input file contains name of the - // input image files - return -1; - } - - MagickCore::SetMagickResourceLimit(MagickCore::MemoryResource, 1536); - MagickCore::SetMagickResourceLimit(MagickCore::MapResource, 4092); - - string ifns(argv[1]); - inputFileName = ifns; -// cout << "input file name is "<<inputFileName<<endl; - + int c; + int writeFinalImages; + string usage = "Usage: FlyTracking -i <inputFile.txt> -o <originalImagePath> -f <finalOutputPath> -m <maskImagePath> -O <outputFilePrefix>"; + string origImagePath; + string finalOutputPath; + string outputFilePrefix; + string maskImagePath; + string inputFileName; + opterr = 0; + + while ((c = getopt (argc, argv, "i:f:m:p:o:hx")) != -1) + switch (c) + { + case 'i': + inputFileName = optarg; + break; + case 'o': + origImagePath = optarg; + break; + case 'f': + finalOutputPath = optarg; + break; + case 'm': + maskImagePath = optarg; + break; + case 'p': + outputFilePrefix = optarg; + break; + case 'h': + cout << usage << endl; + exit(1); + break; + case 'x': + writeFinalImages; + break; + default: + break; + } + + //MagickCore::SetMagickResourceLimit(MagickCore::MemoryResource, 1536); + //MagickCore::SetMagickResourceLimit(MagickCore::MapResource, 4092); + + i + if( inputFileName.empty() || origImagePath.empty() || finalOutputPath.empty() || maskImagePath.empty() || outputFilePrefix.empty() ) { + cerr << usage << endl; + exit(1); + } string fileName; ifstream inputFile(inputFileName.c_str()); // save the input file name @@ -2045,25 +2078,8 @@ int main(int argc, char* argv[]) cout << "cannot open the input file that contains name of the input images\n"; exit(1); } - - //cout<<"come here ------------------------- 1"<<endl; - // set the global paths - string tempOIP(argv[2]); - origImagePath = tempOIP; - - //cout<<"come here ------------------------- 2"<<endl; - - string tempFOP(argv[3]); - finalOutputPath = tempFOP; - //cout<<"come here ------------------------- 3"<<endl; - - string tempOFP(argv[5]); - outputFilePrefix = tempOFP; - - //cout<<"come here ------------------------- 4"<<endl; - - string statFileName = tempFOP + outputFilePrefix + "_statFile.txt"; + string statFileName = finalOutputPath + outputFilePrefix + "_statFile.txt"; //cout << "Statfilename is "<<statFileName<<endl; foutSt.open(statFileName.c_str()); if (foutSt.fail()) { @@ -2072,7 +2088,7 @@ int main(int argc, char* argv[]) } // debug file - string foutDebugCenFN = tempFOP + outputFilePrefix + "_statFileDebug.txt"; + string foutDebugCenFN = finalOutputPath + outputFilePrefix + "_statFileDebug.txt"; foutDebugCen.open(foutDebugCenFN.c_str()); if (foutDebugCen.fail()) { cout << "cannot open the statDebug file"<<endl; @@ -2081,15 +2097,14 @@ int main(int argc, char* argv[]) // debug file speed distribution - string foutDebugSpeedFN = tempFOP + outputFilePrefix + "_speedDebug.txt"; + string foutDebugSpeedFN = finalOutputPath + outputFilePrefix + "_speedDebug.txt"; foutDebugSpeed.open(foutDebugSpeedFN.c_str()); if (foutDebugSpeed.fail()) { cout << "cannot open the speedDebug file"<<endl; exit(1); } - string tempMIP(argv[4]); - maskImagePath = tempMIP; + // open the file for statistics string lPSFileName("LongestPositive.txt"); @@ -2114,10 +2129,10 @@ int main(int argc, char* argv[]) bool currentlyCalculatingHead = true; - + while (inputFile>>fileName) { -// Image* img = new Image(argv[1]);// = new Image(argv[1]); + // 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 @@ -2136,7 +2151,7 @@ int main(int argc, char* argv[]) cout << "Reading file "<<fileName<<endl; Image* img = new Image(fileName.c_str()); int width = img->columns(),height = img->rows(); - diagLength= static_cast<int> ( sqrt( (height*height) + (width*width) ) ); + diagLength= static_cast<int> ( sqrt( (height*height) + (width*width) ) ); //cout << "Diagonal length is "<<diagLength<<endl; // Image* imgWithInfo; // imgWithInfo = new Image(fileName.c_str()); @@ -2184,13 +2199,12 @@ int main(int argc, char* argv[]) } } - + delete img; - delete residual; -// cout<<"Sorting the objects according to size"<<endl; -// bubbleSort(tempFOV); + // cout<<"Sorting the objects according to size"<<endl; + // bubbleSort(tempFOV); fOVector.clear(); @@ -2793,8 +2807,8 @@ void drawTheFlyObject(FrameInfo currentFI, string fileName, int isFirst, bool si bool eVDirection = currentFO.getHeadIsInDirectionMAEV(); // debug: - cout<<"Calling the findTheStartPoint() function"<<endl; - cout<<"Female size "<<femaleSize<<" maleSize "<<maleSize<<" MaleCentroid = "<<centroid.first<<", "<<centroid.second<<endl; + //cout<<"Calling the findTheStartPoint() function"<<endl; + //cout<<"Female size "<<femaleSize<<" maleSize "<<maleSize<<" MaleCentroid = "<<centroid.first<<", "<<centroid.second<<endl; // initialize the flag with false for the next found of findTheStartPoint() isFoundStartPoint = false; @@ -2837,7 +2851,7 @@ void drawTheFlyObject(FrameInfo currentFI, string fileName, int isFirst, bool si bool eVDirection = currentFO.getHeadIsInDirectionMAEV(); - double ev_x, ev_y; + //double ev_x, ev_y; // draw the female when tracked by the male fly if (isHitting == 1) { diff --git a/process-video-beta b/process-video-beta index e37980e..97aeffa 100755 --- a/process-video-beta +++ b/process-video-beta @@ -202,7 +202,7 @@ while read crop; do cd $output_dir #parallel -i FlyTrackingIterativeFilter {} 15 $output_dir/Masks/$setname/Masks/ $output_dir/Filtered/$setname/ -- $( ls $output_dir/Masks/$setname/Masks/ ) - ls $output_dir/Masks/$setname/Masks/ | parallel -v -j +0 -S $server_list /site/kuiper/jcm357/FlyTrackingIterativeFilter {} 15 $output_dir/Masks/$setname/Masks/ $output_dir/Filtered/$setname/ + ls $output_dir/Masks/$setname/Masks/ | parallel -v -j +0 -S $server_list /site/kuiper/jcm357/FilterFlyMask {} 15 $output_dir/Masks/$setname/Masks/ $output_dir/Filtered/$setname/ i=$(( $i + 1 )) done < $crop_file @@ -227,4 +227,3 @@ done < $crop_file wait fi -echo "Finished" |