chronojump r429 - trunk/src/angle



Author: xaviblas
Date: Thu Nov 13 17:14:32 2008
New Revision: 429
URL: http://svn.gnome.org/viewvc/chronojump?rev=429&view=rev

Log:
little changes and two bugfixes


Modified:
   trunk/src/angle/kneeAngle.cpp
   trunk/src/angle/kneeAngleFunctions.cpp
   trunk/src/angle/kneeAngleGlobal.cpp

Modified: trunk/src/angle/kneeAngle.cpp
==============================================================================
--- trunk/src/angle/kneeAngle.cpp	(original)
+++ trunk/src/angle/kneeAngle.cpp	Thu Nov 13 17:14:32 2008
@@ -110,7 +110,6 @@
 /*
  * TODO:
  * -imprimeixi en arxiu xy de cada punt (6 columnes)
- *  -implement adaptative threshold on skin only markers, to allow hip (pant bended) to be detected without having a threshold too low or too large on knee and toe. This doesn't work, because what we need is more threshold in one point and less sin other (allowing to select point coordinates). this can be done maybe, making a copy of part of the image and applying threshold there, then copying again that part into the original image. Better, do it with cvSetImageROI and cvResetImageROI
  *  -implement convexity defects (opencv book p.259) at findKneePointBack
  *  solve the problem with the cvCopy(frame_copy,result);
  *  	on blackAndMarkers, minimumFrame is the marked or the expected?
@@ -158,11 +157,18 @@
 	{
 		exit(0);
 	}
+	
+	if(argc == 3) {
+		startAt = atoi(argv[2]);
+	}
+
 	/*
 	int framesNumber = cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_COUNT);
 	printf("--%d--\n", framesNumber);
 	*/
 
+	printf("framesCount;hip.x;hip.y;knee.x;knee.y;toe.x;toe.y;angle seen;angle side;angle real\n");
+
 	
 	/* initialization variables */
 	IplImage *frame=0,*frame_copy=0,*gray=0,*segmented=0,*edge=0,*temp=0,*output=0;
@@ -182,7 +188,7 @@
 	gui = cvLoadImage("kneeAngle_intro.png");
 	cvShowImage("gui", gui);
 	int programMode = menu(gui, font);
-	printf("programMode: %d\n", programMode);
+	//printf("programMode: %d\n", programMode);
 	
 	if(programMode == skinOnlyMarkers)
 		gui = cvLoadImage("kneeAngle_skin.png");
@@ -494,11 +500,6 @@
 			}
 
 
-
-
-
-
-
 			CvSeq* seqHolesEnd = findHolesSkin(output, frame_copy, hipMarked, kneeMarked, toeMarked, font);
 
 			hipMarked = *CV_GET_SEQ_ELEM( CvPoint, seqHolesEnd, 0); 
@@ -552,7 +553,7 @@
 			{
 				// force a playPause and reload frame after
 				// then all the code of key mouse interaction will be together at end of loop
-				mouseClicked = PLAYPAUSE;
+				forcePause = true;
 				reloadFrame = true;
 			}
 		} 
@@ -639,6 +640,13 @@
 						);
 				cvShowImage("toClick", frame_copy);
 				cvShowImage("threshold",output);
+			
+				printf("%d;%d;%d;%d;%d;%d;%d;%.2f;%.2f;%.2f\n", 
+						framesCount, 
+						hipMarked.x, frame->height - hipMarked.y,
+						kneeMarked.x, frame-> height - kneeMarked.y,
+						toeMarked.x, frame->height - toeMarked.y,
+						thetaMarked, thetaABD, thetaRealFlex);
 			}
 
 			printOnScreen(frame_copy, font, CV_RGB(255,255,255), labelsAtLeft,
@@ -1326,7 +1334,9 @@
 					forceMouseMark = myMark;
 			
 					cvSetMouseCallback( "toClick", on_mouse_mark_point, 0 );
+					mouseClicked = UNDEFINED;  
 					bool doneMarking = false;
+					bool cancelled = false;
 					do {
 						key = (char) cvWaitKey(playDelay);
 						if(!pointIsEqual(markedBefore, markedMouse)) {
@@ -1358,7 +1368,12 @@
 							}
 							mouseClicked = UNDEFINED;  
 						}
-					} while(!doneMarking);
+					
+						else if(mouseClicked == HIPMARK || mouseClicked == KNEEMARK || 
+								mouseClicked == TOEMARK) {
+							cancelled = true;
+						}
+					} while(!doneMarking && !cancelled);
 					
 					eraseGuiMark(gui, myMark);
 					
@@ -1371,26 +1386,24 @@
 						cvSetMouseCallback( "toClick", on_mouse_mark_point, 0 );
 					}
 					
