aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormutantturkey <mutantturke@gmail.com>2012-08-03 15:17:10 -0400
committermutantturkey <mutantturke@gmail.com>2012-08-03 15:17:10 -0400
commit5cc9a2db607ac074343d7f18e14c3bb187123530 (patch)
tree45190d7711ba5f8055a0766354a2582c3f1540ce
parentaaffa57083d35349a573dd03e5f5f905da2b69d9 (diff)
calculate frames where flies are together
-rw-r--r--fly-tools/fly-tracker/main.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/fly-tools/fly-tracker/main.cpp b/fly-tools/fly-tracker/main.cpp
index dab81b3..7be88e8 100644
--- a/fly-tools/fly-tracker/main.cpp
+++ b/fly-tools/fly-tracker/main.cpp
@@ -31,13 +31,6 @@ int main(int argc, char* argv[]) {
bool setNumberSet;
string setType;
- CvBlobs blobs;
- CvBlobs largeBlobs;
-
- IplImage *inputImg;
- IplImage *outputImg;
- IplImage *labelImg;
-
vector< pair<CvLabel, CvBlob*> > blobList;
while ((c = getopt (argc, argv, "i:o:t:n:hv")) != -1)
@@ -85,11 +78,16 @@ int main(int argc, char* argv[]) {
}
string fileName;
- int fileNumber;
+ long int fileNumber = 0;
+ long int totalFrames = 0;
+ long int togetherFrames = 0;
+
bool togetherState = false;
while (inputFile>>fileName) {
+ totalFrames += 1;
+
IplImage *inputImg, *outputImg, *labelImg;
inputImg = cvLoadImage(fileName.c_str(), CV_LOAD_IMAGE_GRAYSCALE);
@@ -106,16 +104,20 @@ int main(int argc, char* argv[]) {
copy(blobs.begin(), blobs.end(), back_inserter(blobList));
sort(blobList.begin(), blobList.end(), cmpArea);
- (blobList.size() == 1) ? togetherState = true : togetherState = false;
+ if (blobList.size() == 1) {
+ togetherState = true;
+ togetherFrames += 1;
+ } else {
+ togetherState = false;
+ }
// List detected blob in each file
*output << "File: " << fileName << endl;
*output << "\t Together:" << togetherState << endl;
for (int i=0; i<(int)blobList.size(); i++) {
- *output << "\t Blob #" << blobList[i].first << " -> " << (*blobList[i].second) << endl;
+ *output << "\t Blob #" << blobList[i].first << " -> " << (*blobList[i].second) << endl;
}
-
// Release all the memory
cvReleaseImage(&labelImg);
cvReleaseImage(&inputImg);
@@ -123,5 +125,9 @@ int main(int argc, char* argv[]) {
}
+ cout << "Final Information" << endl;
+ cout << "\t Total Number of frames in video: " << totalFrames << endl;
+ cout << "\t Number of frames where there flies are together: " << togetherFrames << endl;
+ cout << "\t Percent of video where there flies are together: " << (long double)togetherFrames / totalFrames << endl;
return 0;
}