-					if(mouseClicked == HIPMARK) {
-						hipMarked = markedMouse;
-						hipOld = markedMouse;
-					} else if(mouseClicked == KNEEMARK) {
-						kneeMarked = markedMouse;
-						kneeOld = markedMouse;
-					} else { 
-						toeMarked = markedMouse;
-						toeOld = markedMouse;
+					if(!cancelled) {
+						if(myMark == TOGGLEHIP) {
+							hipMarked = markedMouse;
+							hipOld = markedMouse;
+						} else if(myMark == TOGGLEKNEE) {
+							kneeMarked = markedMouse;
+							kneeOld = markedMouse;
+						} else { 
+							toeMarked = markedMouse;
+							toeOld = markedMouse;
+						}
 					}
 
-
 					eraseGuiResult(gui, true);
 					forceMouseMark = TOGGLENOTHING;
 					mouseClicked = UNDEFINED;  
 				}
 
-				
-					
-
 			} while (! done);
 					
 			eraseGuiResult(gui, true);
@@ -1431,7 +1444,7 @@
 		cvWaitKey(0);
 	}
 	else {
-		printf("*** Result ***\nMin angle: %.2f, lowest angle frame: %d\n", minThetaMarked, lowestAngleFrame);
+		//printf("*** Result ***\nMin angle: %.2f, lowest angle frame: %d\n", minThetaMarked, lowestAngleFrame);
 		cvNamedWindow("Minimum Frame",1);
 		cvShowImage("Minimum Frame", result);
 		cvWaitKey(0);

Modified: trunk/src/angle/kneeAngleFunctions.cpp
==============================================================================
--- trunk/src/angle/kneeAngleFunctions.cpp	(original)
+++ trunk/src/angle/kneeAngleFunctions.cpp	Thu Nov 13 17:14:32 2008
@@ -624,6 +624,7 @@
 	CvSeq* seqPoints = cvCreateSeq( CV_SEQ_KIND_GENERIC|CV_32SC2, sizeof(CvSeq), sizeof(CvPoint), storage );
 	CvSeq* seqGroups = cvCreateSeq( 0, sizeof(CvSeq), sizeof(0), storage );
 
+	
 	//put all hole points on seqAllHoles
 	for(int y=0;y<endy;y++)
 	{
@@ -695,7 +696,7 @@
 	CvSeq* seqIsValidSize = cvCreateSeq( 0, sizeof(CvSeq), sizeof(0), storage ); //'1' if is valid
 
 	int minSide = 2;
-	int maxSize = 200;
+	int maxSize = 400;
 	int validValue = 1;
 	int nonValidValue = 0;
 	for( int i = 0; i < seqHolesUpLeft->total; i++ ) {
@@ -765,19 +766,19 @@
 					if(hipPoint.x == 0) {
 						hipPoint.x = center.x; 
 						hipPoint.y = center.y;
-						color = CV_RGB(255, 0, 0 );
+						color = RED;
 						sprintf(labelShort,"H");
 					} 
 					else if(kneePoint.x == 0) {
 						kneePoint.x = center.x; 
 						kneePoint.y = center.y;
-						color = CV_RGB(0, 255, 0 );
+						color = GREEN;
 						sprintf(labelShort,"K");
 					} 
 					else {
 						toePoint.x = center.x; 
 						toePoint.y = center.y;
-						color = CV_RGB(0, 0, 255 );
+						color = BLUE;
 						sprintf(labelShort,"T");
 					}
 				}
@@ -789,19 +790,19 @@
 				if(pointInside(hipOld, sp1, sp2)) {
 					hipPoint.x = center.x; 
 					hipPoint.y = center.y;
-					color = CV_RGB(255, 0, 0 );
+					color = RED;
 					sprintf(labelShort,"H");
 				} 
 				else if(pointInside(kneeOld, sp1,sp2)) {
 					kneePoint.x = center.x; 
 					kneePoint.y = center.y;
-					color = CV_RGB(0, 255, 0 );
+					color = GREEN;
 					sprintf(labelShort,"K");
 				} 
 				else if(pointInside(toeOld, sp1,sp2)) {
 					toePoint.x = center.x; 
 					toePoint.y = center.y;
-					color = CV_RGB(0, 0, 255);
+					color = BLUE;
 					sprintf(labelShort,"T");
 				} else 
 					validSure = false;

Modified: trunk/src/angle/kneeAngleGlobal.cpp
==============================================================================
--- trunk/src/angle/kneeAngleGlobal.cpp	(original)
+++ trunk/src/angle/kneeAngleGlobal.cpp	Thu Nov 13 17:14:32 2008
@@ -87,25 +87,12 @@
 
 enum { TOGGLENOTHING = -1, TOGGLEHIP = 0, TOGGLEKNEE = 1, TOGGLETOE = 2};
 
-double zoomScale = 2; 
-
-//CvPoint hipMouse;
-//CvPoint kneeMouse;
-//CvPoint toeMouse;
 CvPoint markedMouse;
-
 int forceMouseMark;
-/*
-bool forceMouseHip = false;
-bool forceMouseKnee = false;
-bool forceMouseToe = false;
-*/
-
-bool zoomed = false;
-
-//bool mouseCanMark = true; 
-
 int mouseClicked = undefined;
 bool mouseMultiplier = false; //using shift key
 
+bool zoomed = false;
+double zoomScale = 2; 
+
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]